GDCM 3.0.24
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
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);
74
75 // Work in progress do not use:
76 bool AddPrivateTag(PrivateTag const &pt);
78
80 bool AddSkipTag(Tag const &t);
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
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
112
116
121
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 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; }
146 return PrivateMappings;
147 }
148
150 PublicTagToValue const &GetPublicMapping(const char *filename) const;
151 PrivateTagToValue const &GetPrivateMapping(const char *filename) const;
152
156 const char *valueref) const;
158 const char *valueref) const;
159
163 Tag const &t, const char *valueref) const;
165 PrivateTag const &pt, const char *valueref) const;
166
169 // by a call to GetMapping()
171 Tag const &t, const char *value) const;
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
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//-----------------------------------------------------------------------------
208inline 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
std::vector< FilenameType > FilenamesType
Definition gdcmDirectory.h:49
Class to represent a Private DICOM Data Element (Attribute) Tag (Group, Element, Owner)
Definition gdcmPrivateTag.h:39
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
StrictScanner2.
Definition gdcmStrictScanner2.h:52
std::map< const char *, PublicTagToValue, ltstr > PublicMappingType
Definition gdcmStrictScanner2.h:132
const char * GetPrivateValue(const char *filename, PrivateTag const &t) const
PublicTagToValue const & GetMappingFromPublicTagToValue(Tag const &t, const char *value) const
Directory::FilenamesType GetAllFilenamesFromPrivateTagToValue(PrivateTag const &pt, const char *valueref) const
StrictScanner2()
Definition gdcmStrictScanner2.h:56
PublicConstIterator Begin() const
Definition gdcmStrictScanner2.h:134
Directory::FilenamesType GetKeys() const
Directory::FilenamesType GetAllFilenamesFromPublicTagToValue(Tag const &t, const char *valueref) const
PublicMappingType const & GetPublicMappings() const
Definition gdcmStrictScanner2.h:144
const char * GetPublicValue(const char *filename, Tag const &t) const
Directory::FilenamesType const & GetFilenames() const
Return the list of filenames.
Definition gdcmStrictScanner2.h:87
PrivateTagToValue const & GetMappingFromPrivateTagToValue(PrivateTag const &pt, const char *value) const
Directory::FilenamesType GetPublicOrderedValues(Tag const &t) const
PrivateConstIterator PrivateEnd() const
Definition gdcmStrictScanner2.h:140
ValuesType GetPublicValues(Tag const &t) const
Get all the values found (in lexicographic order) associated with Tag 't'.
PublicTagToValue const & GetPublicMapping(const char *filename) const
Get the std::map mapping filenames to value for file 'filename'.
void ProcessPublicTag(StringFilter &sf, const char *filename)
bool IsKey(const char *filename) const
bool AddPrivateTag(PrivateTag const &pt)
PublicConstIterator End() const
Definition gdcmStrictScanner2.h:135
bool Scan(Directory::FilenamesType const &filenames)
Start the scan !
PublicTagToValue::value_type PublicTagToValueValueType
Definition gdcmStrictScanner2.h:66
ValuesType GetPrivateValues(PrivateTag const &pt) const
PrivateTagToValue const & GetPrivateMapping(const char *filename) const
Directory::FilenamesType GetPrivateOrderedValues(PrivateTag const &pt) const
void Print(std::ostream &os) const override
Print result.
std::set< std::string > ValuesType
Definition gdcmStrictScanner2.h:105
PrivateMappingType::const_iterator PrivateConstIterator
Definition gdcmStrictScanner2.h:138
void PrintTable(std::ostream &os, bool header=false) const
Print result as CSV table.
PublicMappingType::const_iterator PublicConstIterator
Definition gdcmStrictScanner2.h:133
bool AddSkipTag(Tag const &t)
Add a tag that will need to be skipped. Those are root level skip tags.
bool AddPublicTag(Tag const &t)
Add a tag that will need to be read. Those are root level tags.
const char * GetFilenameFromPrivateTagToValue(PrivateTag const &pt, const char *valueref) const
~StrictScanner2() override
std::map< PrivateTag, const char * > PrivateTagToValue
Definition gdcmStrictScanner2.h:68
void ProcessPrivateTag(StringFilter &sf, const char *filename)
PrivateTagToValue::value_type PrivateTagToValueValueType
Definition gdcmStrictScanner2.h:69
const char * GetFilenameFromPublicTagToValue(Tag const &t, const char *valueref) const
PrivateConstIterator PrivateBegin() const
Definition gdcmStrictScanner2.h:139
PrivateMappingType const & GetPrivateMappings() const
Definition gdcmStrictScanner2.h:145
static SmartPointer< StrictScanner2 > New()
for wrapped language: instantiate a reference counted object
Definition gdcmStrictScanner2.h:184
std::map< Tag, const char * > PublicTagToValue
Definition gdcmStrictScanner2.h:65
ValuesType const & GetValues() const
Get all the values found (in lexicographic order)
Definition gdcmStrictScanner2.h:108
std::map< const char *, PrivateTagToValue, ltstr > PrivateMappingType
Definition gdcmStrictScanner2.h:137
StringFilter.
Definition gdcmStringFilter.h:30
Subject.
Definition gdcmSubject.h:29
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
#define GDCM_EXPORT
Definition gdcmWin32.h:34
Definition gdcmASN1.h:21
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88
Definition gdcmStrictScanner2.h:126
bool operator()(const char *s1, const char *s2) const
Definition gdcmStrictScanner2.h:127