GeopsyCore/AsciiSignalFormat.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyCore.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2009-08-14
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef ASCIISIGNALFORMAT_H
00029 #define ASCIISIGNALFORMAT_H
00030 
00031 #include "AbstractFileFormat.h"
00032 #include "AsciiSignalFormatRule.h"
00033 #include "AsciiSignalFormatComponent.h"
00034 #include "GeopsyCoreDLLExport.h"
00035 
00036 namespace GeopsyCore {
00037 
00038 class GEOPSYCORE_EXPORT AsciiSignalFormat : public AbstractFileFormat
00039 {
00040   TRANSLATIONS("AsciiSignalFormat")
00041 public:
00042   AsciiSignalFormat();
00043   AsciiSignalFormat(const AsciiSignalFormat& o);
00044 
00045   void operator=(const AsciiSignalFormat& o);
00046 
00047   virtual const QString& xml_tagName() const {return xmlAsciiSignalFormatTag;}
00048   static const QString xmlAsciiSignalFormatTag;
00049 
00050   enum HeaderType {NoHeader, FixedHeader, HeaderPattern, EndHeaderPattern};
00051 
00052   void setHeaderType(HeaderType t) {_headerType=t;}
00053   void setHeaderType(const QString& t);
00054   HeaderType headerType() const {return _headerType;}
00055   QString headerTypeString() const;
00056 
00057   const QString& headerPattern() const {return _headerPattern;}
00058   void setHeaderPattern(const QString& h) {_headerPattern=h;}
00059 
00060   int headerLineCount() const {return _headerLineCount;}
00061   void setHeaderLineCount(int h) {_headerLineCount=h;}
00062 
00063   const QString& timeFormat() const {return _timeFormat;}
00064   void setTimeFormat(const QString& t) {_timeFormat=t;}
00065 
00066   void insertComponent(int index, const AsciiSignalFormatComponent& c) {_components.insert(index, c);}
00067   void removeComponent(int index) {_components.remove(index);}
00068   int componentCount() const {return _components.count();}
00069   const AsciiSignalFormatComponent& component(int index) const {return _components.at(index);}
00070   AsciiSignalFormatComponent& component(int index) {return _components[index];}
00071 
00072   void insertRule(int index, const AsciiSignalFormatRule& r) {_rules.insert(index, r);}
00073   void removeRule(int index) {_rules.remove(index);}
00074   int ruleCount() const {return _rules.count();}
00075   const AsciiSignalFormatRule& rule(int index) const {return _rules.at(index);}
00076   AsciiSignalFormatRule& rule(int index) {return _rules[index];}
00077 
00078   QString header(QTextStream& s, int& lineNumber, QAtomicInt * terminate=0);
00079   bool parseHeader(const QString& headerText, QAtomicInt * terminate=0);
00080   double t0() const;
00081   QDateTime timeReference() const;
00082   void assign(Signal * sig);
00083 
00084   virtual SignalFileFormat::Format format() const {return SignalFileFormat::Ascii;}
00085   virtual int complexity() const;
00086   virtual bool isValid(const QString& fileName) const;
00087 protected:
00088   virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00089   virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00090   virtual XMLMember xml_member(XML_MEMBER_ARGS);
00091   virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00092 private:
00093   HeaderType _headerType;
00094   QString _headerPattern;
00095   int _headerLineCount;
00096 
00097   QString _timeFormat;
00098   QVector<AsciiSignalFormatComponent> _components;
00099   QVector<AsciiSignalFormatRule> _rules;
00100 };
00101 
00102 } // namespace GeopsyCore
00103 
00104 #endif // ASCIISIGNALFORMAT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines