12 #ifndef ECL_SIGSLOTS_TOPIC_HPP_ 13 #define ECL_SIGSLOTS_TOPIC_HPP_ 33 template <
typename Data>
44 template <
typename Data>
56 Topic(
const std::string& name) : topic_name(name) {}
62 const Subscribers*
subscribers()
const {
return &topic_subscribers; }
69 topic_subscribers.insert(sigslot);
76 topic_publishers.insert(sigslot);
87 typename std::set<SigSlot<Data>*>::const_iterator iter = topic_publishers.find(sigslot);
88 if ( iter != topic_publishers.end() ) {
89 topic_publishers.erase(iter);
91 iter = topic_subscribers.find(sigslot);
92 if ( iter != topic_subscribers.end() ) {
93 topic_subscribers.erase(iter);
103 return ( ( topic_publishers.size() == 0 ) && ( topic_subscribers.size() == 0 ) );
115 template <
typename OutputStream,
typename TopicData>
116 friend OutputStream& operator<<(OutputStream &ostream , const Topic<TopicData>& topic);
129 template <
typename OutputStream,
typename TopicData>
130 OutputStream& operator<<(OutputStream &ostream , const Topic<TopicData> &topic) {
132 ostream <<
" Name: " << topic.topic_name <<
"\n";
133 ostream <<
" # Subscribers: " << topic.topic_subscribers.size() <<
"\n";
134 ostream <<
" # Publishers : " << topic.topic_publishers.size() <<
"\n";
const Subscribers * subscribers() const
List of subscribers (listeners) to a topic.
Topic(const std::string &name)
Uniquely construct with the specified name.
Stores publisher and subscriber lists to a uniquely string identified topic.
std::set< SigSlot< Data > * > Subscribers
A list of subscribers (slots) to a given topic.
bool empty() const
Checks to see if there is no publishers/subscribers.
void disconnect(SigSlot< Data > *sigslot)
Disconnect a sigslot.
std::set< SigSlot< Data > * > topic_publishers
void addPublisher(SigSlot< Data > *sigslot)
Add a publisher.
void addSubscriber(SigSlot< Data > *sigslot)
Add a subscriber.
Not for direct use, provides the power behind both signals and slots.
std::set< SigSlot< Data > * > topic_subscribers