// PathTree.cpp #include "PathTree.h" #include "trfutil/STLprint.h" using std::ostream; using trf::Path; using trf::PathPtr; using trf::PathTree; //********************************************************************** // Local functions. //********************************************************************** namespace { // Append the descendant of ppath to tree. void append_children(PathTree& tree, const PathPtr& ppath) { const Path::PathList& children = ppath->get_children(); for ( Path::PathList::const_iterator ippath=children.begin(); ippath!=children.end(); ++ippath ) { tree.push_back(*ippath); append_children(tree,*ippath); } } } // end unnamed namespace //********************************************************************** // Member functions. //********************************************************************** // Constructor. PathTree::PathTree(const PathPtr& ppath) { this->push_back(ppath); append_children(*this,ppath); } //********************************************************************** // Free functions //********************************************************************** // Output stream. ostream& operator<<(ostream& stream, const PathTree& rhs) { print_ptr_list("Path tree", rhs, stream); return stream; } //**********************************************************************