GDCM: gdcmStrictScanner2.h Source File

GDCM 3.2.10

gdcmStrictScanner2.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 GDCMSTRICTSCANNER2_H
15#define GDCMSTRICTSCANNER2_H
16
17#include "gdcmDirectory.h"
18#include "gdcmPrivateTag.h"
19#include "gdcmSmartPointer.h"
20#include "gdcmSubject.h"
21#include "gdcmTag.h"
22
23#include <map>
24#include <set>
25#include <string>
26
27#include <string.h> // strcmp
28
29namespace gdcm {
30class StringFilter;
31
52 class GDCM_EXPORT StrictScanner2 : public Subject {
53 friend std::ostream &operator<<(std::ostream &_os, const StrictScanner2 &s);
54
55 public:
56 StrictScanner2() : Values(), Filenames(), PublicMappings(), PrivateMappings(), Progress(0.0) {}
57 ~StrictScanner2() override;
58
65 typedef std::map<Tag, const char *> PublicTagToValue;
66 typedef PublicTagToValue::value_type PublicTagToValueValueType;
67
68 typedef std::map<PrivateTag, const char *> PrivateTagToValue;
69 typedef PrivateTagToValue::value_type PrivateTagToValueValueType;
70
72 bool AddPublicTag(Tag const &t);
73 void ClearPublicTags();
74
75 // Work in progress do not use:
76 bool AddPrivateTag(PrivateTag const &pt);
77 void ClearPrivateTags();
78
80 bool AddSkipTag(Tag const &t);
81 void ClearSkipTags();
82
84 bool Scan(Directory::FilenamesType const &filenames);
85
87 Directory::FilenamesType const &GetFilenames() const { return Filenames; }
88
90 void Print(std::ostream &os) const override;
91
93 void PrintTable(std::ostream &os, bool header = false) const;
94
98 bool IsKey(const char *filename) const;
99
102 Directory::FilenamesType GetKeys() const;
103
104 // struct to store all the values found:
105 typedef std::set<std::string> ValuesType;
106
108 ValuesType const &GetValues() const { return Values; }
109
111 ValuesType GetPublicValues(Tag const &t) const;
112
115 ValuesType GetPrivateValues(PrivateTag const &pt) const;
116
120 Directory::FilenamesType GetPublicOrderedValues(Tag const &t) const;
121
122 Directory::FilenamesType GetPrivateOrderedValues(PrivateTag const &pt) const;
123
124 /* ltstr is CRITICAL, otherwise pointers value are used to do the key
125 * comparison */
126 struct ltstr {
127 bool operator()(const char *s1, const char *s2) const {
128 gdcm_assert(s1 && s2);
129 return strcmp(s1, s2) < 0;
130 }
131 };
132 typedef std::map<const char *, PublicTagToValue, ltstr> PublicMappingType;
133 typedef PublicMappingType::const_iterator PublicConstIterator;
134 PublicConstIterator Begin() const { return PublicMappings.begin(); }
135 PublicConstIterator End() const { return PublicMappings.end(); }
136
137 typedef std::map<const char *, PrivateTagToValue, ltstr> PrivateMappingType;
138 typedef PrivateMappingType::const_iterator PrivateConstIterator;
139 PrivateConstIterator PrivateBegin() const { return PrivateMappings.begin(); }
140 PrivateConstIterator PrivateEnd() const { return PrivateMappings.end(); }
141
144 PublicMappingType const &GetPublicMappings() const { return PublicMappings; }
145 PrivateMappingType const &GetPrivateMappings() const {
146 return PrivateMappings;
147 }
148
150 PublicTagToValue const &GetPublicMapping(const char *filename) const;
151 PrivateTagToValue const &GetPrivateMapping(const char *filename) const;
152
155 const char *GetFilenameFromPublicTagToValue(Tag const &t,
156 const char *valueref) const;
157 const char *GetFilenameFromPrivateTagToValue(PrivateTag const &pt,
158 const char *valueref) const;
159
162 Directory::FilenamesType GetAllFilenamesFromPublicTagToValue(
163 Tag const &t, const char *valueref) const;
164 Directory::FilenamesType GetAllFilenamesFromPrivateTagToValue(
165 PrivateTag const &pt, const char *valueref) const;
166
169 // by a call to GetMapping()
170 PublicTagToValue const &GetMappingFromPublicTagToValue(
171 Tag const &t, const char *value) const;
172 PrivateTagToValue const &GetMappingFromPrivateTagToValue(
173 PrivateTag const &pt, const char *value) const;
174
180 const char *GetPublicValue(const char *filename, Tag const &t) const;
181 const char *GetPrivateValue(const char *filename, PrivateTag const &t) const;
182
184 static SmartPointer<StrictScanner2> New() { return new StrictScanner2; }
185
186 protected:
187 void ProcessPublicTag(StringFilter &sf, const char *filename);
188 void ProcessPrivateTag(StringFilter &sf, const char *filename);
189
190 private:
191 // struct to store all uniq tags in ascending order:
192 typedef std::set<Tag> PublicTagsType;
193 typedef std::set<PrivateTag> PrivateTagsType;
194 std::set<Tag> PublicTags; // Public and Private Creator
195 std::set<PrivateTag> PrivateTags; // Only Private (no Private Creator)
196 std::set<Tag> SkipTags;
197 ValuesType Values;
198 Directory::FilenamesType Filenames;
199
200 // Main struct that will hold all public mapping:
201 PublicMappingType PublicMappings;
202 // Main struct that will hold all private mapping:
203 PrivateMappingType PrivateMappings;
204
205 double Progress;
206};
207//-----------------------------------------------------------------------------
208 inline std::ostream &operator<<(std::ostream &os, const StrictScanner2 &s) {
209 s.Print(os);
210 return os;
211}
212
213} // end namespace gdcm
214
215#endif // GDCMSTRICTSCANNER2_H
gdcm::Directory::FilenamesType
std::vector< FilenameType > FilenamesType
Definition gdcmDirectory.h:49
gdcm::PrivateTag
Class to represent a Private DICOM Data Element (Attribute) Tag (Group, Element, Owner).
Definition gdcmPrivateTag.h:39
gdcm::SmartPointer
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
gdcm::StrictScanner2::PublicMappingType
std::map< const char *, PublicTagToValue, ltstr > PublicMappingType
Definition gdcmStrictScanner2.h:132
gdcm::StrictScanner2::GetPrivateValue
const char * GetPrivateValue(const char *filename, PrivateTag const &t) const
gdcm::StrictScanner2::GetMappingFromPublicTagToValue
PublicTagToValue const & GetMappingFromPublicTagToValue(Tag const &t, const char *value) const
gdcm::StrictScanner2::GetAllFilenamesFromPrivateTagToValue
Directory::FilenamesType GetAllFilenamesFromPrivateTagToValue(PrivateTag const &pt, const char *valueref) const
gdcm::StrictScanner2::StrictScanner2
StrictScanner2()
Definition gdcmStrictScanner2.h:56
gdcm::StrictScanner2::Begin
PublicConstIterator Begin() const
Definition gdcmStrictScanner2.h:134
gdcm::StrictScanner2::GetKeys
Directory::FilenamesType GetKeys() const
gdcm::StrictScanner2::GetAllFilenamesFromPublicTagToValue
Directory::FilenamesType GetAllFilenamesFromPublicTagToValue(Tag const &t, const char *valueref) const
gdcm::StrictScanner2::GetPublicMappings
PublicMappingType const & GetPublicMappings() const
Definition gdcmStrictScanner2.h:144
gdcm::StrictScanner2::GetPublicValue
const char * GetPublicValue(const char *filename, Tag const &t) const
gdcm::StrictScanner2::GetFilenames
Directory::FilenamesType const & GetFilenames() const
Return the list of filenames.
Definition gdcmStrictScanner2.h:87
gdcm::StrictScanner2::GetMappingFromPrivateTagToValue
PrivateTagToValue const & GetMappingFromPrivateTagToValue(PrivateTag const &pt, const char *value) const
gdcm::StrictScanner2::GetPublicOrderedValues
Directory::FilenamesType GetPublicOrderedValues(Tag const &t) const
gdcm::StrictScanner2::PrivateEnd
PrivateConstIterator PrivateEnd() const
Definition gdcmStrictScanner2.h:140
gdcm::StrictScanner2::GetPublicValues
ValuesType GetPublicValues(Tag const &t) const
Get all the values found (in lexicographic order) associated with Tag 't'.
gdcm::StrictScanner2::GetPublicMapping
PublicTagToValue const & GetPublicMapping(const char *filename) const
Get the std::map mapping filenames to value for file 'filename'.
gdcm::StrictScanner2::ProcessPublicTag
void ProcessPublicTag(StringFilter &sf, const char *filename)
gdcm::StrictScanner2::IsKey
bool IsKey(const char *filename) const
gdcm::StrictScanner2::AddPrivateTag
bool AddPrivateTag(PrivateTag const &pt)
gdcm::StrictScanner2::End
PublicConstIterator End() const
Definition gdcmStrictScanner2.h:135
gdcm::StrictScanner2::Scan
bool Scan(Directory::FilenamesType const &filenames)
Start the scan !
gdcm::StrictScanner2::operator<<
friend std::ostream & operator<<(std::ostream &_os, const StrictScanner2 &s)
Definition gdcmStrictScanner2.h:208
gdcm::StrictScanner2::PublicTagToValueValueType
PublicTagToValue::value_type PublicTagToValueValueType
Definition gdcmStrictScanner2.h:66
gdcm::StrictScanner2::GetPrivateValues
ValuesType GetPrivateValues(PrivateTag const &pt) const
gdcm::StrictScanner2::GetPrivateMapping
PrivateTagToValue const & GetPrivateMapping(const char *filename) const
gdcm::StrictScanner2::GetPrivateOrderedValues
Directory::FilenamesType GetPrivateOrderedValues(PrivateTag const &pt) const
gdcm::StrictScanner2::ClearSkipTags
void ClearSkipTags()
gdcm::StrictScanner2::Print
void Print(std::ostream &os) const override
Print result.
gdcm::StrictScanner2::ValuesType
std::set< std::string > ValuesType
Definition gdcmStrictScanner2.h:105
gdcm::StrictScanner2::PrivateConstIterator
PrivateMappingType::const_iterator PrivateConstIterator
Definition gdcmStrictScanner2.h:138
gdcm::StrictScanner2::PrintTable
void PrintTable(std::ostream &os, bool header=false) const
Print result as CSV table.
gdcm::StrictScanner2::PublicConstIterator
PublicMappingType::const_iterator PublicConstIterator
Definition gdcmStrictScanner2.h:133
gdcm::StrictScanner2::AddSkipTag
bool AddSkipTag(Tag const &t)
Add a tag that will need to be skipped. Those are root level skip tags.
gdcm::StrictScanner2::AddPublicTag
bool AddPublicTag(Tag const &t)
Add a tag that will need to be read. Those are root level tags.
gdcm::StrictScanner2::GetFilenameFromPrivateTagToValue
const char * GetFilenameFromPrivateTagToValue(PrivateTag const &pt, const char *valueref) const
gdcm::StrictScanner2::~StrictScanner2
~StrictScanner2() override
gdcm::StrictScanner2::PrivateTagToValue
std::map< PrivateTag, const char * > PrivateTagToValue
Definition gdcmStrictScanner2.h:68
gdcm::StrictScanner2::ProcessPrivateTag
void ProcessPrivateTag(StringFilter &sf, const char *filename)
gdcm::StrictScanner2::ClearPublicTags
void ClearPublicTags()
gdcm::StrictScanner2::PrivateTagToValueValueType
PrivateTagToValue::value_type PrivateTagToValueValueType
Definition gdcmStrictScanner2.h:69
gdcm::StrictScanner2::ClearPrivateTags
void ClearPrivateTags()
gdcm::StrictScanner2::GetFilenameFromPublicTagToValue
const char * GetFilenameFromPublicTagToValue(Tag const &t, const char *valueref) const
gdcm::StrictScanner2::PrivateBegin
PrivateConstIterator PrivateBegin() const
Definition gdcmStrictScanner2.h:139
gdcm::StrictScanner2::GetPrivateMappings
PrivateMappingType const & GetPrivateMappings() const
Definition gdcmStrictScanner2.h:145
gdcm::StrictScanner2::New
static SmartPointer< StrictScanner2 > New()
for wrapped language: instantiate a reference counted object
Definition gdcmStrictScanner2.h:184
gdcm::StrictScanner2::PublicTagToValue
std::map< Tag, const char * > PublicTagToValue
Definition gdcmStrictScanner2.h:65
gdcm::StrictScanner2::GetValues
ValuesType const & GetValues() const
Get all the values found (in lexicographic order).
Definition gdcmStrictScanner2.h:108
gdcm::StrictScanner2::PrivateMappingType
std::map< const char *, PrivateTagToValue, ltstr > PrivateMappingType
Definition gdcmStrictScanner2.h:137
gdcm::StringFilter
StringFilter.
Definition gdcmStringFilter.h:30
gdcm::Subject::Subject
Subject()
gdcm::Tag
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
gdcmDirectory.h
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmPrivateTag.h
gdcmSmartPointer.h
gdcmSubject.h
gdcmTag.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
gdcm::StrictScanner2::ltstr
Definition gdcmStrictScanner2.h:126
gdcm::StrictScanner2::ltstr::operator()
bool operator()(const char *s1, const char *s2) const
Definition gdcmStrictScanner2.h:127