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

Generated on Tue Dec 6 2011 20:36:27 for GDCM by doxygen 1.7.5.1
SourceForge.net Logo