GDCM: gdcmModules.h Source File

GDCM 3.2.11

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
22namespace gdcm
23{
29 class GDCM_EXPORT Modules
30{
31public:
32 typedef std::map<std::string, Module> ModuleMapType;
33
34 Modules() = default;
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 gdcm_assert( ref && *ref );
43 gdcm_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 gdcm_assert( name && *name );
50 ModuleMapType::const_iterator it = ModulesInternal.find( name );
51 gdcm_assert( it != ModulesInternal.end() );
52 gdcm_assert( it->first == name );
53 return it->second;
54 }
55
56 bool IsEmpty() const { return ModulesInternal.empty(); }
57
58private:
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
gdcm::Module
Class for representing a Module.
Definition gdcmModule.h:38
gdcm::Modules::GetModule
const Module & GetModule(const char *name) const
Definition gdcmModules.h:47
gdcm::Modules::Clear
void Clear()
Definition gdcmModules.h:37
gdcm::Modules::ModuleMapType
std::map< std::string, Module > ModuleMapType
Definition gdcmModules.h:32
gdcm::Modules::Modules
Modules()=default
gdcm::Modules::operator<<
friend std::ostream & operator<<(std::ostream &_os, const Modules &_val)
Definition gdcmModules.h:62
gdcm::Modules::AddModule
void AddModule(const char *ref, const Module &module)
Definition gdcmModules.h:40
gdcm::Modules::IsEmpty
bool IsEmpty() const
Definition gdcmModules.h:56
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmModule.h
gdcmTypes.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21