1 /*=========================================================================
4 Module: $RCSfile: gdcmDictEntry.cxx,v $
6 Date: $Date: 2005/01/14 11:28:30 $
7 Version: $Revision: 1.40 $
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.
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.
17 =========================================================================*/
19 #include "gdcmDictEntry.h"
20 #include "gdcmDebug.h"
23 #include <iomanip> // for std::ios::left, ...
29 //-----------------------------------------------------------------------------
30 // Constructor / Destructor
33 * @param group DICOM-Group Number
34 * @param element DICOM-Element Number
35 * @param vr Value Representation
36 * @param vm Value Mutlplicity
37 * @param name description of the element
40 DictEntry::DictEntry(uint16_t group, uint16_t element,
50 Key = TranslateToKey(group, element);
53 //-----------------------------------------------------------------------------
55 void DictEntry::Print(std::ostream &os)
64 s << DictEntry::TranslateToKey(GetGroup(),GetElement());
65 s << " [" << vr << "] ";
69 s.setf(std::ios::left);
70 s << std::setw(66-GetName().length()) << " ";
73 s << "[" << GetName()<< "]";
74 os << s.str() << std::endl;
77 //-----------------------------------------------------------------------------
80 * \brief concatenates 2 uint16_t (supposed to be a Dicom group number
81 * and a Dicom element number)
82 * @param group the Dicom group number used to build the tag
83 * @param element the Dicom element number used to build the tag
84 * @return the built tag
86 TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t element)
88 return Util::Format("%04x|%04x", group, element);
91 //-----------------------------------------------------------------------------
93 * \brief If-and only if-the V(alue) R(epresentation)
94 * \ is unset then overwrite it.
95 * @param vr New V(alue) R(epresentation) to be set.
97 void DictEntry::SetVR(TagName const &vr)
105 gdcmErrorMacro( "Overwriting VR might compromise a dictionary");
109 //-----------------------------------------------------------------------------
111 * \brief If-and only if-the V(alue) M(ultiplicity)
112 * \ is unset then overwrite it.
113 * @param vm New V(alue) M(ultiplicity) to be set.
115 void DictEntry::SetVM(TagName const &vm)
123 gdcmErrorMacro( "Overwriting VM might compromise a dictionary");
126 //-----------------------------------------------------------------------------
129 //-----------------------------------------------------------------------------
132 //-----------------------------------------------------------------------------
133 } // end namespace gdcm