GDCM  2.2.3
gdcmReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program: GDCM (Grassroots DICOM). A DICOM library
00004 
00005   Copyright (c) 2006-2011 Mathieu Malaterre
00006   All rights reserved.
00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 #ifndef GDCMREADER_H
00015 #define GDCMREADER_H
00016 
00017 #include "gdcmFile.h"
00018 
00019 #include <fstream>
00020 
00021 namespace gdcm
00022 {
00023   class StreamImageReader;
00053 class GDCM_EXPORT Reader
00054 {
00055 public:
00056   Reader():F(new File){
00057     Stream = NULL;
00058     Ifstream = NULL;
00059   }
00060   virtual ~Reader();
00061 
00063   virtual bool Read(); // Execute()
00064 
00067   void SetFileName(const char *filename_native);
00068 
00070   void SetStream(std::istream &input_stream) {
00071     Stream = &input_stream;
00072   }
00073 
00075   const File &GetFile() const { return *F; }
00076 
00078   File &GetFile() { return *F; }
00079 
00081   void SetFile(File& file) { F = &file; }
00082 
00085   bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags = std::set<Tag>() );
00086 
00088   bool ReadSelectedTags(std::set<Tag> const & tags);
00089 
00092   bool CanRead() const;
00093 
00094 protected:
00095   bool ReadPreamble();
00096   bool ReadMetaInformation();
00097   bool ReadDataSet();
00098 
00099   SmartPointer<File> F;
00100 
00101   friend class StreamImageReader; //need to be friended to be able to grab the GetStreamPtr
00102 
00103   //this function is added for the StreamImageReader, which needs to read
00104   //up to the pixel data and then stops right before reading the pixel data.
00105   //it's used to get that position, so that reading can continue
00106   //apace once the read function is called.
00107   //so, this function gets the stream directly, and then allows for position information
00108   //from the tellg function, and allows for stream/pointer manip in order
00109   //to read the pixel data.  Note, of course, that reading pixel elements
00110   //will still have to be subject to endianness swaps, if necessary.
00111   std::istream* GetStreamPtr() const { return Stream; }
00112 
00113 private:
00114   template <typename T_Caller>
00115   bool InternalReadCommon(const T_Caller &caller);
00116   TransferSyntax GuessTransferSyntax();
00117   std::istream *Stream;
00118   std::ifstream *Ifstream;
00119 };
00120 
00127 } // end namespace gdcm
00128 
00129 
00130 #endif //GDCMREADER_H

Generated on Thu Nov 28 2013 07:02:50 for GDCM by doxygen 1.7.6.1
SourceForge.net Logo