rlog: rlog::RLogNode Class Reference

- Main Page
- Modules
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# rlog::RLogNode Class Reference

Core of publication system, forms activation network. More...

`#include <rlog/RLogNode.h>`

Inheritance diagram for rlog::RLogNode:

List of all members.

## Public Member Functions
| RLogNode ()
| Instantiate an empty RLogNode. No subscribers or publishers..
virtual | ~RLogNode ()
| Disconnects from any remaining subscribers and publishers.
virtual void | clear ()
| Force disconnection from any subscribers or publishers.
virtual void | publish (const RLogData &data)
| Publish data.
virtual void | addPublisher (RLogNode *)
| Have this node subscribe to a new publisher.
virtual void | dropPublisher (RLogNode *, bool callbacks=true)
| Drop our subscription to a publisher.
bool | enabled () const
| Returns true if this node is active.
virtual void | addSubscriber (RLogNode *)
| Add a subscriber.
virtual void | dropSubscriber (RLogNode *)
| Remove a subscriber.
virtual void | isInterested (RLogNode *node, bool isInterested)
| Change the state of one of our subscribers.
## Protected Member Functions
virtual void | setEnabled (bool newState)
| For derived classes to get notified of activation status change.
## Protected Attributes
std::list< RLogNode * > | publishers
| list of nodes we are subscribed to
std::list< RLogNode * > | subscribers
| list of nodes we publish to
std::list< RLogNode * > | interestList
| list of subscribers that are interested in receiving publications..
Mutex | mutex

## Detailed Description

Core of publication system, forms activation network.

RLogNode formes the core of the publication system. It has two primary purposes :

- link publications with subscribers
- transfer meta-data in the form or node activations

Both publishers (eg RLogPublisher) and subscribers (eg StdioNode) are derived from RLogNode, although RLogNode can be used entirely unmodified.

An RLogNode contains a list of publishers which it is linked with. It also contains a list of subscribers which it is linked with. Publications always flow from publishers to subscribers, and activation information flows the opposite direction from subscribers to publishers.

An RLogNode by default acts as both a subscriber and publisher -- when it has been subscribed to another node and receives a publication it simply repeats the information to all of its subscribers.

More specifically, it only publishes to subscribers who have also voiced an interest in receiving the publication. If a node has no subscribers which are also interested (or no subscribers at all), then it can be said to be dormant and it tells the publishers that it is subscribed to that it is no longer interested. This propogates all the way up to RLogPublishers which will disable the logging statement completely if there are no interested parties.

Author:
  Valient Gough

## Member Function Documentation

void RLogNode::publish | ( | const RLogData & | data | ) | `[virtual]`

Publish data.

This iterates over the list of subscribers which have stated interest and sends them the data.

Reimplemented in rlog::RLogChannel, rlog::StdioNode, and rlog::SyslogNode.

void RLogNode::addPublisher | ( | RLogNode * | publisher | ) | `[virtual]`

Have this node subscribe to a new publisher.

We become a subscriber of the publisher. The publisher's addSubscriber() function is called to complete the link.

If our node is active then we also tell the publisher that we want publications.

void RLogNode::dropPublisher | ( | RLogNode * | publisher,
|  | bool | callback = `true` |
| ) |  |  | `[virtual]`

Drop our subscription to a publisher.

A callback parameter is provided to help avoid loops in the code which may affect the thread locking code.

Parameters:

  | callback | If True, then we call publisher->dropSubscriber() to make sure the publisher also drops us as a subscriber.

bool RLogNode::enabled | ( |  | ) | const

Returns true if this node is active.

Returns:
  true if we have one or more interested subscribers, otherwise false

void RLogNode::addSubscriber | ( | RLogNode * | subscriber | ) | `[virtual]`

Add a subscriber.

Normally a subscriber calls this for itself when it's addPublisher() method is called.

void RLogNode::dropSubscriber | ( | RLogNode * | subscriber | ) | `[virtual]`

Remove a subscriber.

Normally a subscriber calls this for itself when it's dropPublisher() method is called.

Note that the subscriber list is kept separate from the interest list. If the subscriber is active, then you must undo that by calling isInterested(subscriber, false) in addition to dropSubscriber

void RLogNode::isInterested | ( | RLogNode * | node,
|  | bool | interest |
| ) |  |  | `[virtual]`

Change the state of one of our subscribers.

This allows a subscriber to say that it wants to be notified of publications or not. The node should already be registered as a subscriber.

If we previously had no interested parties and now we do, then we need to notify the publishers in our publishers list that we are now interested.

If we previously had interested parties and we remove the last one, then we can notify the publishers that we are no longer interested..

void RLogNode::setEnabled | ( | bool | newState | ) | `[protected, virtual]`

For derived classes to get notified of activation status change.

This is called by isInterested() when our state changes. If true is passed, then this node has become active. If false is passed, then this node has just become dormant.

Reimplemented in rlog::RLogPublisher.

The documentation for this class was generated from the following files:

- RLogNode.h
- RLogNode.cpp