RSC  0.16.0
rsc::logging::LoggerTreeNode Class Reference

A simple tree representation for loggers. More...

#include <LoggerTreeNode.h>

Inheritance diagram for rsc::logging::LoggerTreeNode:
Inheritance graph
Collaboration diagram for rsc::logging::LoggerTreeNode:
Collaboration graph

Classes

class  Visitor
 Visitor interface to operate on the tree. More...
 

Public Types

typedef std::vector< std::string > NamePath
 A unique representation of a name. More...
 
typedef boost::function< LoggerProxyPtr(const NamePath &name, LoggerTreeNodePtr node)> CreateFunction
 
typedef boost::shared_ptr< VisitorVisitorPtr
 

Public Member Functions

 LoggerTreeNode (const std::string &name, LoggerTreeNodeWeakPtr parent)
 Creates a new node without an assigned LoggerProxy. More...
 
 LoggerTreeNode (const std::string &name, LoggerProxyPtr loggerProxy, LoggerTreeNodeWeakPtr parent)
 Creates a new node with a LoggerProxy assigned. More...
 
LoggerTreeNodePtr getParent () const
 
std::string getName () const
 
LoggerProxyPtr getLoggerProxy () const
 
void setLoggerProxy (LoggerProxyPtr loggerProxy)
 
bool addChild (LoggerTreeNodePtr child)
 Adds a child if it does not exist so far. More...
 
LoggerTreeNodePtr addChildren (const NamePath &path, CreateFunction createFn, const NamePath &processedPath=NamePath())
 Retrieves an (indirect) child and creates required ancestors of this child using a custom callback method. More...
 
void visit (VisitorPtr visitor, const NamePath &thisPath=NamePath())
 Visits every sub-node excluding this node. More...
 
bool hasChild (const std::string &name) const
 
bool hasChild (const NamePath &path) const
 
LoggerTreeNodePtr getChild (const std::string &name) const
 
LoggerTreeNodePtr getChild (const NamePath &path) const
 
void clearChildren ()
 
boost::shared_ptr< Logger::LevelgetAssignedLevel () const
 
void setAssignedLevel (boost::shared_ptr< Logger::Level > level)
 
void setAssignedLevel (const Logger::Level &level)
 
bool hasAssignedLevel () const
 

Static Public Member Functions

static NamePath nameToPath (const std::string &name)
 Converts a string name of the form a.test.string to a hierarchical logger path representation. More...
 
static std::string pathToName (const NamePath &path)
 

Private Attributes

std::string name
 New name part of this node. More...
 
LoggerProxyPtr loggerProxy
 
LoggerTreeNodeWeakPtr parent
 
std::map< std::string, LoggerTreeNodePtrchildren
 
boost::shared_ptr< Logger::LevelassignedLevel
 

Detailed Description

A simple tree representation for loggers.

We do not use any special library but create our own one because all publicly available libs like BGL are too big for this purpose and BGL is often not included in boost distributions.

Author
jwienke

Definition at line 55 of file LoggerTreeNode.h.

Member Typedef Documentation

Definition at line 100 of file LoggerTreeNode.h.

typedef std::vector<std::string> rsc::logging::LoggerTreeNode::NamePath

A unique representation of a name.

From the string representation this is the name split at each '.' char. Empty vector means root logger.

Definition at line 62 of file LoggerTreeNode.h.

Definition at line 134 of file LoggerTreeNode.h.

Constructor & Destructor Documentation

rsc::logging::LoggerTreeNode::LoggerTreeNode ( const std::string &  name,
LoggerTreeNodeWeakPtr  parent 
)

Creates a new node without an assigned LoggerProxy.

This needs to be set afterwards with setLoggerProxy.

Parameters
namename of the current path element, i.e. not the full path
parentparent tree node

Definition at line 39 of file LoggerTreeNode.cpp.

Referenced by addChildren().

Here is the caller graph for this function:

rsc::logging::LoggerTreeNode::LoggerTreeNode ( const std::string &  name,
LoggerProxyPtr  loggerProxy,
LoggerTreeNodeWeakPtr  parent 
)

Creates a new node with a LoggerProxy assigned.

Parameters
namename of the current path element, i.e. not the full path
loggerProxyassigned logger proxy
parentparent tree node

Definition at line 43 of file LoggerTreeNode.cpp.

Member Function Documentation

bool rsc::logging::LoggerTreeNode::addChild ( LoggerTreeNodePtr  child)

Adds a child if it does not exist so far.

Parameters
childchild to add
Returns
true if the new child was added, false if it already exited.

Definition at line 64 of file LoggerTreeNode.cpp.

References children, and rsc::patterns::detail::make_pair().

Here is the call graph for this function:

LoggerTreeNodePtr rsc::logging::LoggerTreeNode::addChildren ( const NamePath path,
CreateFunction  createFn,
const NamePath processedPath = NamePath() 
)

