]> Creatis software - creaImageIO.git/blob - src/creaImageIOTreeAttributeDescriptor.h
#3185 creaImageIO Feature New Normal - Clean code
[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 <creaImageIOSystem.h>
32 #include <string>
33 //#include <iostream>
34
35 namespace creaImageIO
36 {
37
38   namespace tree
39   {
40           /**
41         * \ingroup Tree
42         */
43     //=====================================================================
44     /// Descriptor of an attribute of a node of a Tree (name, dicom group/element)
45     class AttributeDescriptor
46     {    
47     public:
48       /// Flags
49       /// The attribute is hidden (not visible to user)
50       static const unsigned int PRIVATE;
51       /// The attribute enters in unique identifier constitution 
52       static const unsigned int IDENTIFIER;
53       /// The attribute enters in label constitution (for printing)
54       static const unsigned int LABEL;
55            /// The attribute can be edited
56       static const unsigned int EDITABLE;
57
58           /// Types
59       /// The attribute is of numeric type
60       static const int NUMBER=1;
61       /// The attribute is of string type
62       static const int STRING=2;
63           /// The attribute's type is unknown
64       static const int UNKNOWN=0;
65
66       /// Default ctor
67       AttributeDescriptor()
68         : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0)
69       {
70       }
71       /// Ctor with all explicitely
72       AttributeDescriptor(const std::string& key,
73                           const std::string& name,
74                           unsigned short group,
75                           unsigned short element,
76                           unsigned int flags)
77         : mKey(key), mName(name), mGroup(group), mElement(element), 
78           mFlags(flags)
79       {
80       }
81
82       // Ctor with key, name and flags
83       AttributeDescriptor(const std::string& key,
84                           const std::string& name,
85                           unsigned int flags = 0);
86       // Ctor with dicom group, elem and flags
87       // The key is built as 'Dgroup_elem'
88       // The user name is retreived from dicom dictionnary
89       AttributeDescriptor(unsigned short group,
90                           unsigned short element,
91                           unsigned int flags = 0);
92       /// Returns the key of the attribute
93       const std::string& GetKey() const { return mKey; }
94       /// Returns the name of the attribute
95       const std::string& GetName() const { return mName; }
96       /// Returns the DICOM group code of the attribute
97       unsigned short GetGroup() const { return mGroup; }
98       /// Returns the DICOM element code of the attribute
99       unsigned short GetElement() const { return mElement; }
100       /// Returns the flags of the attribute
101       unsigned int GetFlags() const { return mFlags; }
102           
103       /// Extracts group and element from a key of the form "Dgroup_elem" 
104       static void GetDicomGroupElementFromKey(const std::string& key,
105                                               unsigned short& group,
106                                               unsigned short& elem);
107       /// Cleans the name:
108       /// Replace simple quote by double quotes
109       /// Cut string at NULL chars 
110       void CleanName(std::string& str) const;
111           ///Decodes the type of attribute into the existing ones
112           void DecodeType(unsigned int& type) const;
113
114           /// Determines if Attribute is a date
115           bool isDateEntry() const;
116
117           /// Determines if Attribute is a time
118           bool isTimeEntry() const;
119
120     private:
121       std::string mKey;
122       std::string mName;
123       unsigned short mGroup;
124       unsigned short mElement;
125       unsigned int mFlags;
126     };
127     // EO class AttributeDescriptor
128     //=====================================================================
129
130    
131
132   } // EO namespace tree
133
134 } // EO namespace creaImageIO
135
136
137
138
139
140 #endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__