14 #ifndef ECL_SIGSLOTS_SIGSLOT_HPP_ 15 #define ECL_SIGSLOTS_SIGSLOT_HPP_ 24 #include <ecl/config/macros.hpp> 25 #include <ecl/threads/mutex.hpp> 26 #include <ecl/utilities/function_objects.hpp> 27 #include <ecl/utilities/void.hpp> 45 template <
typename Data=Vo
id>
52 typedef typename std::map<std::string, const Subscribers*>
PublicationMap;
62 function =
new PartiallyBoundUnaryMemberFunction< SigSlot<Data> ,Data,
void >( &
SigSlot<Data>::emit, *
this);
70 function =
new UnaryFreeFunction<Data>(
f);
81 function =
new PartiallyBoundUnaryMemberFunction<C,Data,void>(f,c);
106 void emit(Data data) {
107 typename PublicationMap::const_iterator topic_iter;
108 typename Subscribers::const_iterator slots_iter;
110 const Subscribers* subscribers = topic_iter->second;
111 for ( slots_iter = subscribers->begin(); slots_iter != subscribers->end(); ++slots_iter ) {
112 SigSlot<Data> *sigslot = *slots_iter;
113 sigslot->process(data);
157 std::pair< std::set<std::string>::iterator,
bool > ret;
168 std::set<std::string>::const_iterator listen_iter =
subscriptions.find(topic);
178 std::set<std::string>::iterator iter;
183 typename std::map<std::string,const Subscribers*>::iterator emit_iter;
199 UnaryFunction<Data,void> *
function;
225 function =
new BoundNullaryMemberFunction<SigSlot,void>(&
SigSlot::emit,*
this);
233 function =
new NullaryFreeFunction<void>(f);
244 function =
new BoundNullaryMemberFunction<C,void>(f,c);
270 PublicationMap::const_iterator topic_iter;
271 Subscribers::const_iterator slots_iter;
273 const Subscribers* subscribers = topic_iter->second;
274 for ( slots_iter = subscribers->begin(); slots_iter != subscribers->end(); ++slots_iter ) {
275 SigSlot *sigslot = *slots_iter;
286 void process(Void void_arg = Void()) {
316 std::pair< std::set<std::string>::iterator,
bool > ret;
330 std::set<std::string>::const_iterator listen_iter =
subscriptions.find(topic);
340 std::set<std::string>::iterator iter;
345 std::map<std::string,const Subscribers*>::iterator emit_iter;
static void connectSlot(const std::string &topic, SigSlot< Data > *sigslot)
Topic< Data >::Subscribers Subscribers
std::set< SigSlot< Data > * > Subscribers
void connectSignal(const std::string &topic)
const std::set< std::string > & subscribedTopics()
unsigned int number_of_handles
const unsigned int & handles() const
PublicationMap publications
static void disconnect(const std::string &topic, SigSlot< Data > *sigslot)
unsigned int processing_count
std::map< std::string, const Subscribers * > PublicationMap
std::set< std::string > subscriptions
static const Subscribers * connectSignal(const std::string &topic, SigSlot< Data > *sigslot)
void connectSlot(const std::string &topic)