GDCM  2.2.6
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 
22 namespace gdcm
23 {
30 {
31 public:
32  typedef std::map<std::string, Macro> ModuleMapType;
33 
34  Macros() {}
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 
58 private:
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
void AddMacro(const char *ref, const Macro &module)
Definition: gdcmMacros.h:40
void Clear()
Definition: gdcmMacros.h:37
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition: gdcmDirectory.h:92
bool IsEmpty() const
Definition: gdcmMacros.h:56
Macros()
Definition: gdcmMacros.h:34
const Macro & GetMacro(const char *name) const
Definition: gdcmMacros.h:47
Class for representing a Macro.
Definition: gdcmMacro.h:36
std::map< std::string, Macro > ModuleMapType
Definition: gdcmMacros.h:32
Class for representing a Modules.
Definition: gdcmMacros.h:29

Generated on Sat Dec 21 2013 05:56:17 for GDCM by doxygen 1.8.5
SourceForge.net Logo