gdcmReader.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 GDCMREADER_H
#define GDCMREADER_H
#include "gdcmFile.h"
#include <fstream>
namespace gdcm_ns
{
class StreamImageReader;
class GDCM_EXPORT Reader
{
public:
Reader();
virtual ~Reader();
virtual bool Read(); // Execute()
void SetFileName(const char *filename_native);
void SetStream(std::istream &input_stream) {
Stream = &input_stream;
}
const File &GetFile() const { return *F; }
File &GetFile() { return *F; }
void SetFile(File& file) { F = &file; }
bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags = std::set<Tag>() );
bool ReadSelectedTags(std::set<Tag> const & tags, bool readvalues = true);
bool ReadSelectedPrivateTags(std::set<PrivateTag> const & ptags, bool readvalues = true);
bool CanRead() const;
size_t GetStreamCurrentPosition() const;
protected:
bool ReadPreamble();
bool ReadMetaInformation();
bool ReadDataSet();
SmartPointer<File> F;
friend class StreamImageReader; //need to be friended to be able to grab the GetStreamPtr
//this function is added for the StreamImageReader, which needs to read
//up to the pixel data and then stops right before reading the pixel data.
//it's used to get that position, so that reading can continue
//apace once the read function is called.
//so, this function gets the stream directly, and then allows for position information
//from the tellg function, and allows for stream/pointer manip in order
//to read the pixel data. Note, of course, that reading pixel elements
//will still have to be subject to endianness swaps, if necessary.
std::istream* GetStreamPtr() const { return Stream; }
private:
template <typename T_Caller>
bool InternalReadCommon(const T_Caller &caller);
TransferSyntax GuessTransferSyntax();
std::istream *Stream;
std::ifstream *Ifstream;
// prevent copy/move to avoid 2 ifstream leak
Reader(const Reader &) = delete;
Reader &operator=(const Reader &) = delete;
Reader(const Reader &&) = delete;
Reader &operator=(const Reader &&) = delete;
};
} // end namespace gdcm_ns
#endif //GDCMREADER_H
gdcm::File
a DICOM File
Definition gdcmFile.h:34
gdcm::Reader
Reader ala DOM (Document Object Model).
Definition gdcmReader.h:54
gdcm::Reader::StreamImageReader
friend class StreamImageReader
Definition gdcmReader.h:105
gdcm::Reader::GetFile
const File & GetFile() const
Set/Get File.
Definition gdcmReader.h:72
gdcm::Reader::Reader
Reader()
gdcm::Reader::CanRead
bool CanRead() const
gdcm::Reader::SetStream
void SetStream(std::istream &input_stream)
Set the open-ed stream directly.
Definition gdcmReader.h:67
gdcm::Reader::~Reader
virtual ~Reader()
gdcm::Reader::ReadDataSet
bool ReadDataSet()
gdcm::Reader::ReadSelectedTags
bool ReadSelectedTags(std::set< Tag > const &tags, bool readvalues=true)
Will only read the specified selected tags.
gdcm::Reader::Read
virtual bool Read()
Main function to read a file.
gdcm::Reader::ReadPreamble
bool ReadPreamble()
gdcm::Reader::SetFileName
void SetFileName(const char *filename_native)
gdcm::Reader::GetStreamCurrentPosition
size_t GetStreamCurrentPosition() const
gdcm::Reader::SetFile
void SetFile(File &file)
Set/Get File.
Definition gdcmReader.h:78
gdcm::Reader::F
SmartPointer< File > F
Definition gdcmReader.h:103
gdcm::Reader::ReadSelectedPrivateTags
bool ReadSelectedPrivateTags(std::set< PrivateTag > const &ptags, bool readvalues=true)
Will only read the specified selected private tags.
gdcm::Reader::ReadUpToTag
bool ReadUpToTag(const Tag &tag, std::set< Tag > const &skiptags=std::set< Tag >())
gdcm::Reader::ReadMetaInformation
bool ReadMetaInformation()
gdcm::Reader::GetFile
File & GetFile()
Set/Get File.
Definition gdcmReader.h:75
gdcm::Reader::GetStreamPtr
std::istream * GetStreamPtr() const
Definition gdcmReader.h:115
gdcm::SmartPointer
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
gdcm::Tag
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
gdcm::TransferSyntax
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
gdcmFile.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34