GDCM 2.2.1

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

- File List
- File Members

gdcmModules.h
Go to the documentation of this file.
1 /*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13 =========================================================================*/
14 #ifndef GDCMMODULES_H
15 #define GDCMMODULES_H
16
17 #include "gdcmTypes.h"
18 #include "gdcmModule.h"
19
20 #include <map>
21
22 namespace gdcm
23 {
29 class GDCM_EXPORT Modules
30 {
31 public:
32 typedef std::map<std::string, Module> ModuleMapType;
33
34 Modules() {}
35 friend std::ostream& operator<<(std::ostream& _os, const Modules &_val);
36
37 void Clear() { ModulesInternal.clear(); }
38
39 // A Module is inserted based on it's ref
40 void AddModule(const char *ref, const Module & module )
41 {
42 assert( ref && *ref );
43 assert( ModulesInternal.find( ref ) == ModulesInternal.end() );
44 ModulesInternal.insert(
45 ModuleMapType::value_type(ref, module));
46 }
47 const Module &GetModule(const char *name) const
48 {
49 assert( name && *name );
50 ModuleMapType::const_iterator it = ModulesInternal.find( name );
51 assert( it != ModulesInternal.end() );
52 assert( it->first == name );
53 return it->second;
54 }
55
56 bool IsEmpty() const { return ModulesInternal.empty(); }
57
58 private:
59 ModuleMapType ModulesInternal;
60 };
61 //-----------------------------------------------------------------------------
62 inline std::ostream& operator<<(std::ostream& _os, const Modules &_val)
63 {
64 Modules::ModuleMapType::const_iterator it = _val.ModulesInternal.begin();
65 for(;it != _val.ModulesInternal.end(); ++it)
66 {
67 const std::string &name = it->first;
68 const Module &m = it->second;
69 _os << name << " " << m << '\n';
70 }
71
72 return _os;
73 }
74
75
76
77 } // end namespace gdcm
78
79 #endif //GDCMMODULES_H