RSC
0.16.0
|
A simple tree representation for loggers. More...
#include <LoggerTreeNode.h>
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< Visitor > | VisitorPtr |
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::Level > | getAssignedLevel () 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, LoggerTreeNodePtr > | children |
boost::shared_ptr< Logger::Level > | assignedLevel |
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.
Definition at line 55 of file LoggerTreeNode.h.
typedef boost::function< LoggerProxyPtr(const NamePath& name, LoggerTreeNodePtr node)> rsc::logging::LoggerTreeNode::CreateFunction |
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.
typedef boost::shared_ptr<Visitor> rsc::logging::LoggerTreeNode::VisitorPtr |
Definition at line 134 of file LoggerTreeNode.h.
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.
name | name of the current path element, i.e. not the full path |
parent | parent tree node |
Definition at line 39 of file LoggerTreeNode.cpp.
Referenced by addChildren().
rsc::logging::LoggerTreeNode::LoggerTreeNode | ( | const std::string & | name, |
LoggerProxyPtr | loggerProxy, | ||
LoggerTreeNodeWeakPtr | parent | ||
) |
Creates a new node with a LoggerProxy assigned.
name | name of the current path element, i.e. not the full path |
loggerProxy | assigned logger proxy |
parent | parent tree node |
Definition at line 43 of file LoggerTreeNode.cpp.
bool rsc::logging::LoggerTreeNode::addChild | ( | LoggerTreeNodePtr | child | ) |
Adds a child if it does not exist so far.
child | child to add |
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().
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.
path | path of the child starting from this node |
createFn | function used to create new children |
processedPath | the path of this node. Passed to the create function |
Definition at line 69 of file LoggerTreeNode.cpp.
References children, and LoggerTreeNode().
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.
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.
|
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.
name | point-separated string name of logger |
Definition at line 169 of file LoggerTreeNode.cpp.
References name.
|
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.
visitor | visitor to use |
Definition at line 101 of file LoggerTreeNode.cpp.
References children, and loggerProxy.
|
private |
Definition at line 181 of file LoggerTreeNode.h.
Referenced by getAssignedLevel(), hasAssignedLevel(), and setAssignedLevel().
|
private |
Definition at line 179 of file LoggerTreeNode.h.
Referenced by addChild(), addChildren(), clearChildren(), getChild(), hasChild(), and visit().
|
private |
Definition at line 176 of file LoggerTreeNode.h.
Referenced by getLoggerProxy(), setLoggerProxy(), and visit().
|
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().
|
private |
Definition at line 178 of file LoggerTreeNode.h.
Referenced by getParent().