gdcmWriter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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();
00057
00059 void SetFileName(const char *filename) {
00060
00061
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
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 }
00098
00099 #endif //__gdcmWriter_h