gdcmStrictScanner.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 GDCMSTRICTSCANNER_H
#define GDCMSTRICTSCANNER_H
#include "gdcmDirectory.h"
#include "gdcmSubject.h"
#include "gdcmTag.h"
#include "gdcmPrivateTag.h"
#include "gdcmSmartPointer.h"
#include <map>
#include <set>
#include <string>
#include <string.h> // strcmp
namespace gdcm
{
class StringFilter;
class GDCM_EXPORT StrictScanner : public Subject
{
friend std::ostream& operator<<(std::ostream &_os, const StrictScanner &s);
public:
StrictScanner():Values(),Filenames(),Mappings() {}
~StrictScanner() override;
typedef std::map<Tag, const char*> TagToValue;
//typedef std::map<Tag, ConstCharWrapper> TagToValue; //StringMap;
//typedef TagToStringMap TagToValue;
typedef TagToValue::value_type TagToValueValueType;
void AddTag( Tag const & t );
void ClearTags();
// Work in progress do not use:
void AddPrivateTag( PrivateTag const & t );
void 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 ) 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 GetValues(Tag const &t) const;
Directory::FilenamesType GetOrderedValues(Tag const &t) 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 *,TagToValue, ltstr> MappingType;
typedef MappingType::const_iterator ConstIterator;
ConstIterator Begin() const { return Mappings.begin(); }
ConstIterator End() const { return Mappings.end(); }
MappingType const & GetMappings() const { return Mappings; }
TagToValue const & GetMapping(const char *filename) const;
const char *GetFilenameFromTagToValue(Tag const &t, const char *valueref) const;
Directory::FilenamesType GetAllFilenamesFromTagToValue(Tag const &t, const char *valueref) const;
// by a call to GetMapping()
TagToValue const & GetMappingFromTagToValue(Tag const &t, const char *value) const;
const char* GetValue(const char *filename, Tag const &t) const;
static SmartPointer<StrictScanner> New() { return new StrictScanner; }
protected:
void ProcessPublicTag(StringFilter &sf, const char *filename);
private:
// struct to store all uniq tags in ascending order:
typedef std::set< Tag > TagsType;
typedef std::set< PrivateTag > PrivateTagsType;
std::set< Tag > Tags;
std::set< PrivateTag > PrivateTags;
std::set< Tag > SkipTags;
ValuesType Values;
Directory::FilenamesType Filenames;
// Main struct that will hold all mapping:
MappingType Mappings;
double Progress;
};
//-----------------------------------------------------------------------------
inline std::ostream& operator<<(std::ostream &os, const StrictScanner &s)
{
s.Print( os );
return os;
}
} // end namespace gdcm
#endif //GDCMSTRICTSCANNER_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::StrictScanner::GetMappingFromTagToValue
TagToValue const & GetMappingFromTagToValue(Tag const &t, const char *value) const
See GetFilenameFromTagToValue(). This is simply GetFilenameFromTagToValue followed.
gdcm::StrictScanner::operator<<
friend std::ostream & operator<<(std::ostream &_os, const StrictScanner &s)
Definition gdcmStrictScanner.h:177
gdcm::StrictScanner::AddTag
void AddTag(Tag const &t)
Add a tag that will need to be read. Those are root level skip tags.
gdcm::StrictScanner::ClearSkipTags
void ClearSkipTags()
gdcm::StrictScanner::GetOrderedValues
Directory::FilenamesType GetOrderedValues(Tag const &t) const
gdcm::StrictScanner::GetValues
ValuesType const & GetValues() const
Get all the values found (in lexicographic order).
Definition gdcmStrictScanner.h:107
gdcm::StrictScanner::ProcessPublicTag
void ProcessPublicTag(StringFilter &sf, const char *filename)
gdcm::StrictScanner::MappingType
std::map< const char *, TagToValue, ltstr > MappingType
Definition gdcmStrictScanner.h:126
gdcm::StrictScanner::ClearTags
void ClearTags()
gdcm::StrictScanner::TagToValueValueType
TagToValue::value_type TagToValueValueType
Definition gdcmStrictScanner.h:71
gdcm::StrictScanner::IsKey
bool IsKey(const char *filename) const
gdcm::StrictScanner::GetAllFilenamesFromTagToValue
Directory::FilenamesType GetAllFilenamesFromTagToValue(Tag const &t, const char *valueref) const
gdcm::StrictScanner::Print
void Print(std::ostream &os) const override
Print result.
gdcm::StrictScanner::StrictScanner
StrictScanner()
Definition gdcmStrictScanner.h:59
gdcm::StrictScanner::ValuesType
std::set< std::string > ValuesType
Definition gdcmStrictScanner.h:104
gdcm::StrictScanner::GetMapping
TagToValue const & GetMapping(const char *filename) const
Get the std::map mapping filenames to value for file 'filename'.
gdcm::StrictScanner::AddSkipTag
void AddSkipTag(Tag const &t)
Add a tag that will need to be skipped. Those are root level skip tags.
gdcm::StrictScanner::New
static SmartPointer< StrictScanner > New()
for wrapped language: instantiate a reference counted object
Definition gdcmStrictScanner.h:157
gdcm::StrictScanner::~StrictScanner
~StrictScanner() override
gdcm::StrictScanner::GetFilenames
Directory::FilenamesType const & GetFilenames() const
Definition gdcmStrictScanner.h:87
gdcm::StrictScanner::GetFilenameFromTagToValue
const char * GetFilenameFromTagToValue(Tag const &t, const char *valueref) const
gdcm::StrictScanner::PrintTable
void PrintTable(std::ostream &os) const
gdcm::StrictScanner::TagToValue
std::map< Tag, const char * > TagToValue
Definition gdcmStrictScanner.h:68
gdcm::StrictScanner::AddPrivateTag
void AddPrivateTag(PrivateTag const &t)
gdcm::StrictScanner::GetValue
const char * GetValue(const char *filename, Tag const &t) const
gdcm::StrictScanner::GetKeys
Directory::FilenamesType GetKeys() const
gdcm::StrictScanner::Begin
ConstIterator Begin() const
Definition gdcmStrictScanner.h:128
gdcm::StrictScanner::GetMappings
MappingType const & GetMappings() const
Mappings are the mapping from a particular tag to the map, mapping filename to value:
Definition gdcmStrictScanner.h:132
gdcm::StrictScanner::GetValues
ValuesType GetValues(Tag const &t) const
Get all the values found (in lexicographic order) associated with Tag 't'.
gdcm::StrictScanner::Scan
bool Scan(Directory::FilenamesType const &filenames)
Start the scan !
gdcm::StrictScanner::ConstIterator
MappingType::const_iterator ConstIterator
Definition gdcmStrictScanner.h:127
gdcm::StrictScanner::End
ConstIterator End() const
Definition gdcmStrictScanner.h:129
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::StrictScanner::ltstr
Definition gdcmStrictScanner.h:119
gdcm::StrictScanner::ltstr::operator()
bool operator()(const char *s1, const char *s2) const
Definition gdcmStrictScanner.h:120