GDCM  2.4.4
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 
21 namespace gdcm
22 {
23  class StreamImageReader;
54 {
55 public:
56  Reader():F(new File){
57  Stream = NULL;
58  Ifstream = NULL;
59  }
60  virtual ~Reader();
61 
63  virtual bool Read(); // Execute()
64 
67  void SetFileName(const char *filename_native);
68 
70  void SetStream(std::istream &input_stream) {
71  Stream = &input_stream;
72  }
73 
75  const File &GetFile() const { return *F; }
76 
78  File &GetFile() { return *F; }
79 
81  void SetFile(File& file) { F = &file; }
82 
85  bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags = std::set<Tag>() );
86 
88  bool ReadSelectedTags(std::set<Tag> const & tags, bool readvalues = true);
89 
91  bool ReadSelectedPrivateTags(std::set<PrivateTag> const & ptags, bool readvalues = true);
92 
95  bool CanRead() const;
96 
99  size_t GetStreamCurrentPosition() const;
100 
101 protected:
102  bool ReadPreamble();
103  bool ReadMetaInformation();
104  bool ReadDataSet();
105 
107 
108  friend class StreamImageReader; //need to be friended to be able to grab the GetStreamPtr
109 
110  //this function is added for the StreamImageReader, which needs to read
111  //up to the pixel data and then stops right before reading the pixel data.
112  //it's used to get that position, so that reading can continue
113  //apace once the read function is called.
114  //so, this function gets the stream directly, and then allows for position information
115  //from the tellg function, and allows for stream/pointer manip in order
116  //to read the pixel data. Note, of course, that reading pixel elements
117  //will still have to be subject to endianness swaps, if necessary.
118  std::istream* GetStreamPtr() const { return Stream; }
119 
120 private:
121  template <typename T_Caller>
122  bool InternalReadCommon(const T_Caller &caller);
123  TransferSyntax GuessTransferSyntax();
124  std::istream *Stream;
125  std::ifstream *Ifstream;
126 };
127 
134 } // end namespace gdcm
135 
136 
137 #endif //GDCMREADER_H
Reader ala DOM (Document Object Model)
Definition: gdcmReader.h:53
void SetFile(File &file)
Set/Get File.
Definition: gdcmReader.h:81
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
SmartPointer< File > F
Definition: gdcmReader.h:106
File & GetFile()
Set/Get File.
Definition: gdcmReader.h:78
Reader()
Definition: gdcmReader.h:56
StreamImageReader.
Definition: gdcmStreamImageReader.h:38
Class to manipulate Transfer Syntax.
Definition: gdcmTransferSyntax.h:39
std::istream * GetStreamPtr() const
Definition: gdcmReader.h:118
Class for Smart Pointer.
Definition: gdcmObject.h:26
a DICOM File See PS 3.10 File: A File is an ordered string of zero or more bytes, where the first byt...
Definition: gdcmFile.h:33
const File & GetFile() const
Set/Get File.
Definition: gdcmReader.h:75
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element). Basically an uint32_t which...
Definition: gdcmTag.h:38
Definition: gdcmASN1.h:20
void SetStream(std::istream &input_stream)
Set the open-ed stream directly.
Definition: gdcmReader.h:70

Generated on Tue Sep 30 2014 16:05:23 for GDCM by doxygen 1.8.8
SourceForge.net Logo