]> Creatis software - creaImageIO.git/blob - src/creaImageIOTree.h
c7b65b4014630e27eb38e524b9171cf9426bfd61
[creaImageIO.git] / src / 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      * \ingroup Tree
13      */
14     //=====================================================================
15     /// Abstract class to store user data on a Tree
16     struct TreeData
17     { 
18       TreeData() {}
19       virtual ~TreeData() {}
20     };
21     //=====================================================================
22     
23     //=====================================================================
24     /// An attributed Tree structure
25     /** \ingroup Tree
26      */
27     class Tree : public Node
28     {
29     public:
30       /// Ctor
31       Tree();
32       /// Virtual destructor
33       virtual ~Tree();
34       
35       /// Returns the descriptor of the tree
36     
37       /// Returns the tree to which the node belongs
38       virtual Tree* GetTree() { return this; }
39       /// Returns the tree to which the node belongs
40       virtual const Tree* GetTree() const { return this; }
41       /// Returns the level of the node in the tree
42       virtual int GetLevel() const { return 0; }
43       
44       /// Returns the Descriptor of the tree (const)
45       const Descriptor& GetDescriptor() const { return mDescriptor; }
46       /// Returns the descriptor of the tree 
47       Descriptor& GetDescriptor() { return mDescriptor; }
48
49      /// Returns the number of levels of the tree
50       unsigned int GetNumberOfLevels() 
51       { return GetDescriptor().GetNumberOfLevels(); }
52
53       /// Returns the LevelDescriptor of a given level (const ref)
54       const LevelDescriptor& GetLevelDescriptor(int level) const
55       { return GetDescriptor().GetLevelDescriptor(level); }
56
57       /// Returns the AttributeDescriptorList of a given level (const ref)
58           /// type = 0 all attributes
59           /// type = 1 without ID and PATIENT_ID
60       const LevelDescriptor::AttributeDescriptorListType& 
61       GetAttributeDescriptorList(int level, int type = 0) const
62       { return GetDescriptor().GetAttributeDescriptorList(level, type); }
63   
64       virtual void Print() const;
65
66
67           /// Copy descriptor list without ID tag
68           void CopyAttributeDescriptorList(int level)
69           {
70                   GetDescriptor().CopyAttributeDescriptorList(level);
71           }
72           
73           /// Test if this attribute is available in this tree description
74           const std::string isAttributeExist(const std::string i_attr)
75           {
76                   return mDescriptor.isExist(i_attr);
77           }
78
79     private:
80       Descriptor mDescriptor;
81
82     };
83     // EO class Tree
84     //=====================================================================
85
86   } // EO namespace tree
87   
88 } // EO namespace creaImageIO
89
90 // EOF
91 #endif