GDCM 2.0.17
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 Module: $URL$ 00005 00006 Copyright (c) 2006-2010 Mathieu Malaterre 00007 All rights reserved. 00008 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 // Implementation detail was shamelessly borowed from the VTK excellent 00016 // implementation of debug leak manager singleton: 00017 /*========================================================================= 00018 00019 Program: Visualization Toolkit 00020 Module: $RCSfile: vtkDebugLeaks.cxx,v $ 00021 00022 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00023 All rights reserved. 00024 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00025 00026 This software is distributed WITHOUT ANY WARRANTY; without even 00027 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00028 PURPOSE. See the above copyright notice for more information. 00029 00030 =========================================================================*/ 00031 #ifndef GDCMGLOBAL_H 00032 #define GDCMGLOBAL_H 00033 00034 #include "gdcmTypes.h" 00035 00036 namespace gdcm 00037 { 00038 class GlobalInternal; 00039 class Dicts; 00040 class Defs; 00050 class GDCM_EXPORT Global // why expose the symbol I think I only need to expose the instance... 00051 { 00052 friend std::ostream& operator<<(std::ostream &_os, const Global &g); 00053 public: 00054 Global(); 00055 ~Global(); 00056 00059 Dicts const &GetDicts() const; 00060 Dicts &GetDicts(); 00061 00064 Defs const &GetDefs() const; 00065 00067 static Global& GetInstance(); 00068 00072 bool LoadResourcesFiles(); 00073 00076 bool Append(const char *path); 00077 00080 bool Prepend(const char *path); 00081 00082 protected: 00084 const char *Locate(const char *resfile) const; 00085 00086 private: 00087 Global &operator=(const Global &_val); // purposely not implemented 00088 Global(const Global &_val); // purposely not implemented 00089 // PIMPL: 00090 // but we could have also directly exposed a Dicts *Internals; 00091 static GlobalInternal *Internals; 00092 }; 00093 //----------------------------------------------------------------------------- 00094 inline std::ostream& operator<<(std::ostream &os, const Global &g) 00095 { 00096 (void)g; 00097 return os; 00098 } 00099 00100 // This instance will show up in any translation unit that uses 00101 // Global or that has a singleton. It will make sure 00102 // Global is initialized before it is used and is the last 00103 // static object destroyed. 00104 static Global GlobalInstance; 00105 00106 } // end namespace gdcm 00107 00108 #endif //GDCMGLOBAL_H