gdcmStrictScanner2.h
Go to the documentation of this file.
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCMSTRICTSCANNER2_H
#define GDCMSTRICTSCANNER2_H
#include "gdcmDirectory.h"
#include "gdcmPrivateTag.h"
#include "gdcmSmartPointer.h"
#include "gdcmSubject.h"
#include "gdcmTag.h"
#include <map>
#include <set>
#include <string>
#include <string.h> // strcmp
namespace gdcm {
class StringFilter;
class GDCM_EXPORT StrictScanner2 : public Subject {
friend std::ostream &operator<<(std::ostream &_os, const StrictScanner2 &s);
public:
StrictScanner2() : Values(), Filenames(), PublicMappings(), PrivateMappings(), Progress(0.0) {}
~StrictScanner2() override;
typedef std::map<Tag, const char *> PublicTagToValue;
typedef PublicTagToValue::value_type PublicTagToValueValueType;
typedef std::map<PrivateTag, const char *> PrivateTagToValue;
typedef PrivateTagToValue::value_type PrivateTagToValueValueType;
bool AddPublicTag(Tag const &t);
void ClearPublicTags();
// Work in progress do not use:
bool AddPrivateTag(PrivateTag const &pt);
void ClearPrivateTags();
bool AddSkipTag(Tag const &t);
void ClearSkipTags();
bool Scan(Directory::FilenamesType const &filenames);
Directory::FilenamesType const &GetFilenames() const { return Filenames; }
void Print(std::ostream &os) const override;
void PrintTable(std::ostream &os, bool header = false) const;
bool IsKey(const char *filename) const;
Directory::FilenamesType GetKeys() const;
// struct to store all the values found:
typedef std::set<std::string> ValuesType;
ValuesType const &GetValues() const { return Values; }
ValuesType GetPublicValues(Tag const &t) const;
ValuesType GetPrivateValues(PrivateTag const &pt) const;
Directory::FilenamesType GetPublicOrderedValues(Tag const &t) const;
Directory::FilenamesType GetPrivateOrderedValues(PrivateTag const &pt) const;
/* ltstr is CRITICAL, otherwise pointers value are used to do the key
* comparison */
struct ltstr {
bool operator()(const char *s1, const char *s2) const {
assert(s1 && s2);
return strcmp(s1, s2) < 0;
}
};
typedef std::map<const char *, PublicTagToValue, ltstr> PublicMappingType;
typedef PublicMappingType::const_iterator PublicConstIterator;
PublicConstIterator Begin() const { return PublicMappings.begin(); }
PublicConstIterator End() const { return PublicMappings.end(); }
typedef std::map<const char *, PrivateTagToValue, ltstr> PrivateMappingType;
typedef PrivateMappingType::const_iterator PrivateConstIterator;
PrivateConstIterator PrivateBegin() const { return PrivateMappings.begin(); }
PrivateConstIterator PrivateEnd() const { return PrivateMappings.end(); }
PublicMappingType const &GetPublicMappings() const { return PublicMappings; }
PrivateMappingType const &GetPrivateMappings() const {
return PrivateMappings;
}
PublicTagToValue const &GetPublicMapping(const char *filename) const;
PrivateTagToValue const &GetPrivateMapping(const char *filename) const;
const char *GetFilenameFromPublicTagToValue(Tag const &t,
const char *valueref) const;
const char *GetFilenameFromPrivateTagToValue(PrivateTag const &pt,
const char *valueref) const;
Directory::FilenamesType GetAllFilenamesFromPublicTagToValue(
Tag const &t, const char *valueref) const;
Directory::FilenamesType GetAllFilenamesFromPrivateTagToValue(
PrivateTag const &pt, const char *valueref) const;
// by a call to GetMapping()
PublicTagToValue const &GetMappingFromPublicTagToValue(
Tag const &t, const char *value) const;
PrivateTagToValue const &GetMappingFromPrivateTagToValue(
PrivateTag const &pt, const char *value) const;
const char *GetPublicValue(const char *filename, Tag const &t) const;
const char *GetPrivateValue(const char *filename, PrivateTag const &t) const;
static SmartPointer<StrictScanner2> New() { return new StrictScanner2; }
protected:
void ProcessPublicTag(StringFilter &sf, const char *filename);
void ProcessPrivateTag(StringFilter &sf, const char *filename);
private:
// struct to store all uniq tags in ascending order:
typedef std::set<Tag> PublicTagsType;
typedef std::set<PrivateTag> PrivateTagsType;
std::set<Tag> PublicTags; // Public and Private Creator
std::set<PrivateTag> PrivateTags; // Only Private (no Private Creator)
std::set<Tag> SkipTags;
ValuesType Values;
Directory::FilenamesType Filenames;
// Main struct that will hold all public mapping:
PublicMappingType PublicMappings;
// Main struct that will hold all private mapping:
PrivateMappingType PrivateMappings;
double Progress;
};
//-----------------------------------------------------------------------------
inline std::ostream &operator<<(std::ostream &os, const StrictScanner2 &s) {
s.Print(os);
return os;
}
} // end namespace gdcm
#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
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