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 : 2010-03-20 00022 ** Authors : 00023 ** Marc Wathelet (LGIT, Grenoble, France) 00024 ** 00025 ***************************************************************************/ 00026 00027 #ifndef CUSTOMFILEFORMATS_H 00028 #define CUSTOMFILEFORMATS_H 00029 00030 #include <QGpCoreTools.h> 00031 00032 #include "GeopsyCoreDLLExport.h" 00033 #include "SignalFileFormat.h" 00034 00035 namespace GeopsyCore { 00036 00037 class AbstractFileFormat; 00038 00039 class GEOPSYCORE_EXPORT CustomFileFormats : public XMLClass 00040 { 00041 public: 00042 CustomFileFormats(); 00043 ~CustomFileFormats(); 00044 00045 void setFormats(const CustomFileFormats& o, 00046 SignalFileFormat::Format id=SignalFileFormat::Unknown); 00047 00048 virtual const QString& xml_tagName() const {return xmlCustomFileFormatsTag;} 00049 static const QString xmlCustomFileFormatsTag; 00050 00051 void save(); 00052 00053 int count() const {return _formats.count();} 00054 QString name(int index) const; 00055 00056 SignalFileFormat fromExtension(const QString& ext) const; 00057 SignalFileFormat fromContent(const QString& fileName) const; 00058 SignalFileFormat fromString(const QString& f) const; 00059 QList<SignalFileFormat> list() const; 00060 bool contains(const QString& name) const; 00061 00062 void clear(SignalFileFormat::Format id=SignalFileFormat::Unknown); 00063 void add(AbstractFileFormat * format); 00064 void remove(int index); 00065 AbstractFileFormat * format(int index) {return _formats.at(index);} 00066 protected: 00067 virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const; 00068 virtual XMLMember xml_member(XML_MEMBER_ARGS); 00069 private: 00070 QList<AbstractFileFormat *> _formats; 00071 }; 00072 00073 } // namespace GeopsyCore 00074 00075 #endif // CUSTOMFILEFORMATS_H