00001 #ifndef MatlabWRITER_H 00002 #define MatlabWRITER_H 00003 00004 #include "SundanceDefs.h" 00005 #include "FieldWriterBase.h" 00006 #include "TSFSmartPtr.h" 00007 #include "CellSet.h" 00008 #include <fstream> 00009 00010 namespace Sundance 00011 { 00012 00013 using namespace TSF; 00014 using std::string; 00015 using std::ostream; 00016 00017 /** */ 00018 class MatlabWriter : public FieldWriterBase 00019 { 00020 public: 00021 /** open a Matlab writer that will write to a file */ 00022 MatlabWriter(const string& filename); 00023 00024 /** open a Matlab writer that will write to a file */ 00025 MatlabWriter(const string& filename, const CellSet& cellSet); 00026 00027 /** open a Matlab writer that will write to standard out */ 00028 MatlabWriter(); 00029 00030 virtual ~MatlabWriter(); 00031 00032 /** write a field, tagging it with the given string as a name */ 00033 virtual void writeField(const string& name, 00034 const Expr& expr) const ; 00035 00036 /** write a mesh in Matlab format */ 00037 virtual void writeMesh(const Mesh& mesh) const ; 00038 00039 /** write a comment */ 00040 virtual void writeCommentLine(const string& line) const ; 00041 private: 00042 00043 00044 mutable ostream* os_; 00045 TSFArray<CellSet> cellSet_; 00046 bool deleteStream_; 00047 mutable bool meshHasBeenWritten_; 00048 }; 00049 } 00050 00051 #endif 00052