gdcmGlobal.h

Go to the documentation of this file.
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 
00063   Defs const &GetDefs() const;
00064 
00066   static Global& GetInstance();
00067 
00071   bool LoadResourcesFiles();
00072 
00075   bool Append(const char *path);
00076 
00079   bool Prepend(const char *path);
00080 
00081 protected:
00083   const char *Locate(const char *resfile) const;
00084 
00085 private:
00086   Global &operator=(const Global &_val); // purposely not implemented
00087   Global(const Global &_val); // purposely not implemented
00088   // PIMPL:
00089   // but we could have also directly exposed a Dicts *Internals;
00090   static GlobalInternal *Internals;
00091 };
00092 //-----------------------------------------------------------------------------
00093 inline std::ostream& operator<<(std::ostream &os, const Global &g)
00094 {
00095   (void)g;
00096   return os;
00097 }
00098 
00099 // This instance will show up in any translation unit that uses
00100 // Global or that has a singleton.  It will make sure
00101 // Global is initialized before it is used and is the last
00102 // static object destroyed.
00103 static Global GlobalInstance;
00104 
00105 } // end namespace gdcm
00106 
00107 #endif //GDCMGLOBAL_H
00108 

Generated on Sat Dec 4 2010 08:58:43 for GDCM by doxygen 1.7.2
SourceForge.net Logo