DinverCore/ReportWriter.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of DinverCore.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  See http://www.geopsy.org for more information.
00019 **
00020 **  Created : 2005-12-20
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef REPORTWRITER_H
00028 #define REPORTWRITER_H
00029 
00030 #define REPORT_FILE_TAG "DINVER05"
00031 #define REPORT_BLOCK_TAG "MBLK"
00032 
00033 #define REPORT_CURRENT_VERSION 1
00034 
00035 #include <QGpCoreTools.h>
00036 #include "DinverCoreDLLExport.h"
00037 
00038 namespace DinverCore {
00039 
00040 class Parameter;
00041 class RealSpace;
00042 
00043 class DINVERCORE_EXPORT ReportWriter
00044 {
00045   TRANSLATIONS("ReportWriter")
00046 public:
00047   ReportWriter(QString fileName) : _f(fileName) {_blockOffset=0;}
00048   ~ReportWriter() {}
00049 
00050   enum Action {Ask, Overwrite, Append};
00051   static bool initReport(const QString& fileName, const QString& title, Action action);
00052 
00053   bool open();
00054   void close() {_f.close();}
00055 
00056   QDataStream& stream() {return _s;}
00057   bool isOpen() {return _f.isOpen();}
00058   void addModel(double misfit, uint paramChecksum, int nd, Parameter ** model);
00059   void addModel(double misfit, uint paramChecksum, const RealSpace& parameterSpace);
00060   inline void userBlockHeader(const char * tag, int version);
00061   static void setCurrentOffset(QDataStream& s, qint64 tableOffset);
00062   static void setEmptyOffset(QDataStream& s, qint64 tableOffset);
00063   static void remove(const QString& fileName);
00064 private:
00065   QFile _f;
00066   QDataStream _s;
00067 
00068   qint64 _blockOffset;
00069 };
00070 
00071 inline void ReportWriter::userBlockHeader(const char * tag, int version)
00072 {
00073   TRACE;
00074   _s.writeRawData(tag,4);
00075   _s << version;
00076 }
00077 
00078 } // namespace DinverCore
00079 
00080 #endif // REPORTWRITER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines