]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
* Fix compilation warnings
[gdcm.git] / src / gdcmDictEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/11/30 08:48:17 $
7   Version:   $Revision: 1.59 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDictEntry.h"
20 #include "gdcmDebug.h"
21 #include "gdcmUtil.h"
22
23 #include <iomanip> // for std::ios::left, ...
24 #include <fstream>
25 #include <stdio.h> // for sprintf
26
27 namespace gdcm 
28 {
29 //-----------------------------------------------------------------------------
30 // Constructor / Destructor
31 /**
32  * \brief   Constructor
33  * @param   group      DICOM-Group Number
34  * @param   elem       DICOM-Element Number
35  * @param   vr         Value Representation
36  * @param   vm         Value Multiplicity 
37  * @param   name       description of the element
38 */
39 DictEntry::DictEntry(uint16_t group, uint16_t elem,
40                      VRKey const &vr, 
41                      TagName const &vm,
42                      TagName const &name)
43
44 {
45    Tag.SetGroup(group);
46    Tag.SetElement(elem);
47    VR      = vr;
48    VM      = vm;
49    Name    = name;
50 }
51
52 /**
53  * \brief   Destructor
54  */
55 DictEntry::~DictEntry()
56 {
57 }
58 //-----------------------------------------------------------------------------
59 // Public
60 /**
61  * \brief Class allocator
62  * @param   group      DICOM-Group Number
63  * @param   elem       DICOM-Element Number
64  * @param   vr         Value Representation
65  * @param   vm         Value Multiplicity 
66  * @param   name       description of the element
67 */
68 DictEntry *DictEntry::New(uint16_t group, uint16_t elem,
69                           VRKey const &vr,
70                           TagName const &vm,
71                           TagName const &name)
72 {
73    return new DictEntry(group,elem,vr,vm,name);
74 }
75
76 /**
77  * \brief   concatenates 2 uint16_t (supposed to be a Dicom group number 
78  *                                              and a Dicom element number)
79  * @param  group the Dicom group number used to build the tag
80  * @param  elem the Dicom element number used to build the tag
81  * @return the built tag
82  */
83 TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
84 {
85    // according to 'Purify', TranslateToKey is one of the most
86    // time consuming methods.
87    // Let's try to shorten it !
88    return TagKey(group,elem);
89 }
90
91 //-----------------------------------------------------------------------------
92 // Protected
93
94 //-----------------------------------------------------------------------------
95 // Private
96
97 //-----------------------------------------------------------------------------
98 // Print
99 /**
100  * \brief   Prints an entry of the Dicom DictionaryEntry
101  * @param   os ostream we want to print in
102  * @param indent Indentation string to be prepended during printing
103  */
104 void DictEntry::Print(std::ostream &os, std::string const & )
105 {
106    os << GetKey(); 
107    os << " [" << VR  << "] ";
108
109    std::ostringstream s;
110
111    if ( PrintLevel >= 1 )
112    {
113       s.setf(std::ios::left);
114       s << std::setw(66-GetName().length()) << " ";
115    }
116
117    s << "[" << GetName()<< "]";
118    os << s.str() << std::endl;
119 }
120
121 //-----------------------------------------------------------------------------
122 } // end namespace gdcm
123