31 using namespace rsc::logging;
33 using namespace rsb::transport;
39 logger(Logger::getLogger(
"rsb.inprocess.Bus")), singleThreaded(false) {
43 if (!this->
sinks.empty()) {
46 "" << this->
sinks.size()
47 <<
" non-empty scopes when destructing");
60 boost::recursive_mutex::scoped_lock lock(this->
mutex);
62 RSCDEBUG(
logger,
"Adding sink " << sink);
64 SinkMap::iterator it = this->
sinks.find(sink->getScope());
65 if (it == this->
sinks.end()) {
67 "No entry in sink map for event scope " << sink->getScope());
69 set<boost::weak_ptr<InConnector> > connectors;
70 for (SinkMap::iterator it_ = this->
sinks.begin(); it_
71 != this->
sinks.end(); ++it_) {
74 "Adding " << it_->second.size() <<
" connectors from "
77 if (it_->first == sink->getScope() || it_->first.isSuperScopeOf(
79 copy(it_->second.begin(), it_->second.end(),
80 inserter(connectors, connectors.begin()));
83 copy(connectors.begin(), connectors.end(),
84 back_inserter(this->
sinks[sink->getScope()]));
88 "Created entry in sink map for scope " << sink->getScope()
89 <<
" with " << connectors.size() <<
" connectors");
91 it = this->
sinks.find(sink->getScope());
93 it->second.push_back(sink);
95 for (SinkMap::iterator it = this->
sinks.begin(); it != this->
sinks.end(); ++it) {
96 if (it->first.isSubScopeOf(sink->getScope())) {
98 connectors.push_back(sink);
104 boost::recursive_mutex::scoped_lock lock(this->
mutex);
107 RSCDEBUG(
logger,
"Removing sink " << sink);
109 for (SinkMap::iterator it = this->
sinks.begin(); it != this->
sinks.end(); ++it) {
113 "Scope " << it->first <<
" has " << connectors.size()
116 for (SinkList::iterator it_ = connectors.begin(); it_
117 != connectors.end(); ++it_) {
121 if (!ptr || (ptr.get() == sink)) {
123 "Found connector " << sink <<
" in scope " << it->first);
124 it_ = connectors.erase(it_);
131 "Scope " << it->first <<
" has " << connectors.size()
133 if (connectors.empty()) {
134 RSCDEBUG(
logger,
"Removing empty scope " << it->first);
146 boost::recursive_mutex::scoped_lock lock(this->
mutex);
154 SinkMap::const_iterator it = this->
sinks.find(*event->getScopePtr());
155 if (it == this->
sinks.end()) {
157 "No entry in sink map for event scope " << *event->getScopePtr());
159 set<boost::weak_ptr<InConnector> > connectors;
160 for (SinkMap::iterator it_ = this->
sinks.begin(); it_
161 != this->
sinks.end(); ++it_) {
164 "Adding " << it_->second.size() <<
" connectors from "
167 if (it_->first == *event->getScopePtr() || it_->first.isSuperScopeOf(
168 *event->getScopePtr())) {
169 copy(it_->second.begin(), it_->second.end(),
170 inserter(connectors, connectors.begin()));
173 copy(connectors.begin(), connectors.end(),
174 back_inserter(this->
sinks[*event->getScopePtr()]));
178 "Created entry in sink map for scope " << *event->getScopePtr()
179 <<
" with " << connectors.size() <<
" connectors");
181 it = this->
sinks.find(*event->getScopePtr());
184 const SinkList& connectors = it->second;
185 for (SinkList::const_iterator it__ = connectors.begin(); it__
186 != connectors.end(); ++it__) {
190 connector->handle(event);