Template Class Topic

Class Documentation

template<typename Data>
class Topic

Stores publisher and subscriber lists to a uniquely string identified topic.

This is not for direct use, its the storage container for the sigslots manager.

Public Types

typedef std::set<SigSlot<Data>*> Subscribers

A list of subscribers (slots) to a given topic.

Public Functions

inline Topic(const std::string &name)

Uniquely construct with the specified name.

Parameters:

name – : name of the topic.

inline const Subscribers *subscribers() const

List of subscribers (listeners) to a topic.

Returns:

Subscribers : handle to the list.

inline void addSubscriber(SigSlot<Data> *sigslot)

Add a subscriber.

Parameters:

sigslot – : the sigslot to add.

inline void addPublisher(SigSlot<Data> *sigslot)

Add a publisher.

Parameters:

sigslot – : the sigslot to add.

inline void disconnect(SigSlot<Data> *sigslot)

Disconnect a sigslot.

This parses both publishers and subscribers looking for the sigslot to connect. Could be a bit heavy doing it this way, but its convenient.

Parameters:

sigslot – : the sigslot to disconnect.

inline bool empty() const

Checks to see if there is no publishers/subscribers.

This is used to delete the topic (by the manager) if it is empty.

Returns:

bool : empty (true) or not (false).

Friends

template<typename OutputStream, typename TopicData>
friend OutputStream &operator<<(OutputStream &ostream, const Topic<TopicData> &topic)

Insertion operator for sending the topic to an output stream.

Parameters:
  • ostream – : the output stream.

  • topic – : the topic to be inserted.

Returns:

OutputStream : continue streaming with the updated output stream.