GDCM: gdcmReader.h Source File

GDCM 3.2.5

gdcmReader.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 GDCMREADER_H
15#define GDCMREADER_H
16
17#include "gdcmFile.h"
18
19#include <fstream>
20
21namespace gdcm_ns
22{
23 class StreamImageReader;
53 class GDCM_EXPORT Reader
54{
55public:
56 Reader();
57 virtual ~Reader();
58
60 virtual bool Read(); // Execute()
61
64 void SetFileName(const char *filename_native);
65
67 void SetStream(std::istream &input_stream) {
68 Stream = &input_stream;
69 }
70
72 const File &GetFile() const { return *F; }
73
75 File &GetFile() { return *F; }
76
78 void SetFile(File& file) { F = &file; }
79
82 bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags = std::set<Tag>() );
83
85 bool ReadSelectedTags(std::set<Tag> const & tags, bool readvalues = true);
86
88 bool ReadSelectedPrivateTags(std::set<PrivateTag> const & ptags, bool readvalues = true);
89
92 bool CanRead() const;
93
96 size_t GetStreamCurrentPosition() const;
97
98protected:
99 bool ReadPreamble();
100 bool ReadMetaInformation();
101 bool ReadDataSet();
102
103 SmartPointer<File> F;
104
105 friend class StreamImageReader; //need to be friended to be able to grab the GetStreamPtr
106
107 //this function is added for the StreamImageReader, which needs to read
108 //up to the pixel data and then stops right before reading the pixel data.
109 //it's used to get that position, so that reading can continue
110 //apace once the read function is called.
111 //so, this function gets the stream directly, and then allows for position information
112 //from the tellg function, and allows for stream/pointer manip in order
113 //to read the pixel data. Note, of course, that reading pixel elements
114 //will still have to be subject to endianness swaps, if necessary.
115 std::istream* GetStreamPtr() const { return Stream; }
116
117private:
118 template <typename T_Caller>
119 bool InternalReadCommon(const T_Caller &caller);
120 TransferSyntax GuessTransferSyntax();
121 std::istream *Stream;
122 std::ifstream *Ifstream;
123
124 // prevent copy/move to avoid 2 ifstream leak
125 Reader(const Reader &) = delete;
126 Reader &operator=(const Reader &) = delete;
127 Reader(const Reader &&) = delete;
128 Reader &operator=(const Reader &&) = delete;
129};
130
136
137} // end namespace gdcm_ns
138
139
140#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