GDCM  2.2.0
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 
15 #ifndef GDCMREADER_H
16 #define GDCMREADER_H
17 
18 #include "gdcmFile.h"
19 
20 
21 #include <fstream>
22 
23 namespace gdcm
24 {
25  class StreamImageReader;
56 {
57 public:
58  Reader():F(new File){
59  Stream = NULL;
60  Ifstream = NULL;
61  }
62  virtual ~Reader();
63 
65  virtual bool Read(); // Execute()
66 
69  void SetFileName(const char *filename_native);
70 
72  void SetStream(std::istream &input_stream) {
73  Stream = &input_stream;
74  }
75 
77  const File &GetFile() const { return *F; }
78 
80  File &GetFile() { return *F; }
81 
83  void SetFile(File& file) { F = &file; }
84 
87  bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags = std::set<Tag>() );
88 
90  bool ReadSelectedTags(std::set<Tag> const & tags);
91 
94  bool CanRead() const;
95 
96 protected:
97  bool ReadPreamble();
98  bool ReadMetaInformation();
99  bool ReadDataSet();
100 
102 
103  friend class StreamImageReader; //need to be friended to be able to grab the GetStreamPtr
104 
105  //this function is added for the StreamImageReader, which needs to read
106  //up to the pixel data and then stops right before reading the pixel data.
107  //it's used to get that position, so that reading can continue
108  //apace once the read function is called.
109  //so, this function gets the stream directly, and then allows for position information
110  //from the tellg function, and allows for stream/pointer manip in order
111  //to read the pixel data. Note, of course, that reading pixel elements
112  //will still have to be subject to endianness swaps, if necessary.
113  std::istream* GetStreamPtr() const { return Stream; }
114 
115 private:
116  template <typename T_Caller>
117  bool InternalReadCommon(const T_Caller &caller);
118  TransferSyntax GuessTransferSyntax();
119  std::istream *Stream;
120  std::ifstream *Ifstream;
121 };
122 
129 } // end namespace gdcm
130 
131 
132 #endif //GDCMREADER_H

Generated on Wed Jun 13 2012 20:40:37 for GDCM by doxygen 1.8.1
SourceForge.net Logo