]> Creatis software - creaImageIO.git/blob - src2/creaImageIOTree.h
854693d3409ab2e6f08c2d7db7a5f02d31518149
[creaImageIO.git] / src2 / creaImageIOTree.h
1 #ifndef __creaImageIOTree_h_INCLUDED__
2 #define __creaImageIOTree_h_INCLUDED__
3
4 #include <creaImageIOTreeNode.h>
5
6 namespace creaImageIO
7 {
8
9   namespace tree
10   {
11     
12     //=====================================================================
13     /// Abstract class to store user data on a tree
14     struct TreeData
15     { 
16       TreeData() {}
17       virtual ~TreeData() {}
18     };
19     //=====================================================================
20     
21     //=====================================================================
22     /// An attributed tree structure
23     class Tree : public Node
24     {
25     public:
26       /// Ctor
27       Tree();
28       /// Virtual destructor
29       virtual ~Tree();
30       
31       /// Returns the descriptor of the tree
32     
33       /// Returns the tree to which the node belongs
34       virtual Tree* GetTree() { return this; }
35       /// Returns the tree to which the node belongs
36       virtual const Tree* GetTree() const { return this; }
37       /// Returns the level of the node in the tree
38       virtual int GetLevel() const { return 0; }
39       
40       /// Returns the Descriptor of the tree (const)
41       const Descriptor& GetDescriptor() const { return mDescriptor; }
42       /// Returns the descriptor of the tree 
43       Descriptor& GetDescriptor() { return mDescriptor; }
44
45      /// Returns the number of levels of the tree
46       unsigned int GetNumberOfLevels() 
47       { return GetDescriptor().GetNumberOfLevels(); }
48
49     /// Returns the LevelDescriptor of a given level (const ref)
50       const LevelDescriptor& GetLevelDescriptor(int level) const
51       { return GetDescriptor().GetLevelDescriptor(level); }
52       /// Returns the LevelDescriptor of a given level (ref)
53       LevelDescriptor& GetLevelDescriptor(int level) 
54       { return GetDescriptor().GetLevelDescriptor(level); }
55
56       /// Returns the AttributeDescriptorList of a given level (const ref)
57       const LevelDescriptor::AttributeDescriptorListType& 
58       GetAttributeDescriptorList(int level) const
59       { return GetDescriptor().GetAttributeDescriptorList(level); }
60       /// Returns the AttributeDescriptorList of a given level (ref)
61       LevelDescriptor::AttributeDescriptorListType& 
62       GetAttributeDescriptorList(int level) 
63       { return GetDescriptor().GetAttributeDescriptorList(level); }
64   
65
66     private:
67       Descriptor mDescriptor;
68
69     };
70     // EO class Tree
71     //=====================================================================
72
73   } // EO namespace tree
74   
75 } // EO namespace creaImageIO
76
77 // EOF
78 #endif