GDCM 2.2.1

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

- File List
- File Members

gdcmCSAHeaderDict.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 GDCMCSAHEADERDICT_H
15 #define GDCMCSAHEADERDICT_H
16
17 #include "gdcmTypes.h"
18 #include "gdcmTag.h"
19 #include "gdcmCSAHeaderDictEntry.h"
20
21 #include <iostream>
22 #include <iomanip>
23 #include <set>
24 #include <exception>
25
26 namespace gdcm
27 {
28
29 class GDCM_EXPORT CSAHeaderDictException : public std::exception {};
30
34 class GDCM_EXPORT CSAHeaderDict
35 {
36 public:
37 typedef std::set<CSAHeaderDictEntry> MapCSAHeaderDictEntry;
38 typedef MapCSAHeaderDictEntry::iterator Iterator;
39 typedef MapCSAHeaderDictEntry::const_iterator ConstIterator;
40 //static CSAHeaderDictEntry GroupLengthCSAHeaderDictEntry; // = CSAHeaderDictEntry("Group Length",VR::UL,VM::VM1);
41
42 CSAHeaderDict():CSAHeaderDictInternal() {
43 assert( CSAHeaderDictInternal.empty() );
44 }
45
46 friend std::ostream& operator<<(std::ostream& _os, const CSAHeaderDict &_val);
47
48 ConstIterator Begin() const { return CSAHeaderDictInternal.begin(); }
49 ConstIterator End() const { return CSAHeaderDictInternal.end(); }
50
51 bool IsEmpty() const { return CSAHeaderDictInternal.empty(); }
52 void AddCSAHeaderDictEntry(const CSAHeaderDictEntry &de)
53 {
54 #ifndef NDEBUG
55 MapCSAHeaderDictEntry::size_type s = CSAHeaderDictInternal.size();
56 #endif
57 CSAHeaderDictInternal.insert( de );
58 assert( s < CSAHeaderDictInternal.size() );
59 }
60
61 const CSAHeaderDictEntry &GetCSAHeaderDictEntry(const char *name) const
62 {
63 MapCSAHeaderDictEntry::const_iterator it = CSAHeaderDictInternal.find( name );
64 if( it != CSAHeaderDictInternal.end() )
65 {
66 return *it;
67 }
68 throw CSAHeaderDictException();
69 }
70
71 protected:
72 friend class Dicts;
73 void LoadDefault();
74
75 private:
76 CSAHeaderDict &operator=(const CSAHeaderDict &_val); // purposely not implemented
77 CSAHeaderDict(const CSAHeaderDict &_val); // purposely not implemented
78
79 MapCSAHeaderDictEntry CSAHeaderDictInternal;
80 };
81 //-----------------------------------------------------------------------------
82 inline std::ostream& operator<<(std::ostream& os, const CSAHeaderDict &val)
83 {
84 CSAHeaderDict::MapCSAHeaderDictEntry::const_iterator it = val.CSAHeaderDictInternal.begin();
85 for(;it != val.CSAHeaderDictInternal.end(); ++it)
86 {
87 const CSAHeaderDictEntry &de = *it;
88 os << de << '\n';
89 }
90
91
92 return os;
93 }
94
95
96 } // end namespace gdcm
97
98 #endif //GDCMCSAHEADERDICT_H