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;
00048 class GDCM_EXPORT Writer
00049 {
00050 public:
00051 Writer():F(new File),CheckFileMetaInformation(true) {
00052 Stream = NULL;
00053 Ofstream = NULL;
00054 }
00055 virtual ~Writer();
00056
00058 virtual bool Write();
00059
00061 void SetFileName(const char *filename) {
00062
00063
00064 if (Ofstream && Ofstream->is_open())
00065 {
00066 Ofstream->close();
00067 delete Ofstream;
00068 }
00069 Ofstream = new std::ofstream();
00070 Ofstream->open(filename, std::ios::out | std::ios::binary );
00071 assert( Ofstream->is_open() );
00072 assert( !Ofstream->fail() );
00073
00074 Stream = Ofstream;
00075 }
00077 void SetStream(std::ostream &output_stream) {
00078 Stream = &output_stream;
00079 }
00080
00082 void SetFile(const File& f) { F = f; }
00083 File &GetFile() { return *F; }
00084
00086 void SetCheckFileMetaInformation(bool b) { CheckFileMetaInformation = b; }
00087 void CheckFileMetaInformationOff() { CheckFileMetaInformation = false; }
00088 void CheckFileMetaInformationOn() { CheckFileMetaInformation = true; }
00089
00090 protected:
00091 std::ostream *Stream;
00092 std::ofstream *Ofstream;
00093
00094 private:
00095 SmartPointer<File> F;
00096 bool CheckFileMetaInformation;
00097 };
00098
00099 }
00100
00101 #endif //GDCMWRITER_H