GDCM: gdcmCSAHeaderDict.h Source File

GDCM 3.2.6

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
26namespace gdcm
27{
28
29 class GDCM_EXPORT CSAHeaderDictException : public std::exception {};
30
34 class GDCM_EXPORT CSAHeaderDict
35{
36public:
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 gdcm_assert( CSAHeaderDictInternal.empty() );
44 }
45 CSAHeaderDict &operator=(const CSAHeaderDict &_val) = delete;
46 CSAHeaderDict(const CSAHeaderDict &_val) = delete;
47
48 friend std::ostream& operator<<(std::ostream& _os, const CSAHeaderDict &_val);
49
50 ConstIterator Begin() const { return CSAHeaderDictInternal.begin(); }
51 ConstIterator End() const { return CSAHeaderDictInternal.end(); }
52
53 bool IsEmpty() const { return CSAHeaderDictInternal.empty(); }
54 void AddCSAHeaderDictEntry(const CSAHeaderDictEntry &de)
55 {
56#ifndef NDEBUG
57 MapCSAHeaderDictEntry::size_type s = CSAHeaderDictInternal.size();
58#endif
59 CSAHeaderDictInternal.insert( de );
60#ifndef NDEBUG
61 gdcm_assert( s < CSAHeaderDictInternal.size() );
62#endif
63 }
64
65 const CSAHeaderDictEntry &GetCSAHeaderDictEntry(const char *name) const
66 {
67 MapCSAHeaderDictEntry::const_iterator it = CSAHeaderDictInternal.find( name );
68 if( it != CSAHeaderDictInternal.end() )
69 {
70 return *it;
71 }
72 throw CSAHeaderDictException();
73 }
74
75protected:
76 friend class Dicts;
77 void LoadDefault();
78
79private:
80
81 MapCSAHeaderDictEntry CSAHeaderDictInternal;
82};
83//-----------------------------------------------------------------------------
84 inline std::ostream& operator<<(std::ostream& os, const CSAHeaderDict &val)
85{
86 CSAHeaderDict::MapCSAHeaderDictEntry::const_iterator it = val.CSAHeaderDictInternal.begin();
87 for(;it != val.CSAHeaderDictInternal.end(); ++it)
88 {
89 const CSAHeaderDictEntry &de = *it;
90 os << de << '\n';
91 }
92
93
94 return os;
95}
96
97
98} // end namespace gdcm
99
100#endif //GDCMCSAHEADERDICT_H
gdcm::CSAHeaderDictEntry
Class to represent an Entry in the Dict.
Definition gdcmCSAHeaderDictEntry.h:39
gdcm::CSAHeaderDictException
Definition gdcmCSAHeaderDict.h:29
gdcm::CSAHeaderDict::IsEmpty
bool IsEmpty() const
Definition gdcmCSAHeaderDict.h:53
gdcm::CSAHeaderDict::End
ConstIterator End() const
Definition gdcmCSAHeaderDict.h:51
gdcm::CSAHeaderDict::MapCSAHeaderDictEntry
std::set< CSAHeaderDictEntry > MapCSAHeaderDictEntry
Definition gdcmCSAHeaderDict.h:37
gdcm::CSAHeaderDict::ConstIterator
MapCSAHeaderDictEntry::const_iterator ConstIterator
Definition gdcmCSAHeaderDict.h:39
gdcm::CSAHeaderDict::CSAHeaderDict
CSAHeaderDict()
Definition gdcmCSAHeaderDict.h:42
gdcm::CSAHeaderDict::GetCSAHeaderDictEntry
const CSAHeaderDictEntry & GetCSAHeaderDictEntry(const char *name) const
Definition gdcmCSAHeaderDict.h:65
gdcm::CSAHeaderDict::LoadDefault
void LoadDefault()
gdcm::CSAHeaderDict::operator=
CSAHeaderDict & operator=(const CSAHeaderDict &_val)=delete
gdcm::CSAHeaderDict::Begin
ConstIterator Begin() const
Definition gdcmCSAHeaderDict.h:50
gdcm::CSAHeaderDict::Dicts
friend class Dicts
Definition gdcmCSAHeaderDict.h:76
gdcm::CSAHeaderDict::AddCSAHeaderDictEntry
void AddCSAHeaderDictEntry(const CSAHeaderDictEntry &de)
Definition gdcmCSAHeaderDict.h:54
gdcm::CSAHeaderDict::Iterator
MapCSAHeaderDictEntry::iterator Iterator
Definition gdcmCSAHeaderDict.h:38
gdcm::CSAHeaderDict::operator<<
friend std::ostream & operator<<(std::ostream &_os, const CSAHeaderDict &_val)
Definition gdcmCSAHeaderDict.h:84
gdcm::CSAHeaderDict::CSAHeaderDict
CSAHeaderDict(const CSAHeaderDict &_val)=delete
gdcmCSAHeaderDictEntry.h
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmTag.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