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