Cat
Hierarchy.h
Go to the documentation of this file.
1 // $Id: $
2 #ifndef INC_HIERARCHY_H
3 #define INC_HIERARCHY_H 1
4 
5 // Include files
6 #include <string>
7 #include <vector>
8 #include <list>
9 
10 #include "Object.h"
11 
19 class Hierarchy : public Object {
20 public:
22  Hierarchy( );
23  virtual ~Hierarchy( );
24 
25  // Hierarchy
26  void clear(); //< clear Hierarchy (recursive)
27  void setParent(Hierarchy *parent);
28  Hierarchy* parent( ) { return m_parent; } //< Get Hierarchy Parent
29  Hierarchy* parent ( std::string ); //< Get First Parent of a certain type
30  Hierarchy* origin () { return m_origin; } //< Get the origin of the tree
31 
32  virtual void addChild(Hierarchy* element); //< add a child to the element hierarchy
33  std::vector<Hierarchy*> children() { return m_children; } //< get list of child(ren)
34  Hierarchy* child(std::string); //< get child according to the path
35  Hierarchy* childTyped(std::string ); //< get child according to the typed path
36  unsigned long numberOfChildren(); //< get number of child(ren)
37  bool hasChildren(); //< has the object at least a child
38  // Hierarchy* child(Hierarchy*);
39  void delChild (Hierarchy*); //< remove child from the hierarchy
40  void delChild (std::string); //< remove child from the hierarchy according to its path
41 
42  std::string path ( std::string = std::string("") ); //< Get the path of the object
43  std::string pathTyped( std::string = std::string("") ); //< Get the typed path of the object
44 
45  void tree(std::string indent=std::string("")); // output tree of Hierarchy from object
46  void tree() { tree(""); }; // output tree of Hierarchy from object
47 
48 protected:
49 
50 private:
51  Hierarchy *m_parent; // parent of the object
52  Hierarchy *m_origin; // origin of the hierarchy tree
53  std::vector<Hierarchy*> m_children; //< list of Children
54 };
55 #endif // INC_HIERARCHY_H
Definition: Object.h:21
Hierarchy * childTyped(std::string)
Definition: Hierarchy.cpp:239
Hierarchy * child(std::string)
Definition: Hierarchy.cpp:133
Hierarchy()
Standard constructor.
Definition: Hierarchy.cpp:16
void setParent(Hierarchy *parent)
Definition: Hierarchy.cpp:67
Hierarchy * m_origin
Definition: Hierarchy.h:52
bool hasChildren()
Definition: Hierarchy.cpp:303
std::vector< Hierarchy * > children()
Definition: Hierarchy.h:33
void delChild(Hierarchy *)
Definition: Hierarchy.cpp:92
Hierarchy * parent()
Definition: Hierarchy.h:28
unsigned long numberOfChildren()
Definition: Hierarchy.cpp:125
std::vector< Hierarchy * > m_children
Definition: Hierarchy.h:53
virtual ~Hierarchy()
Destructor.
Definition: Hierarchy.cpp:24
void tree()
Definition: Hierarchy.h:46
virtual void addChild(Hierarchy *element)
Definition: Hierarchy.cpp:83
std::string pathTyped(std::string=std::string(""))
Definition: Hierarchy.cpp:356
Hierarchy * m_parent
Definition: Hierarchy.h:46
void clear()
Definition: Hierarchy.cpp:35
Hierarchy * origin()
Definition: Hierarchy.h:30
std::string path(std::string=std::string(""))
Definition: Hierarchy.cpp:344