Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gdcmDictEntry.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmDictEntry.cxx,v $
00005   Language:  C++
00006   Date:      $Date: 2005/02/02 15:07:41 $
00007   Version:   $Revision: 1.45 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018 
00019 #include "gdcmDictEntry.h"
00020 #include "gdcmDebug.h"
00021 #include "gdcmUtil.h"
00022 
00023 #include <iomanip> // for std::ios::left, ...
00024 #include <fstream>
00025 
00026 namespace gdcm 
00027 {
00028 //-----------------------------------------------------------------------------
00029 // Constructor / Destructor
00039 DictEntry::DictEntry(uint16_t group, uint16_t elem,
00040                      TagName const &vr, 
00041                      TagName const &vm,
00042                      TagName const &name)
00043 {
00044    Group   = group;
00045    Element = elem;
00046    VR      = vr;
00047    VM      = vm;
00048    Name    = name;
00049    Key     = TranslateToKey(group, elem);
00050 }
00051 
00052 //-----------------------------------------------------------------------------
00053 // Public
00059 void DictEntry::SetVR(TagName const &vr) 
00060 {
00061    if ( IsVRUnknown() )
00062    {
00063       VR = vr;
00064    }
00065    else 
00066    {
00067       gdcmErrorMacro( "Overwriting VR might compromise a dictionary");
00068    }
00069 }
00070 
00076 void DictEntry::SetVM(TagName const &vm) 
00077 {
00078    if ( IsVMUnknown() )
00079    {
00080       VM = vm;
00081    }
00082    else 
00083    {
00084       gdcmErrorMacro( "Overwriting VM might compromise a dictionary");
00085    }
00086 }
00087 
00095 TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
00096 {
00097    return Util::Format("%04x|%04x", group, elem);
00098 }
00099 
00100 //-----------------------------------------------------------------------------
00101 // Protected
00102 
00103 //-----------------------------------------------------------------------------
00104 // Private
00105 
00106 //-----------------------------------------------------------------------------
00107 // Print
00113 void DictEntry::Print(std::ostream &os, std::string const & )
00114 {
00115    std::string vr;
00116    std::ostringstream s;
00117 
00118    vr = GetVR();
00119    if(vr==GDCM_UNKNOWN)
00120       vr="  ";
00121 
00122    s << DictEntry::TranslateToKey(GetGroup(),GetElement()); 
00123    s << " [" << vr  << "] ";
00124 
00125    if (PrintLevel >= 1)
00126    {
00127       s.setf(std::ios::left);
00128       s << std::setw(66-GetName().length()) << " ";
00129    }
00130 
00131    s << "[" << GetName()<< "]";
00132    os << s.str() << std::endl;
00133 }
00134 
00135 //-----------------------------------------------------------------------------
00136 } // end namespace gdcm
00137 

Generated on Thu Feb 10 22:17:57 2005 for gdcm by doxygen 1.3.6