senf::console::GenericNode Class Referenceabstract

Config/console node tree base-class. More...

#include <senf/Utils/Console/Node.hh>

Inheritance diagram for senf::console::GenericNode:

Public Types

typedef boost::shared_ptr< GenericNodeptr
 
typedef boost::shared_ptr< GenericNode const > cptr
 
typedef boost::weak_ptr< GenericNodeweak_ptr
 

Public Member Functions

virtual ~GenericNode ()
 
std::string const & name () const
 Node name. More...
 
boost::shared_ptr< DirectoryNodeparent () const
 Parent node. More...
 
std::string path () const
 Node path. More...
 
std::string path (DirectoryNode const &root) const
 Node path up to root. More...
 
ptr unlink ()
 Remove node from it's parent directory. More...
 
void rename (std::string const &newName)
 Rename node name in it's parent directory. More...
 
bool active () const
 true, if node is attached to the root() node More...
 
void help (std::ostream &output) const
 Write help info to output. More...
 
std::string shorthelp () const
 Get short (one-line) documentation. More...
 
ptr thisptr ()
 Get smart pointer to node. More...
 
cptr thisptr () const
 Get smart pointer to node (const) More...
 
bool isChildOf (DirectoryNode &parent) const
 true, if node is a child of parent More...
 
bool operator== (GenericNode &other) const
 true, if this and other are the same node More...
 
bool operator!= (GenericNode &other) const
 true, if this and other are different nodes More...
 
bool isDirectory () const
 true, if this is a directory node More...
 
bool isLink () const
 true, if this is a link node More...
 
bool isCommand () const
 true, if this is a command node More...
 
GenericNode const & followLink () const
 Follow link if this node is a link node. More...
 
GenericNodefollowLink ()
 Follow link if this node is a link node. More...
 
virtual void v_help (std::ostream &output) const =0
 Provide help information. More...
 
virtual std::string v_shorthelp () const =0
 Provide short documentation. More...
 

Protected Member Functions

 GenericNode ()
 
void name (std::string const &name)
 

Detailed Description

Config/console node tree base-class.

GenericNode is the base class of all node objects. There are two basic node types derived from GenericNode: DirectoryNode and CommandNode.

All nodes are dynamically allocated and automatically managed using reference counting.

All nodes are normally linked into a single tree which root node is senf::console::root(). Nodes may however be orphaned (not linked to the tree) either directly (the node has no parent) or indirectly (the node has a parent but is part of an orphaned subtree which is not linked to the root node).

Every active (non-orphaned) node (except the root() node) has a non-empty node name. This name is assigned to the node when adding the node to the tree.

Definition at line 250 of file Node.hh.

Member Typedef Documentation

◆ cptr

typedef boost::shared_ptr<GenericNode const> senf::console::GenericNode::cptr

Definition at line 259 of file Node.hh.

◆ ptr

typedef boost::shared_ptr<GenericNode> senf::console::GenericNode::ptr

Definition at line 253 of file Node.hh.

◆ weak_ptr

Definition at line 260 of file Node.hh.

Constructor & Destructor Documentation

◆ ~GenericNode()

virtual senf::console::GenericNode::~GenericNode ( )
virtual

◆ GenericNode()

senf::console::GenericNode::GenericNode ( )
protected

Member Function Documentation

◆ active()

bool senf::console::GenericNode::active ( ) const

true, if node is attached to the root() node

Definition at line 99 of file Node.cc.

◆ followLink() [1/2]

GenericNode const& senf::console::GenericNode::followLink ( ) const

Follow link if this node is a link node.

◆ followLink() [2/2]

GenericNode& senf::console::GenericNode::followLink ( )

Follow link if this node is a link node.

◆ help()

void senf::console::GenericNode::help ( std::ostream &  output) const

Write help info to output.

◆ isChildOf()

bool senf::console::GenericNode::isChildOf ( DirectoryNode parent) const

true, if node is a child of parent

Will also return true, if parent is the current node.

Definition at line 108 of file Node.cc.

◆ isCommand()

bool senf::console::GenericNode::isCommand ( ) const

true, if this is a command node

◆ isDirectory()

bool senf::console::GenericNode::isDirectory ( ) const

true, if this is a directory node

◆ isLink()

bool senf::console::GenericNode::isLink ( ) const

true, if this is a link node

◆ name() [1/2]

std::string const& senf::console::GenericNode::name ( ) const

Node name.

◆ name() [2/2]

void senf::console::GenericNode::name ( std::string const &  name)
protected

◆ operator!=()

bool senf::console::GenericNode::operator!= ( GenericNode other) const

true, if this and other are different nodes

◆ operator==()

bool senf::console::GenericNode::operator== ( GenericNode other) const

true, if this and other are the same node

◆ parent()

boost::shared_ptr<DirectoryNode> senf::console::GenericNode::parent ( ) const

Parent node.

May be null, if the node is the root node or if it is not linked to the tree

◆ path() [1/2]

std::string senf::console::GenericNode::path ( ) const

Node path.

The node path is built by joining the names of all parent nodes with '/' chars.

Definition at line 70 of file Node.cc.

◆ path() [2/2]

std::string senf::console::GenericNode::path ( DirectoryNode const &  root) const

Node path up to root.

The node path is built by joining the names of all parent nodes up to root with '/' chars.

Definition at line 82 of file Node.cc.

◆ rename()

void senf::console::GenericNode::rename ( std::string const &  newName)

Rename node name in it's parent directory.

The renaming is done by unlinking the node from the parent and re-adding it with the new name. If the node is not linked to the tree, that is parent() returns null, this is a no-op.

Definition at line 117 of file Node.cc.

◆ shorthelp()

std::string senf::console::GenericNode::shorthelp ( ) const

Get short (one-line) documentation.

◆ thisptr() [1/2]

ptr senf::console::GenericNode::thisptr ( )

Get smart pointer to node.

◆ thisptr() [2/2]

cptr senf::console::GenericNode::thisptr ( ) const

Get smart pointer to node (const)

◆ unlink()

ptr senf::console::GenericNode::unlink ( )

Remove node from it's parent directory.

You may either discard the return value and thereby dispose the node or may re-attach the node at some other place using DirectoryNode::add().

◆ v_help()

virtual void senf::console::GenericNode::v_help ( std::ostream &  output) const
pure virtual

Provide help information.

This member must be implemented in derived classes to provide node specific help information.

◆ v_shorthelp()

virtual std::string senf::console::GenericNode::v_shorthelp ( ) const
pure virtual

Provide short documentation.

This member must be implemented in derived classes to provide node specific documentation.


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