]> Creatis software - creaImageIO.git/blob - src2/creaImageIOTreeAttributeDescriptor.h
dc734bd62964469ef4d4600890d1366d5192866d
[creaImageIO.git] / src2 / creaImageIOTreeAttributeDescriptor.h
1 #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__
2 #define __creaImageIOTreeAttributeDescriptor_h_INCLUDED__
3
4 #include <string>
5 //#include <iostream>
6
7 namespace creaImageIO
8 {
9
10   namespace tree
11   {
12     //=====================================================================
13     /// Descriptor of an attribute of a node of a tree (name, dicom group/element)
14     class AttributeDescriptor
15     {    
16     public:
17       /// Flags
18       /// The attribute is hidden (not visible to user)
19       static const unsigned int HIDDEN;
20       /// The attribute enters in unique identifier constitution (KEY)
21       static const unsigned int KEY;
22       /// The attribute enters in label constitution (for printing)
23       static const unsigned int LABEL;
24
25       /// Default ctor
26       AttributeDescriptor()
27         : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0)
28       {
29       }
30       // Ctor with key, name and flags
31       AttributeDescriptor(const std::string& key,
32                           const std::string& name,
33                           unsigned int flags = 0);
34       // Ctor with dicom group, elem and flags
35       // The key is built as 'Dgroup_elem'
36       // The user name is retreived from dicom dictionnary
37       AttributeDescriptor(unsigned short group,
38                           unsigned short element,
39                           unsigned int flags = 0);
40       /// Returns the key of the attribute
41       const std::string& GetKey() const { return mKey; }
42       /// Returns the name of the attribute
43       const std::string& GetName() const { return mName; }
44       /// Returns the DICOM group code of the attribute
45       unsigned short GetGroup() const { return mGroup; }
46       /// Returns the DICOM element code of the attribute
47       unsigned short GetElement() const { return mElement; }
48       /// Returns the flags of the attribute
49       unsigned int GetFlags() const { return mFlags; }
50     
51       /// Extracts group and element from a key of the form "Dgroup_elem" 
52       static void GetDicomGroupElementFromKey(const std::string& key,
53                                               unsigned short& group,
54                                               unsigned short& elem);
55       /// Cleans the name:
56       /// Replace simple quote by double quotes
57       /// Cut string at NULL chars 
58       void CleanName(std::string& str) const;
59     private:
60       std::string mKey;
61       std::string mName;
62       unsigned short mGroup;
63       unsigned short mElement;
64       unsigned int mFlags;
65     };
66     // EO class AttributeDescriptor
67     //=====================================================================
68
69    
70
71   } // EO namespace tree
72
73 } // EO namespace creaImageIO
74
75
76 /*
77 //=====================================================================
78 inline std::ostream& operator<<(std::ostream& s, 
79 const creaImageIO::tree::AttributeDescriptor& d)
80 {
81 s << "[" << d.key << ":" << d.name << "]";
82 return s;
83 }
84 //=====================================================================
85 */
86
87
88 #endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__