12 #ifndef ECL_SIGSLOTS_TOPIC_HPP_ 13 #define ECL_SIGSLOTS_TOPIC_HPP_ 21 #include <ecl/config/macros.hpp> 33 template <
typename Data>
44 template <
typename Data>
50 typedef std::set<SigSlot<Data>*> Subscribers;
56 Topic(
const std::string& name) : topic_name(name) {}
62 const Subscribers* subscribers()
const {
return &topic_subscribers; }
68 void addSubscriber(SigSlot<Data>* sigslot) {
69 topic_subscribers.insert(sigslot);
75 void addPublisher(SigSlot<Data>* sigslot) {
76 topic_publishers.insert(sigslot);
86 void disconnect(SigSlot<Data>* 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);
119 std::string topic_name;
120 std::set<SigSlot<Data>*> topic_publishers;
121 std::set<SigSlot<Data>*> topic_subscribers;
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";
ecl_geometry_PUBLIC bool empty(const Trajectory2D &trajectory)