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