Retrieves an (indirect) child and creates required ancestors of this child using a custom callback method.

Parameters
pathpath of the child starting from this node
createFnfunction used to create new children
processedPaththe path of this node. Passed to the create function
Returns
the deepest child in the path

Definition at line 69 of file LoggerTreeNode.cpp.

References children, and LoggerTreeNode().

Here is the call graph for this function:

void rsc::logging::LoggerTreeNode::clearChildren ( )

Definition at line 165 of file LoggerTreeNode.cpp.

References children.

boost::shared_ptr< Logger::Level > rsc::logging::LoggerTreeNode::getAssignedLevel ( ) const

Definition at line 209 of file LoggerTreeNode.cpp.

References assignedLevel.

LoggerTreeNodePtr rsc::logging::LoggerTreeNode::getChild ( const std::string &  name) const

Definition at line 137 of file LoggerTreeNode.cpp.

References children.

LoggerTreeNodePtr rsc::logging::LoggerTreeNode::getChild ( const NamePath path) const

Definition at line 148 of file LoggerTreeNode.cpp.

References children, and name.

LoggerProxyPtr rsc::logging::LoggerTreeNode::getLoggerProxy ( ) const

Definition at line 56 of file LoggerTreeNode.cpp.

References loggerProxy.

string rsc::logging::LoggerTreeNode::getName ( ) const

Definition at line 52 of file LoggerTreeNode.cpp.

References name.

LoggerTreeNodePtr rsc::logging::LoggerTreeNode::getParent ( ) const

Definition at line 48 of file LoggerTreeNode.cpp.

References parent.

bool rsc::logging::LoggerTreeNode::hasAssignedLevel ( ) const

Definition at line 221 of file LoggerTreeNode.cpp.

References assignedLevel.

bool rsc::logging::LoggerTreeNode::hasChild ( const std::string &  name) const

Definition at line 119 of file LoggerTreeNode.cpp.

References children.

bool rsc::logging::LoggerTreeNode::hasChild ( const NamePath path) const

Definition at line 123 of file LoggerTreeNode.cpp.

References children.

LoggerTreeNode::NamePath rsc::logging::LoggerTreeNode::nameToPath ( const std::string &  name)
static

Converts a string name of the form a.test.string to a hierarchical logger path representation.

All upper-case letters will be converted to lower-case ones during this process.

Parameters
namepoint-separated string name of logger
Returns
split path with lower-case parts

Definition at line 169 of file LoggerTreeNode.cpp.

References name.

string rsc::logging::LoggerTreeNode::pathToName ( const NamePath path)
static

Definition at line 198 of file LoggerTreeNode.cpp.

void rsc::logging::LoggerTreeNode::setAssignedLevel ( boost::shared_ptr< Logger::Level level)

Definition at line 213 of file LoggerTreeNode.cpp.

References assignedLevel.

void rsc::logging::LoggerTreeNode::setAssignedLevel ( const Logger::Level level)

Definition at line 217 of file LoggerTreeNode.cpp.

References assignedLevel.

void rsc::logging::LoggerTreeNode::setLoggerProxy ( LoggerProxyPtr  loggerProxy)

Definition at line 60 of file LoggerTreeNode.cpp.

References loggerProxy.

void rsc::logging::LoggerTreeNode::visit ( VisitorPtr  visitor,
const NamePath thisPath = NamePath() 
)

Visits every sub-node excluding this node.

Depth-first strategy is used.

Parameters
visitorvisitor to use

Definition at line 101 of file LoggerTreeNode.cpp.

References children, and loggerProxy.

Member Data Documentation

boost::shared_ptr<Logger::Level> rsc::logging::LoggerTreeNode::assignedLevel
private

Definition at line 181 of file LoggerTreeNode.h.

Referenced by getAssignedLevel(), hasAssignedLevel(), and setAssignedLevel().

std::map<std::string, LoggerTreeNodePtr> rsc::logging::LoggerTreeNode::children
private

Definition at line 179 of file LoggerTreeNode.h.

Referenced by addChild(), addChildren(), clearChildren(), getChild(), hasChild(), and visit().

LoggerProxyPtr rsc::logging::LoggerTreeNode::loggerProxy
private

Definition at line 176 of file LoggerTreeNode.h.

Referenced by getLoggerProxy(), setLoggerProxy(), and visit().

std::string rsc::logging::LoggerTreeNode::name
private

New name part of this node.

Somehow mirrored from loggerProxy because we do not want to rely on the custom logger implementation correctness.

Definition at line 175 of file LoggerTreeNode.h.

Referenced by getChild(), getName(), and nameToPath().

LoggerTreeNodeWeakPtr rsc::logging::LoggerTreeNode::parent
private

Definition at line 178 of file LoggerTreeNode.h.

Referenced by getParent().


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