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-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 __gdcmWriter_h
00017 #define __gdcmWriter_h
00018 
00019 #include "gdcmFile.h"
00020 
00021 namespace gdcm
00022 {
00023 
00024 class FileMetaInformation;
00046 class GDCM_EXPORT Writer
00047 {
00048 public:
00049   Writer():F(new File),CheckFileMetaInformation(true) {
00050     Stream = NULL;
00051     Ofstream = NULL;
00052   }
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   std::ostream *Stream;
00090   std::ofstream *Ofstream;
00091 
00092 private:
00093   SmartPointer<File> F;
00094   bool CheckFileMetaInformation;
00095 };
00096 
00097 } // end namespace gdcm
00098 
00099 #endif //__gdcmWriter_h

Generated on Wed Jun 30 13:49:14 2010 for GDCM by doxygen 1.6.3
SourceForge.net Logo