GDCM 2.0.17

gdcmWriter.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 GDCMWRITER_H
00017 #define GDCMWRITER_H
00018 
00019 #include "gdcmFile.h"
00020 
00021 namespace gdcm
00022 {
00023 
00024 class FileMetaInformation;
00049 class GDCM_EXPORT Writer
00050 {
00051 public:
00052   Writer();
00053   virtual ~Writer();
00054 
00056   virtual bool Write(); // Execute()
00057 
00059   void SetFileName(const char *filename) {
00060     //std::cerr << "Stream: " << filename << std::endl;
00061     //std::cerr << "Ofstream: " << Ofstream << std::endl;
00062     if (Ofstream && Ofstream->is_open())
00063       {
00064       Ofstream->close();
00065       delete Ofstream;
00066       }
00067     Ofstream = new std::ofstream();
00068     Ofstream->open(filename, std::ios::out | std::ios::binary );
00069     assert( Ofstream->is_open() );
00070     assert( !Ofstream->fail() );
00071     //std::cerr << Stream.is_open() << std::endl;
00072     Stream = Ofstream;
00073   }
00075   void SetStream(std::ostream &output_stream) {
00076     Stream = &output_stream;
00077   }
00078 
00080   void SetFile(const File& f) { F = f; }
00081   File &GetFile() { return *F; }
00082 
00084   void SetCheckFileMetaInformation(bool b) { CheckFileMetaInformation = b; }
00085   void CheckFileMetaInformationOff() { CheckFileMetaInformation = false; }
00086   void CheckFileMetaInformationOn() { CheckFileMetaInformation = true; }
00087 
00088 protected:
00089   friend class StreamImageWriter;
00090   //this function is added for the StreamImageWriter, which needs to write
00091   //up to the pixel data and then stops right before writing the pixel data.
00092   //after that, for the raw codec at least, zeros are written for the length of the data
00093   std::ostream* GetStreamPtr() const { return Stream; }
00094 
00095 protected:
00096   std::ostream *Stream;
00097   std::ofstream *Ofstream;
00098 
00099 private:
00100   SmartPointer<File> F;
00101   bool CheckFileMetaInformation;
00102 };
00103 
00104 } // end namespace gdcm
00105 
00106 #endif //GDCMWRITER_H

Generated on Tue Feb 1 2011 23:59:13 for GDCM by doxygen 1.7.3
SourceForge.net Logo