GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

gdcmGlobal.h
Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004
    00005   Copyright (c) 2006-2011 Mathieu Malaterre
    00006   All rights reserved.
    00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00008
    00009      This software is distributed WITHOUT ANY WARRANTY; without even
    00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00011      PURPOSE.  See the above copyright notice for more information.
    00012
    00013 =========================================================================*/
    00014 // Implementation detail was shamelessly borowed from the VTK excellent
    00015 // implementation of debug leak manager singleton:
    00016 /*=========================================================================
    00017
    00018   Program:   Visualization Toolkit
    00019   Module:    $RCSfile: vtkDebugLeaks.cxx,v $
    00020
    00021   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
    00022   All rights reserved.
    00023   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00024
    00025      This software is distributed WITHOUT ANY WARRANTY; without even
    00026      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00027      PURPOSE.  See the above copyright notice for more information.
    00028
    00029 =========================================================================*/
    00030 #ifndef GDCMGLOBAL_H
    00031 #define GDCMGLOBAL_H
    00032
    00033 #include "gdcmTypes.h"
    00034
    00035 namespace gdcm
    00036 {
    00037 class GlobalInternal;
    00038 class Dicts;
    00039 class Defs;
    00049 class GDCM_EXPORT Global // why expose the symbol I think I only need to expose the instance...
    00050 {
    00051   friend std::ostream& operator<<(std::ostream &_os, const Global &g);
    00052 public:
    00053   Global();
    00054   ~Global();
    00055
    00058   Dicts const &GetDicts() const;
    00059   Dicts &GetDicts();
    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