GDCM  2.2.0
gdcmMacros.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 #ifndef GDCMMACROS_H
00015 #define GDCMMACROS_H
00016 
00017 #include "gdcmTypes.h"
00018 #include "gdcmMacro.h"
00019 
00020 #include <map>
00021 
00022 namespace gdcm
00023 {
00029 class GDCM_EXPORT Macros
00030 {
00031 public:
00032   typedef std::map<std::string, Macro> ModuleMapType;
00033 
00034   Macros() {}
00035   friend std::ostream& operator<<(std::ostream& _os, const Macros&_val);
00036 
00037   void Clear() { ModulesInternal.clear(); }
00038 
00039   // A Module is inserted based on it's ref
00040   void AddMacro(const char *ref, const Macro & module )
00041     {
00042     assert( ref && *ref );
00043     assert( ModulesInternal.find( ref ) == ModulesInternal.end() );
00044     ModulesInternal.insert(
00045       ModuleMapType::value_type(ref, module));
00046     }
00047   const Macro &GetMacro(const char *name) const
00048     {
00049     assert( name && *name );
00050     ModuleMapType::const_iterator it = ModulesInternal.find( name );
00051     assert( it != ModulesInternal.end() );
00052     assert( it->first == name );
00053     return it->second;
00054     }
00055 
00056   bool IsEmpty() const { return ModulesInternal.empty(); }
00057 
00058 private:
00059   ModuleMapType ModulesInternal;
00060 };
00061 //-----------------------------------------------------------------------------
00062 inline std::ostream& operator<<(std::ostream& _os, const Macros &_val)
00063 {
00064   Macros::ModuleMapType::const_iterator it = _val.ModulesInternal.begin();
00065   for(;it != _val.ModulesInternal.end(); ++it)
00066     {
00067     const std::string &name = it->first;
00068     const Macro &m = it->second;
00069     _os << name << " " << m << '\n';
00070     }
00071 
00072   return _os;
00073 }
00074 
00075 
00076 } // end namespace gdcm
00077 
00078 #endif //GDCMMODULES_H

Generated on Sun Jun 3 2012 15:26:48 for GDCM by doxygen 1.8.0
SourceForge.net Logo