# gdcmReader.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2009 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00009
    00010      This software is distributed WITHOUT ANY WARRANTY; without even
    00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00012      PURPOSE.  See the above copyright notice for more information.
    00013
    00014 =========================================================================*/
    00015
    00016 #ifndef __gdcmReader_h
    00017 #define __gdcmReader_h
    00018
    00019 #include "gdcmFile.h"
    00020
    00021 #include <fstream>
    00022
    00023 namespace gdcm
    00024 {
    00053 class GDCM_EXPORT Reader
    00054 {
    00055 public:
    00056   Reader():F(new File){
    00057     Stream = NULL;
    00058     Ifstream = NULL;
    00059   }
    00060   virtual ~Reader();
    00061
    00062   virtual bool Read(); // Execute()
    00063   void SetFileName(const char *filename) {
    00064     if(Ifstream) delete Ifstream;
    00065     Ifstream = new std::ifstream();
    00066     Ifstream->open(filename, std::ios::binary);
    00067     Stream = Ifstream;
    00068   }
    00069   void SetStream(std::istream &input_stream) {
    00070     Stream = &input_stream;
    00071   }
    00072
    00073   const File &GetFile() const { return *F; }
    00074   File &GetFile() { return *F; }
    00075   void SetFile(File& file) { F = &file; }
    00076
    00077   // Will read only up to Tag 'tag'
    00078   bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags);
    00079
    00080 protected:
    00081   bool ReadPreamble();
    00082   bool ReadMetaInformation();
    00083   bool ReadDataSet();
    00084
    00085   SmartPointer<File> F;
    00086
    00087 private:
    00088   TransferSyntax GuessTransferSyntax();
    00089   std::istream *Stream;
    00090   std::ifstream *Ifstream;
    00091 };
    00092
    00099 } // end namespace gdcm
    00100
    00101
    00102 #endif //__gdcmReader_h