]> Creatis software - creaImageIO.git/blob - src2/creaImageIOTreeAttributeDescriptor.h
*** empty log message ***
[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 PRIVATE;
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 all explicitely
31       AttributeDescriptor(const std::string& key,
32                           const std::string& name,
33                           unsigned short group,
34                           unsigned short element,
35                           unsigned int flags)
36         : mKey(key), mName(name), mGroup(group), mElement(element), 
37           mFlags(flags)
38       {
39       }
40
41       // Ctor with key, name and flags
42       AttributeDescriptor(const std::string& key,
43                           const std::string& name,
44                           unsigned int flags = 0);
45       // Ctor with dicom group, elem and flags
46       // The key is built as 'Dgroup_elem'
47       // The user name is retreived from dicom dictionnary
48       AttributeDescriptor(unsigned short group,
49                           unsigned short element,
50                           unsigned int flags = 0);
51       /// Returns the key of the attribute
52       const std::string& GetKey() const { return mKey; }
53       /// Returns the name of the attribute
54       const std::string& GetName() const { return mName; }
55       /// Returns the DICOM group code of the attribute
56       unsigned short GetGroup() const { return mGroup; }
57       /// Returns the DICOM element code of the attribute
58       unsigned short GetElement() const { return mElement; }
59       /// Returns the flags of the attribute
60       unsigned int GetFlags() const { return mFlags; }
61     
62       /// Extracts group and element from a key of the form "Dgroup_elem" 
63       static void GetDicomGroupElementFromKey(const std::string& key,
64                                               unsigned short& group,
65                                               unsigned short& elem);
66       /// Cleans the name:
67       /// Replace simple quote by double quotes
68       /// Cut string at NULL chars 
69       void CleanName(std::string& str) const;
70     private:
71       std::string mKey;
72       std::string mName;
73       unsigned short mGroup;
74       unsigned short mElement;
75       unsigned int mFlags;
76     };
77     // EO class AttributeDescriptor
78     //=====================================================================
79
80    
81
82   } // EO namespace tree
83
84 } // EO namespace creaImageIO
85
86
87 /*
88 //=====================================================================
89 inline std::ostream& operator<<(std::ostream& s, 
90 const creaImageIO::tree::AttributeDescriptor& d)
91 {
92 s << "[" << d.key << ":" << d.name << "]";
93 return s;
94 }
95 //=====================================================================
96 */
97
98
99 #endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__