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

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