]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
* Fix bug -- sorry
[gdcm.git] / src / gdcmDictEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/11/28 15:30:04 $
7   Version:   $Revision: 1.56 $
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    DicomEntry(group,elem,vr)
44 {
45    VM      = vm;
46    Name    = name;
47 }
48
49 //-----------------------------------------------------------------------------
50 // Public
51 /**
52  * \brief Class allocator
53  * @param   group      DICOM-Group Number
54  * @param   elem       DICOM-Element Number
55  * @param   vr         Value Representation
56  * @param   vm         Value Multiplicity 
57  * @param   name       description of the element
58 */
59 DictEntry *DictEntry::New(uint16_t group, uint16_t elem,
60                           VRKey const &vr,
61                           TagName const &vm,
62                           TagName const &name)
63 {
64    return new DictEntry(group,elem,vr,vm,name);
65 }
66
67 /**
68  * \brief       If-and only if-the V(alue) R(epresentation)
69  * \            is unset then overwrite it.
70  * @param vr    New V(alue) R(epresentation) to be set.
71  */
72 void DictEntry::SetVR(VRKey const &vr) 
73 {
74    gdcmAssertMacro( IsVRUnknown() );
75    DicomEntry::SetVR(vr);
76 }
77
78 /**
79  * \brief       If-and only if-the V(alue) M(ultiplicity)
80  * \            is unset then overwrite it.
81  * @param vm    New V(alue) M(ultiplicity) to be set.
82  */
83 void DictEntry::SetVM(TagName const &vm) 
84 {
85    gdcmAssertMacro( IsVMUnknown() );
86    VM = vm;
87 }
88
89 //-----------------------------------------------------------------------------
90 // Protected
91
92 //-----------------------------------------------------------------------------
93 // Private
94
95 //-----------------------------------------------------------------------------
96 // Print
97 /**
98  * \brief   Prints an entry of the Dicom DictionaryEntry
99  * @param   os ostream we want to print in
100  * @param indent Indentation string to be prepended during printing
101  */
102 void DictEntry::Print(std::ostream &os, std::string const &indent )
103 {
104    DicomEntry::Print(os,indent);
105
106    std::ostringstream s;
107
108    if ( PrintLevel >= 1 )
109    {
110       s.setf(std::ios::left);
111       s << std::setw(66-GetName().length()) << " ";
112    }
113
114    s << "[" << GetName()<< "]";
115    os << s.str() << std::endl;
116 }
117
118 //-----------------------------------------------------------------------------
119 } // end namespace gdcm
120