]> Creatis software - creaImageIO.git/blob - src/creaImageIOTreeAttributeDescriptor.h
1ae86ddeb89c94381cc240dbf589a31c6d33abf6
[creaImageIO.git] / src / 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 Tree
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 
24       static const unsigned int IDENTIFIER;
25       /// The attribute enters in label constitution (for printing)
26       static const unsigned int LABEL;
27            /// The attribute can be edited
28       static const unsigned int EDITABLE;
29
30           /// Types
31       /// The attribute is of numeric type
32       static const int NUMBER=1;
33       /// The attribute is of string type
34       static const int STRING=2;
35           /// The attribute's type is unknown
36       static const int UNKNOWN=0;
37
38       /// Default ctor
39       AttributeDescriptor()
40         : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0)
41       {
42       }
43       /// Ctor with all explicitely
44       AttributeDescriptor(const std::string& key,
45                           const std::string& name,
46                           unsigned short group,
47                           unsigned short element,
48                           unsigned int flags)
49         : mKey(key), mName(name), mGroup(group), mElement(element), 
50           mFlags(flags)
51       {
52       }
53
54       // Ctor with key, name and flags
55       AttributeDescriptor(const std::string& key,
56                           const std::string& name,
57                           unsigned int flags = 0);
58       // Ctor with dicom group, elem and flags
59       // The key is built as 'Dgroup_elem'
60       // The user name is retreived from dicom dictionnary
61       AttributeDescriptor(unsigned short group,
62                           unsigned short element,
63                           unsigned int flags = 0);
64       /// Returns the key of the attribute
65       const std::string& GetKey() const { return mKey; }
66       /// Returns the name of the attribute
67       const std::string& GetName() const { return mName; }
68       /// Returns the DICOM group code of the attribute
69       unsigned short GetGroup() const { return mGroup; }
70       /// Returns the DICOM element code of the attribute
71       unsigned short GetElement() const { return mElement; }
72       /// Returns the flags of the attribute
73       unsigned int GetFlags() const { return mFlags; }
74           
75       /// Extracts group and element from a key of the form "Dgroup_elem" 
76       static void GetDicomGroupElementFromKey(const std::string& key,
77                                               unsigned short& group,
78                                               unsigned short& elem);
79       /// Cleans the name:
80       /// Replace simple quote by double quotes
81       /// Cut string at NULL chars 
82       void CleanName(std::string& str) const;
83           ///Decodes the type of attribute into the existing ones
84           void DecodeType(unsigned int& type) const;
85
86           /// Determines if Attribute is a date
87           bool isDateEntry() const;
88
89           /// Determines if Attribute is a time
90           bool isTimeEntry() const;
91
92     private:
93       std::string mKey;
94       std::string mName;
95       unsigned short mGroup;
96       unsigned short mElement;
97       unsigned int mFlags;
98     };
99     // EO class AttributeDescriptor
100     //=====================================================================
101
102    
103
104   } // EO namespace tree
105
106 } // EO namespace creaImageIO
107
108
109
110
111
112 #endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__