#include <CeylanTree.h>
Public Types | |
typedef std::list< Tree < Content > * > | SubTreeList |
Shortcut for the list of sons of a Tree. | |
Public Member Functions | |
Tree () | |
Constructs a tree made only from a node root, with an empty local content. | |
Tree (Content &content) | |
Constructs a tree made only from a node root, whose local content is provided. | |
virtual | ~Tree () throw () |
Virtual destructor, deletes all tree, including the subtrees and their content. | |
virtual void | accept (Visitor &visitor) |
Allows given visitor to visit this object, thanks to a callback: 'visitor.visit( *this ) ;'. | |
virtual bool | hasContent () const |
Tells whether this tree node (i.e. | |
virtual Content & | getContent () |
Returns the content that this root node of the tree owns. | |
virtual const Content & | getContentAsConst () const |
Returns the content that this root node of the tree owns, as a const reference. | |
virtual void | setContent (Content &newContent) |
Sets a new content for this root node of the tree. | |
virtual const SubTreeList & | getSons () const |
Returns the list of sons (subtrees) of this tree. | |
virtual Tree * | getFather (Tree &child) |
Returns the father of the specified node, which is searched in specified tree. | |
virtual void | addSon (Tree &subtree) |
Adds specified son to the list of sons of this tree. | |
virtual void | traverseDepthFirst (TreeVisitor< Content > &treeVisitor, bool visitContent=true) |
Traverses this tree depth-first, and applies specified processing to each node being selected on this path, in the path order. | |
virtual void | traverseBreadthFirst (TreeVisitor< Content > &treeVisitor, bool visitContent=true) |
Traverses this tree breadth-first, and applies specified processing to each node being selected on this path, in the path order. | |
virtual void | appendSonsContents (std::list< Content * > &toBeAugmented) |
Adds in specified list the content of all direct child nodes. | |
virtual Tree * | getNodeOf (const Content &content) |
Returns the tree node that references specified content, if any. | |
virtual Content * | getFatherContent (const Content &content) |
Returns the content associated with the father node of the node associated with specified content. | |
virtual void | appendSonsContentsOf (const Content &content, std::list< Content * > &toBeAugmented) |
Adds in specified list the content of all direct child nodes. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns a user-friendly description of the state of this object. | |
Protected Attributes | |
Content * | _content |
The content carried by this tree node. | |
SubTreeList | _sons |
The sons, direct subtrees of this tree. | |
Private Member Functions | |
Tree (const Tree &source) | |
Copy constructor made private to ensure that it will never be called. | |
Tree & | operator= (const Tree &source) |
Assignment operator made private to ensure that it will never be called. |
Definition at line 280 of file CeylanTree.h.
typedef std::list< Tree<Content>* > Ceylan::Tree< Content >::SubTreeList |
Ceylan::Tree< Content >::Tree | ( | ) | [inline, explicit] |
Constructs a tree made only from a node root, with an empty local content.
Definition at line 645 of file CeylanTree.h.
Ceylan::Tree< Content >::Tree | ( | Content & | content | ) | [inline, explicit] |
Constructs a tree made only from a node root, whose local content is provided.
content | the local content of this node. |
Definition at line 655 of file CeylanTree.h.
Ceylan::Tree< Content >::~Tree | ( | ) | throw () [inline, virtual] |
Virtual destructor, deletes all tree, including the subtrees and their content.
Definition at line 665 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, and Ceylan::Tree< Content >::_sons.
Ceylan::Tree< Content >::Tree | ( | const Tree< Content > & | source | ) | [private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void Ceylan::Tree< Content >::accept | ( | Visitor & | visitor | ) | [inline, virtual] |
Allows given visitor to visit this object, thanks to a callback: 'visitor.visit( *this ) ;'.
Implements the Visitable interface.
VisitException | if the operation failed, including if the specified visitor is no a tree height-aware visitor. |
Implements Ceylan::Visitable.
Definition at line 729 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, Ceylan::Tree< Content >::_sons, Ceylan::TreeHeightAwareVisitor< Content >::decrementHeight(), Ceylan::TreeHeightAwareVisitor< Content >::incrementHeight(), and Ceylan::Visitor::toString().
Referenced by Ceylan::XML::XMLParser::saveToFile().
void Ceylan::Tree< Content >::addSon | ( | Tree< Content > & | subtree | ) | [inline, virtual] |
Adds specified son to the list of sons of this tree.
TreeException | if the operation failed, included if the subtree was already registered. |
Definition at line 843 of file CeylanTree.h.
References Ceylan::Tree< Content >::_sons, and Ceylan::Tree< Content >::toString().
Referenced by Ceylan::XML::XMLParser::handleNextElement().
void Ceylan::Tree< Content >::appendSonsContents | ( | std::list< Content * > & | toBeAugmented | ) | [inline, virtual] |
Adds in specified list the content of all direct child nodes.
toBeAugmented | the list to which contents will be added. |
Definition at line 900 of file CeylanTree.h.
References Ceylan::Tree< Content >::_sons.
Referenced by Ceylan::Tree< Content >::appendSonsContentsOf().
void Ceylan::Tree< Content >::appendSonsContentsOf | ( | const Content & | content, | |
std::list< Content * > & | toBeAugmented | |||
) | [inline, virtual] |
Adds in specified list the content of all direct child nodes.
content | the content whose sons will be searched for content to append. | |
toBeAugmented | the list to which contents will be added. |
Definition at line 976 of file CeylanTree.h.
References Ceylan::Tree< Content >::appendSonsContents(), and Ceylan::Tree< Content >::getNodeOf().
Content & Ceylan::Tree< Content >::getContent | ( | ) | [inline, virtual] |
Returns the content that this root node of the tree owns.
TreeException | if no content is registered in this node. |
Definition at line 802 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content.
const Content & Ceylan::Tree< Content >::getContentAsConst | ( | ) | const [inline, virtual] |
Returns the content that this root node of the tree owns, as a const reference.
TreeException | if no content is registered in this node. |
Definition at line 816 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content.
Tree< Content > * Ceylan::Tree< Content >::getFather | ( | Tree< Content > & | child | ) | [inline, virtual] |
Returns the father of the specified node, which is searched in specified tree.
child | the node whose father is searched in this tree. |
Definition at line 695 of file CeylanTree.h.
References Ceylan::Tree< Content >::_sons, and Ceylan::Tree< Content >::getFather().
Referenced by Ceylan::Tree< Content >::getFather(), and Ceylan::XML::XMLParser::handleNextElement().
Content * Ceylan::Tree< Content >::getFatherContent | ( | const Content & | content | ) | [inline, virtual] |
Returns the content associated with the father node of the node associated with specified content.
The ownership of any returned content is kept by the tree.
Definition at line 942 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, and Ceylan::Tree< Content >::_sons.
Tree< Content > * Ceylan::Tree< Content >::getNodeOf | ( | const Content & | content | ) | [inline, virtual] |
Returns the tree node that references specified content, if any.
content | the content associated with the searched node. |
Definition at line 919 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, Ceylan::Tree< Content >::_sons, and Ceylan::Tree< Content >::getNodeOf().
Referenced by Ceylan::Tree< Content >::appendSonsContentsOf(), and Ceylan::Tree< Content >::getNodeOf().
const std::list< Tree< Content > * > & Ceylan::Tree< Content >::getSons | ( | ) | const [inline, virtual] |
Returns the list of sons (subtrees) of this tree.
Definition at line 685 of file CeylanTree.h.
References Ceylan::Tree< Content >::_sons.
bool Ceylan::Tree< Content >::hasContent | ( | ) | const [inline, virtual] |
Tells whether this tree node (i.e.
the root of this tree) has a content.
Definition at line 792 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content.
Tree& Ceylan::Tree< Content >::operator= | ( | const Tree< Content > & | source | ) | [private] |
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
void Ceylan::Tree< Content >::setContent | ( | Content & | newContent | ) | [inline, virtual] |
Sets a new content for this root node of the tree.
TreeException | if the operation failed. |
Definition at line 830 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content.
const std::string Ceylan::Tree< Content >::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [inline, virtual] |
Returns a user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 994 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, Ceylan::Tree< Content >::_sons, and Ceylan::formatStringList().
Referenced by Ceylan::Tree< Content >::addSon(), Ceylan::XML::XMLParser::handleNextElement(), and Ceylan::XML::XMLParser::toString().
void Ceylan::Tree< Content >::traverseBreadthFirst | ( | TreeVisitor< Content > & | treeVisitor, | |
bool | visitContent = true | |||
) | [inline, virtual] |
Traverses this tree breadth-first, and applies specified processing to each node being selected on this path, in the path order.
treeVisitor | the actual tree visitor that will visit the tree. | |
visitContent | tells whether the visitor the tree nodes and their content, if true, or only the tree nodes, if false. |
TreeException | if the visit failed. |
Definition at line 880 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, Ceylan::Tree< Content >::_sons, and Ceylan::TreeVisitor< Content >::visit().
void Ceylan::Tree< Content >::traverseDepthFirst | ( | TreeVisitor< Content > & | treeVisitor, | |
bool | visitContent = true | |||
) | [inline, virtual] |
Traverses this tree depth-first, and applies specified processing to each node being selected on this path, in the path order.
treeVisitor | the actual tree visitor that will visit the tree. | |
visitContent | tells whether the visitor the tree nodes and their content, if true, or only the tree nodes, if false. |
TreeException | if the visit failed. |
Definition at line 860 of file CeylanTree.h.
References Ceylan::Tree< Content >::_content, Ceylan::Tree< Content >::_sons, and Ceylan::TreeVisitor< Content >::visit().
Content* Ceylan::Tree< Content >::_content [protected] |
The content carried by this tree node.
Definition at line 586 of file CeylanTree.h.
Referenced by Ceylan::Tree< Content >::accept(), Ceylan::Tree< Content >::getContent(), Ceylan::Tree< Content >::getContentAsConst(), Ceylan::Tree< Content >::getFatherContent(), Ceylan::Tree< Content >::getNodeOf(), Ceylan::Tree< Content >::hasContent(), Ceylan::Tree< Content >::setContent(), Ceylan::Tree< Content >::toString(), Ceylan::Tree< Content >::traverseBreadthFirst(), Ceylan::Tree< Content >::traverseDepthFirst(), and Ceylan::Tree< Content >::~Tree().
SubTreeList Ceylan::Tree< Content >::_sons [protected] |
The sons, direct subtrees of this tree.
Definition at line 603 of file CeylanTree.h.
Referenced by Ceylan::Tree< Content >::accept(), Ceylan::Tree< Content >::addSon(), Ceylan::Tree< Content >::appendSonsContents(), Ceylan::Tree< Content >::getFather(), Ceylan::Tree< Content >::getFatherContent(), Ceylan::Tree< Content >::getNodeOf(), Ceylan::Tree< Content >::getSons(), Ceylan::Tree< Content >::toString(), Ceylan::Tree< Content >::traverseBreadthFirst(), Ceylan::Tree< Content >::traverseDepthFirst(), and Ceylan::Tree< Content >::~Tree().