GDCM  2.2.0
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 
00015 #ifndef GDCMREADER_H
00016 #define GDCMREADER_H
00017 
00018 #include "gdcmFile.h"
00019 
00020 
00021 #include <fstream>
00022 
00023 namespace gdcm
00024 {
00025   class StreamImageReader;
00055 class GDCM_EXPORT Reader
00056 {
00057 public:
00058   Reader():F(new File){
00059     Stream = NULL;
00060     Ifstream = NULL;
00061   }
00062   virtual ~Reader();
00063 
00065   virtual bool Read(); // Execute()
00066 
00069   void SetFileName(const char *filename_native);
00070 
00072   void SetStream(std::istream &input_stream) {
00073     Stream = &input_stream;
00074   }
00075 
00077   const File &GetFile() const { return *F; }
00078 
00080   File &GetFile() { return *F; }
00081 
00083   void SetFile(File& file) { F = &file; }
00084 
00087   bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags = std::set<Tag>() );
00088 
00090   bool ReadSelectedTags(std::set<Tag> const & tags);
00091 
00094   bool CanRead() const;
00095 
00096 protected:
00097   bool ReadPreamble();
00098   bool ReadMetaInformation();
00099   bool ReadDataSet();
00100 
00101   SmartPointer<File> F;
00102 
00103   friend class StreamImageReader; //need to be friended to be able to grab the GetStreamPtr
00104 
00105   //this function is added for the StreamImageReader, which needs to read
00106   //up to the pixel data and then stops right before reading the pixel data.
00107   //it's used to get that position, so that reading can continue
00108   //apace once the read function is called.
00109   //so, this function gets the stream directly, and then allows for position information
00110   //from the tellg function, and allows for stream/pointer manip in order
00111   //to read the pixel data.  Note, of course, that reading pixel elements
00112   //will still have to be subject to endianness swaps, if necessary.
00113   std::istream* GetStreamPtr() const { return Stream; }
00114 
00115 private:
00116   template <typename T_Caller>
00117   bool InternalReadCommon(const T_Caller &caller);
00118   TransferSyntax GuessTransferSyntax();
00119   std::istream *Stream;
00120   std::ifstream *Ifstream;
00121 };
00122 
00129 } // end namespace gdcm
00130 
00131 
00132 #endif //GDCMREADER_H

Generated on Fri Mar 30 2012 12:44:05 for GDCM by doxygen 1.8.0
SourceForge.net Logo