X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmGlobal.cxx;h=7ae08b6e0a16ed5277aad44ba21e2a28c9188dcc;hb=c1a305b54c1a9dd1bfe2173940ba84ccd1b4bb27;hp=7be5abe6d0ab6225952ebad9e4bb199e499be7ae;hpb=1bc5ccd72098866fc29ca8a786e8bb6852f388ea;p=gdcm.git diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index 7be5abe6..7ae08b6e 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -1,91 +1,113 @@ -// gdcmGlobal.cxx -//----------------------------------------------------------------------------- +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmGlobal.cxx,v $ + Language: C++ + Date: $Date: 2007/09/17 12:20:01 $ + Version: $Revision: 1.37 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + #include "gdcmGlobal.h" + #include "gdcmDebug.h" -#include -#include // For isspace -#include // CLEANME: could this be only string ? Related to Win32 ? +#include "gdcmVR.h" +#include "gdcmTS.h" +#include "gdcmDictGroupName.h" +#include "gdcmDictSet.h" +#include "gdcmDicomDirElement.h" -/** - * \ingroup Globals - * \brief Pointer to a container, holding _all_ the Dicom Dictionaries. - */ -gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0; +namespace GDCM_NAME_SPACE +{ +//----------------------------------------------------------------------------- +/// \brief Those global string that are returned by reference everywhere in +/// gdcm code used to be in gdcmCommon.h but due to a 'bug' in gcc/MacOSX +/// you cannot have static initialization in a multithreaded environment +/// since there is a lazy construction everything got skrew up somehow +/// Therefore the actual initialization is done in a cxx file (avoid +/// duplicated symbol), and an extern is used in gdcmCommon.h -/** - * \ingroup Globals - * \brief Pointer to a hash table containing the 'Value Representations'. - */ -gdcmVR *gdcmGlobal::VR = (gdcmVR *)0; +const std::string GDCM_UNKNOWN = "GDCM::Unknown"; +const std::string GDCM_UNFOUND = "GDCM::Unfound"; +const std::string GDCM_BINLOADED = "GDCM::Binary data"; +const std::string GDCM_NOTLOADED = "GDCM::NotLoaded"; +const std::string GDCM_UNREAD = "GDCM::UnRead"; +const std::string GDCM_NOTASCII = "GDCM::NotAscii"; +const std::string GDCM_PIXELDATA = "GDCM::Pixel Data to be loaded"; -/** - * \ingroup Globals - * \brief Pointer to a hash table containing the Transfer Syntax codes - * and their english description - */ -gdcmTS *gdcmGlobal::TS = (gdcmTS *)0; +const char GDCM_VRUNKNOWN[2] = {' ',' '}; // avoid useless std::string stuff -/** - * \ingroup Globals - * \brief Pointer to the hash table containing the Dicom Elements - * necessary to describe each part of a DICOMDIR - */ -gdcmDicomDirElement *gdcmGlobal::ddElem = (gdcmDicomDirElement *)0; +#ifdef _WIN32 +const char GDCM_FILESEPARATOR = '\\'; +#else +const char GDCM_FILESEPARATOR = '/'; +#endif + +//----------------------------------------------------------------------------- +DictSet *Global::Dicts = (DictSet *)0; +VR *Global::ValRes = (VR *)0; +TS *Global::TranSyn = (TS *)0; +DictGroupName *Global::GroupName = (DictGroupName *)0; +DicomDirElement *Global::ddElem = (DicomDirElement *)0; + +Dict *Global::DefaultPubDict = (Dict *)0; +//----------------------------------------------------------------------------- /** - * \ingroup Globals * \brief Global container */ -gdcmGlobal gdcmGlob; +Global Glob; +//------------------------------------------------------------------------- +// Constructor / Destructor /** - * \ingroup gdcmGlobal * \brief constructor : populates the various H Tables */ -gdcmGlobal::gdcmGlobal(void) { - if (VR || TS || Dicts || ddElem) - dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated"); - Dicts = new gdcmDictSet(); - VR = new gdcmVR(); - TS = new gdcmTS(); - ddElem = new gdcmDicomDirElement(); +Global::Global() +{ + if (ValRes || TranSyn || Dicts || ddElem || GroupName ) + { + gdcmStaticWarningMacro( "VR or TS or Dicts or ... already allocated"); + return; + } + Dicts = DictSet::New(); + ValRes = VR::New(); + TranSyn = TS::New(); + GroupName = DictGroupName::New(); + ddElem = DicomDirElement::New(); } /** - * \ingroup gdcmGlobal * \brief canonical destructor */ -gdcmGlobal::~gdcmGlobal() { - delete Dicts; - delete VR; - delete TS; - delete ddElem; -} -/** - * \ingroup gdcmGlobal - * \brief returns a pointer to the 'Value Representation Table' - */ -gdcmVR *gdcmGlobal::GetVR(void) { - return VR; -} -/** - * \ingroup gdcmGlobal - * \brief returns a pointer to the 'Transfert Syntax Table' - */ -gdcmTS *gdcmGlobal::GetTS(void) { - return TS; -} -/** - * \ingroup gdcmGlobal - * \brief returns a pointer to Dictionaries Table - */ -gdcmDictSet *gdcmGlobal::GetDicts(void) { - return Dicts; -} -/** - * \ingroup gdcmGlobal - * \brief returns a pointer to the DicomDir related elements Table - */ -gdcmDicomDirElement *gdcmGlobal::GetDicomDirElements(void) { - return ddElem; +Global::~Global() +{ + Dicts->Delete(); + ValRes->Delete(); + TranSyn->Delete(); + GroupName->Delete(); + ddElem->Delete(); } + +//----------------------------------------------------------------------------- +// Public + +//----------------------------------------------------------------------------- +// Protected + +//----------------------------------------------------------------------------- +// Private + +//----------------------------------------------------------------------------- +// Print + +//----------------------------------------------------------------------------- +} // end namespace gdcm