34 #include <boost/shared_ptr.hpp> 35 #include <boost/function.hpp> 37 #include "../../rsb/Scope.h" 40 namespace eventprocessing {
60 return this->
sinks.empty();
69 return this->
sinks.size();
80 this->
sinks[scope].push_back(sink);
91 typename SinkMap::iterator it = this->
sinks.find(scope);
92 if (it == this->
sinks.end()) {
93 throw std::logic_error(
"Should not happen");
98 this->sinks.erase(it);
113 boost::function<
void (
const T&)>
function)
const {
114 std::vector<Scope> scopes = scope.
superScopes(
true);
115 for (std::vector<Scope>::const_iterator it = scopes.begin(); it != scopes.end(); ++it) {
116 typename SinkMap::const_iterator it_ = this->
sinks.find(*it);
117 if (it_ != this->
sinks.end()) {
120 for (
typename SinkList::const_iterator it__ = sinks.begin();
121 it__ != sinks.end(); ++it__) {
134 void mapAllSinks(boost::function<
void (
const T&)>
function)
const {
135 for (
typename SinkMap::const_iterator it = this->
sinks.begin();
136 it != this->
sinks.end(); ++it) {
138 for (
typename SinkList::const_iterator it_ = sinks.begin();
139 it_ != sinks.end(); ++it_) {
156 template <
typename T>
160 typename WeakScopeDispatcher::SinkMap::iterator it = this->
sinks.find(scope);
161 if (it == this->
sinks.end()) {
162 throw std::logic_error(
"Should not happen");
165 for (
typename WeakScopeDispatcher::SinkList::iterator it
166 = sinks.begin(); it != sinks.end();) {
167 boost::shared_ptr<T> pointer = it->lock();
170 it = sinks.erase(it);
171 }
else if (pointer.get() == sink) {
172 it = sinks.erase(it);
178 this->sinks.erase(it);
183 boost::function<
void (T&)>
function)
const {
184 std::vector<Scope> scopes = scope.
superScopes(
true);
185 for (std::vector<Scope>::const_iterator it = scopes.begin(); it != scopes.end(); ++it) {
186 typename WeakScopeDispatcher::SinkMap::const_iterator it_ = this->
sinks.find(*it);
187 if (it_ != this->
sinks.end()) {
190 for (
typename WeakScopeDispatcher::SinkList::const_iterator it__
191 = sinks.begin(); it__ != sinks.end(); ++it__) {
192 boost::shared_ptr<T> pointer = it__->lock();
202 for (
typename WeakScopeDispatcher::SinkMap::const_iterator it
203 = this->
sinks.begin(); it != this->
sinks.end(); ++it) {
205 for (
typename WeakScopeDispatcher::SinkList::const_iterator it_
206 = sinks.begin(); it_ != sinks.end(); ++it_) {
207 boost::shared_ptr<T> pointer = it_->lock();
void removeSink(const Scope &scope, const T &sink)
Removes sink from the list of sinks associated to scope.
A variant of ScopeDispatcher that references sinks weakly.
void mapAllSinks(boost::function< void(const T &)> function) const
Calls function for each sink in the dispatcher.
bool empty() const
Indicates whether there are scopes with associated sinks.
Maps scopes to sets of sinks of type T.
void mapSinks(const Scope &scope, boost::function< void(const T &)> function) const
Calls function for each sink associated to scope-scopes of scope.
size_t size() const
Returns number of scopes with associated sinks.
void addSink(const Scope &scope, const T &sink)
Associates sink with scope.
std::map< Scope, SinkList > SinkMap
void mapSinks(const Scope &scope, boost::function< void(T &)> function) const
std::vector< Scope > superScopes(const bool &includeSelf=false) const
Generates all super scopes of this scope including the root scope "/".
std::list< boost::weak_ptr< InConnector > > SinkList
Scope is a descriptor for a hierarchical channel of the unified bus.
void removeSink(const Scope &scope, const T *sink)
void mapAllSinks(boost::function< void(T &)> function) const