GDCM
2.0.18
|
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 GDCMMODULES_H 00015 #define GDCMMODULES_H 00016 00017 #include "gdcmTypes.h" 00018 #include "gdcmModule.h" 00019 00020 #include <map> 00021 00022 namespace gdcm 00023 { 00029 class GDCM_EXPORT Modules 00030 { 00031 public: 00032 typedef std::map<std::string, Module> ModuleMapType; 00033 00034 Modules() {} 00035 friend std::ostream& operator<<(std::ostream& _os, const Modules &_val); 00036 00037 void Clear() { ModulesInternal.clear(); } 00038 00039 // A Module is inserted based on it's ref 00040 void AddModule(const char *ref, const Module & 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 Module &GetModule(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 Modules &_val) 00063 { 00064 Modules::ModuleMapType::const_iterator it = _val.ModulesInternal.begin(); 00065 for(;it != _val.ModulesInternal.end(); ++it) 00066 { 00067 const std::string &name = it->first; 00068 const Module &m = it->second; 00069 _os << name << " " << m << '\n'; 00070 } 00071 00072 return _os; 00073 } 00074 00075 00076 00077 } // end namespace gdcm 00078 00079 #endif //GDCMMODULES_H