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