GDCM: gdcmMacros.h Source File

GDCM 3.0.26

gdcmMacros.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 GDCMMACROS_H
15#define GDCMMACROS_H
16
17#include "gdcmTypes.h"
18#include "gdcmMacro.h"
19
20#include <map>
21
22namespace gdcm
23{
29 class GDCM_EXPORT Macros
30{
31public:
32 typedef std::map<std::string, Macro> ModuleMapType;
33
34 Macros() = default;
35 friend std::ostream& operator<<(std::ostream& _os, const Macros&_val);
36
37 void Clear() { ModulesInternal.clear(); }
38
39 // A Module is inserted based on it's ref
40 void AddMacro(const char *ref, const Macro & 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 Macro &GetMacro(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
58private:
59 ModuleMapType ModulesInternal;
60};
61//-----------------------------------------------------------------------------
62 inline std::ostream& operator<<(std::ostream& _os, const Macros &_val)
63{
64 Macros::ModuleMapType::const_iterator it = _val.ModulesInternal.begin();
65 for(;it != _val.ModulesInternal.end(); ++it)
66 {
67 const std::string &name = it->first;
68 const Macro &m = it->second;
69 _os << name << " " << m << '\n';
70 }
71
72 return _os;
73}
74
75
76} // end namespace gdcm
77
78#endif //GDCMMODULES_H
gdcm::Macro
Class for representing a Macro.
Definition gdcmMacro.h:37
gdcm::Macros::Macros
Macros()=default
gdcm::Macros::Clear
void Clear()
Definition gdcmMacros.h:37
gdcm::Macros::GetMacro
const Macro & GetMacro(const char *name) const
Definition gdcmMacros.h:47
gdcm::Macros::AddMacro
void AddMacro(const char *ref, const Macro &module)
Definition gdcmMacros.h:40
gdcm::Macros::IsEmpty
bool IsEmpty() const
Definition gdcmMacros.h:56
gdcm::Macros::operator<<
friend std::ostream & operator<<(std::ostream &_os, const Macros &_val)
Definition gdcmMacros.h:62
gdcm::Macros::ModuleMapType
std::map< std::string, Macro > ModuleMapType
Definition gdcmMacros.h:32
gdcmMacro.h
gdcmTypes.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21
gdcm::operator<<
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88