]> Creatis software - creaImageIO.git/blob - src2/creaImageIOTreeDescriptor.h
765b73f1ae61cc8e03a4c43ac1e07c4b847720af
[creaImageIO.git] / src2 / creaImageIOTreeDescriptor.h
1 #ifndef __creaImageIOTreeDescriptor_h_INCLUDED__
2 #define __creaImageIOTreeDescriptor_h_INCLUDED__
3
4 #include <creaImageIOTreeAttributeMapType.h>
5 #include <creaImageIOTreeLevelDescriptor.h>
6
7
8 namespace creaImageIO
9 {
10
11   namespace tree
12   {
13     
14     /**
15      * \ingroup Tree
16      */
17     
18         ///Descriptor of the structure of a Tree (number of levels, descriptors of each level, ...). 
19           //Any Tree has at least one level (level 0) of name "Root"
20      
21     class Descriptor
22     {
23     public:
24       /// Ctor : creates the mandatory level 0 descriptor called "Root"
25       Descriptor();
26       /// Destructor
27       ~Descriptor();
28
29       /// Loads from a xml description file
30       void LoadXML(const std::string& filename);
31       /// Creates the default descriptor
32       void CreateDefault();
33
34       /// Returns the number of levels of the tree
35       unsigned int GetNumberOfLevels() 
36       { return mLevelDescriptorList.size(); }
37
38       /// Returns the LevelDescriptor of a given level (const ref)
39       const LevelDescriptor& GetLevelDescriptor(int level) const
40       { return mLevelDescriptorList[level]; }
41       /// Returns the LevelDescriptor of a given level (ref)
42       LevelDescriptor& GetLevelDescriptor(int level) 
43       { return mLevelDescriptorList[level]; }
44
45       /// Returns the AttributeDescriptorList of a given level (const ref)
46       const LevelDescriptor::AttributeDescriptorListType& 
47       GetAttributeDescriptorList(int level) const
48       { return mLevelDescriptorList[level].GetAttributeDescriptorList(); }
49       /// Returns the AttributeDescriptorList of a given level (ref)
50       //LevelDescriptor::AttributeDescriptorListType& 
51       //GetAttributeDescriptorList(int level) 
52       //{ return mLevelDescriptorList[level].GetAttributeDescriptorList(); }
53   
54
55       /// Builds the key to value map of all the attributes of the tree
56       void BuildAttributeMap( AttributeMapType& ) const;
57
58       /// The type of LevelDescriptor container
59       typedef std::vector<LevelDescriptor> LevelDescriptorListType;
60       /// Returns the list of LevelDescriptor
61       LevelDescriptorListType& GetLevelDescriptorList() { return mLevelDescriptorList; }
62       /// Returns the list of tree levels (const)
63       const LevelDescriptorListType& GetLevelDescriptorList() const { return mLevelDescriptorList; }
64
65     private:
66       LevelDescriptorListType mLevelDescriptorList;
67       /// Creates the mandatory level 0 descriptor called "Root"
68       /// (assumes the list is empty)
69       void CreateLevel0Descriptor();
70   
71     };
72     // EO class Descriptor
73     //=====================================================================
74   } // EO namespace tree
75
76 } // EO namespace creaImageIO
77
78 // EOF
79 #endif