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