#include <rlog/RLogPublisher.h>
Inheritance diagram for rlog::RLogPublisher:
Public Member Functions | |
RLogPublisher (PublishLoc *src) | |
Static Public Member Functions | |
static void | Publish (PublishLoc *, RLogChannel *, const char *format,...) |
static void | PublishVA (PublishLoc *, RLogChannel *, const char *format, va_list args) |
Public Attributes | |
PublishLoc * | src |
Protected Member Functions | |
virtual void | setEnabled (bool newState) |
For derived classes to get notified of activation status change. | |
RLogPublisher (const RLogPublisher &) | |
RLogPublisher & | operator= (const RLogPublisher &) |
This derives from RLogNode and interfaces to the static PublishLoc logging data allowing them to be enabled or disabled depending on subscriber status.
An instance of this class is created for every error message location. Normally this class is not used directly.
For example, this
rDebug( "hello world" );
is turned approximatly into this:
static PublishLoc _rl = { publish: & rlog::RLog_Register , pub: 0, component: "component", fileName: "myfile.cpp", functionName: "functionName()", lineNum: __LINE__, channel: 0 }; if(_rL.publish != 0) (*_rl.publish)( &_rL, _RLDebugChannel, "hello world" );
The RLogPublisher instance manages the contents of the static structure _rL. When someone subscribes to it's message, then _rL.publish is set to point to the publishing function, and when there are no subscribers then it is set to 0.
The code produced contains one if statement, and with optimization comes out to about 3 instructions on an x86 computer (not including the function call). If there are no subscribers to this message then that is all the overhead, plus the memory usage for the structures involved and the initial registration when the statement is first encountered..
void RLogPublisher::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 from rlog::RLogNode.