14 #ifndef ECL_SIGSLOTS_MANAGER_HPP_ 15 #define ECL_SIGSLOTS_MANAGER_HPP_ 24 #include <ecl/exceptions/standard_exception.hpp> 25 #include <ecl/config/macros.hpp> 26 #include <ecl/utilities/void.hpp> 48 template<
typename Data = Vo
id>
49 class SigSlotsManager {
61 typename std::map< std::string, Topic<Data> >::iterator iter;
62 for ( iter =
topics().begin(); iter !=
topics().end(); ++iter ) {
63 std::cout << iter->second;
82 static const Subscribers*
connectSignal(
const std::string& topic, SigSlot<Data>* sigslot) {
88 std::pair< typename std::map< std::string, Topic<Data> >::iterator,
bool> ret =
topics().insert( std::pair< std::string, Topic<Data> >(topic, Topic<Data>(topic)) );
89 Topic<Data>& current_topic = (ret.first)->second;
90 current_topic.addPublisher(sigslot);
91 return current_topic.subscribers();
101 static void connectSlot(
const std::string& topic, SigSlot<Data>* sigslot) {
107 std::pair< typename std::map< std::string, Topic<Data> >::iterator,
bool> ret =
topics().insert(std::pair< std::string, Topic<Data> >(topic, Topic<Data>(topic)) );
108 Topic<Data>& current_topic = (ret.first)->second;
109 current_topic.addSubscriber(sigslot);
120 static void disconnect(
const std::string& topic, SigSlot<Data>* sigslot) {
121 typename std::map<std::string, Topic<Data> >::iterator iter =
topics().find(topic);
122 if ( iter !=
topics().end() ) {
123 iter->second.disconnect(sigslot);
125 if ( iter->second.empty() ) {
136 static bool isTopic(
const std::string& topic) {
147 static std::map< std::string, Topic<Data> >&
topics() {
148 static std::map< std::string, Topic<Data> > topic_list;
162 static const Subscribers&
subscribers(
const std::string& topic) {
163 typename std::map< std::string, Topic<Data> >::const_iterator iter =
topics().find(topic);
170 return *iter->second.subscribers();
static void connectSlot(const std::string &topic, SigSlot< Data > *sigslot)
static const Subscribers & subscribers(const std::string &topic)
std::set< SigSlot< Data > * > Subscribers
static std::map< std::string, Topic< Data > > & topics()
Topic< Data >::Subscribers Subscribers
static void printStatistics()
static void disconnect(const std::string &topic, SigSlot< Data > *sigslot)
static bool isTopic(const std::string &topic)
friend friend class SigSlot
static const Subscribers * connectSignal(const std::string &topic, SigSlot< Data > *sigslot)