]> Creatis software - creaImageIO.git/blob - src/creaImageIOTreeAttributeDescriptor.h
b83afd1b2f1fa22dfe323e83f6cf5a1b2f6bbcf3
[creaImageIO.git] / src / creaImageIOTreeAttributeDescriptor.h
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and 
11 #  abiding by the rules of distribution of free software. You can  use, 
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13 #  license as circulated by CEA, CNRS and INRIA at the following URL 
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability. 
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27
28 #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__
29 #define __creaImageIOTreeAttributeDescriptor_h_INCLUDED__
30
31 #include <string>
32 //#include <iostream>
33
34 namespace creaImageIO
35 {
36
37   namespace tree
38   {
39           /**
40         * \ingroup Tree
41         */
42     //=====================================================================
43     /// Descriptor of an attribute of a node of a Tree (name, dicom group/element)
44     class AttributeDescriptor
45     {    
46     public:
47       /// Flags
48       /// The attribute is hidden (not visible to user)
49       static const unsigned int PRIVATE;
50       /// The attribute enters in unique identifier constitution 
51       static const unsigned int IDENTIFIER;
52       /// The attribute enters in label constitution (for printing)
53       static const unsigned int LABEL;
54            /// The attribute can be edited
55       static const unsigned int EDITABLE;
56
57           /// Types
58       /// The attribute is of numeric type
59       static const int NUMBER=1;
60       /// The attribute is of string type
61       static const int STRING=2;
62           /// The attribute's type is unknown
63       static const int UNKNOWN=0;
64
65       /// Default ctor
66       AttributeDescriptor()
67         : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0)
68       {
69       }
70       /// Ctor with all explicitely
71       AttributeDescriptor(const std::string& key,
72                           const std::string& name,
73                           unsigned short group,
74                           unsigned short element,
75                           unsigned int flags)
76         : mKey(key), mName(name), mGroup(group), mElement(element), 
77           mFlags(flags)
78       {
79       }
80
81       // Ctor with key, name and flags
82       AttributeDescriptor(const std::string& key,
83                           const std::string& name,
84                           unsigned int flags = 0);
85       // Ctor with dicom group, elem and flags
86       // The key is built as 'Dgroup_elem'
87       // The user name is retreived from dicom dictionnary
88       AttributeDescriptor(unsigned short group,
89                           unsigned short element,
90                           unsigned int flags = 0);
91       /// Returns the key of the attribute
92       const std::string& GetKey() const { return mKey; }
93       /// Returns the name of the attribute
94       const std::string& GetName() const { return mName; }
95       /// Returns the DICOM group code of the attribute
96       unsigned short GetGroup() const { return mGroup; }
97       /// Returns the DICOM element code of the attribute
98       unsigned short GetElement() const { return mElement; }
99       /// Returns the flags of the attribute
100       unsigned int GetFlags() const { return mFlags; }
101           
102       /// Extracts group and element from a key of the form "Dgroup_elem" 
103       static void GetDicomGroupElementFromKey(const std::string& key,
104                                               unsigned short& group,
105                                               unsigned short& elem);
106       /// Cleans the name:
107       /// Replace simple quote by double quotes
108       /// Cut string at NULL chars 
109       void CleanName(std::string& str) const;
110           ///Decodes the type of attribute into the existing ones
111           void DecodeType(unsigned int& type) const;
112
113           /// Determines if Attribute is a date
114           bool isDateEntry() const;
115
116           /// Determines if Attribute is a time
117           bool isTimeEntry() const;
118
119     private:
120       std::string mKey;
121       std::string mName;
122       unsigned short mGroup;
123       unsigned short mElement;
124       unsigned int mFlags;
125     };
126     // EO class AttributeDescriptor
127     //=====================================================================
128
129    
130
131   } // EO namespace tree
132
133 } // EO namespace creaImageIO
134
135
136
137
138
139 #endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__