# 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-2010 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 {
    00054 class GDCM_EXPORT Reader
    00055 {
    00056 public:
    00057   Reader():F(new File){
    00058     Stream = NULL;
    00059     Ifstream = NULL;
    00060   }
    00061   virtual ~Reader();
    00062
    00064   virtual bool Read(); // Execute()
    00065
    00068   void SetFileName(const char *filename) {
    00069     if(Ifstream) delete Ifstream;
    00070     Ifstream = new std::ifstream();
    00071     Ifstream->open(filename, std::ios::binary);
    00072     Stream = Ifstream;
    00073   }
    00074
    00076   void SetStream(std::istream &input_stream) {
    00077     Stream = &input_stream;
    00078   }
    00079
    00081   const File &GetFile() const { return *F; }
    00082
    00084   File &GetFile() { return *F; }
    00085
    00087   void SetFile(File& file) { F = &file; }
    00088
    00090   bool ReadUpToTag(const Tag & tag, std::set<Tag> const & skiptags);
    00091
    00093   bool ReadSelectedTags(std::set<Tag> const & tags);
    00094
    00095 protected:
    00096   bool ReadPreamble();
    00097   bool ReadMetaInformation();
    00098   bool ReadDataSet();
    00099
    00100   SmartPointer<File> F;
    00101
    00102 private:
    00103   template <typename T_Caller>
    00104   bool InternalReadCommon(const T_Caller &caller);
    00105   TransferSyntax GuessTransferSyntax();
    00106   std::istream *Stream;
    00107   std::ifstream *Ifstream;
    00108 };
    00109
    00116 } // end namespace gdcm
    00117
    00118
    00119 #endif //GDCMREADER_H