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