File indexing completed on 2024-12-29 04:11:45
0001 /*************************************************************************** 0002 * * 0003 * Copyright : (C) 2010 The University of Toronto * 0004 * email : netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #ifndef KST_ASCII_SOURCE_CONFIG_H 0014 #define KST_ASCII_SOURCE_CONFIG_H 0015 0016 #include "namedparameter.h" 0017 0018 #include <QDomElement> 0019 #include <QDateTime> 0020 0021 0022 class AsciiSourceConfig { 0023 0024 // TODO translate keys? 0025 static const char Key_fileNamePattern[]; 0026 static const char Tag_fileNamePattern[]; 0027 static const char Key_delimiters[]; 0028 static const char Tag_delimiters[]; 0029 static const char Key_indexVector[]; 0030 static const char Tag_indexVector[]; 0031 static const char Key_indexInterpretation[]; 0032 static const char Tag_indexInterpretation[]; 0033 static const char Key_timeAsciiFormatString[]; 0034 static const char Tag_timeAsciiFormatString[]; 0035 static const char Key_columnType[]; 0036 static const char Tag_columnType[]; 0037 static const char Key_columnDelimiter[]; 0038 static const char Tag_columnDelimiter[]; 0039 static const char Key_columnWidth[]; 0040 static const char Tag_columnWidth[]; 0041 static const char Key_columnWidthIsConst[]; 0042 static const char Tag_columnWidthIsConst[]; 0043 static const char Key_dataLine[]; 0044 static const char Tag_dataLine[]; 0045 static const char Key_readFields[]; 0046 static const char Tag_readFields[]; 0047 static const char Key_readUnits[]; 0048 static const char Tag_readUnits[]; 0049 static const char Key_useDot[]; 0050 static const char Tag_useDot[]; 0051 static const char Key_fieldsLine[]; 0052 static const char Tag_fieldsLine[]; 0053 static const char Key_unitsLine[]; 0054 static const char Tag_unitsLine[]; 0055 static const char Key_limitFileBuffer[]; 0056 static const char Tag_limitFileBuffer[]; 0057 static const char Key_limitFileBufferSize[]; 0058 static const char Tag_limitFileBufferSize[]; 0059 static const char Key_useThreads[]; 0060 static const char Tag_useThreads[]; 0061 static const char Key_dataRate[]; 0062 static const char Tag_dataRate[]; 0063 static const char Key_offsetDateTime[]; 0064 static const char Tag_offsetDateTime[]; 0065 static const char Key_offsetFileDate[]; 0066 static const char Tag_offsetFileDate[]; 0067 static const char Key_offsetRelative[]; 0068 static const char Tag_offsetRelative[]; 0069 static const char Key_dateTimeOffset[]; 0070 static const char Tag_dateTimeOffset[]; 0071 static const char Key_relativeOffset[]; 0072 static const char Tag_relativeOffset[]; 0073 static const char Key_nanValue[]; 0074 static const char Tag_nanValue[]; 0075 static const char Key_updateType[]; 0076 static const char Tag_updateType[]; 0077 0078 public: 0079 AsciiSourceConfig(); 0080 0081 bool operator==(const AsciiSourceConfig&) const; 0082 bool operator!=(const AsciiSourceConfig& rhs) const; 0083 bool isUpdateNecessary(const AsciiSourceConfig& rhs) const; 0084 0085 void saveDefault(QSettings& cfg) const; 0086 void saveGroup(QSettings& cfg, const QString& fileName) const; 0087 const AsciiSourceConfig& readGroup(QSettings& cfg, const QString& fileName = QString()); 0088 0089 void save(QXmlStreamWriter& s); 0090 void parseProperties(QXmlStreamAttributes &properties); 0091 0092 void load(const QDomElement& e); 0093 0094 enum Interpretation { Unknown = 0, NoInterpretation, CTime, Seconds, FormattedTime, FixedRate, IntEnd = 0xffff }; 0095 enum ColumnType { Whitespace = 0, Fixed, Custom, ColEnd = 0xffff }; 0096 0097 NamedParameter<QString, Key_delimiters, Tag_delimiters> _delimiters; 0098 NamedParameter<QString, Key_indexVector, Tag_indexVector> _indexVector; 0099 NamedParameter<int, Key_indexInterpretation, Tag_indexInterpretation> _indexInterpretation; 0100 NamedParameter<QString, Key_timeAsciiFormatString, Tag_timeAsciiFormatString> _timeAsciiFormatString; 0101 NamedParameter<QString, Key_fileNamePattern, Tag_fileNamePattern> _fileNamePattern; 0102 NamedParameter<int, Key_columnType, Tag_columnType> _columnType; 0103 NamedParameter<QString, Key_columnDelimiter, Tag_columnDelimiter> _columnDelimiter; 0104 NamedParameter<int, Key_columnWidth, Tag_columnWidth> _columnWidth; 0105 NamedParameter<bool, Key_columnWidthIsConst, Tag_columnWidthIsConst> _columnWidthIsConst; 0106 NamedParameter<int, Key_dataLine, Tag_dataLine> _dataLine; 0107 NamedParameter<bool, Key_readFields, Tag_readFields> _readFields; 0108 NamedParameter<bool, Key_readUnits, Tag_readUnits> _readUnits; 0109 NamedParameter<int, Key_fieldsLine, Tag_fieldsLine> _fieldsLine; 0110 NamedParameter<int, Key_unitsLine, Tag_unitsLine> _unitsLine; 0111 NamedParameter<bool, Key_useDot, Tag_useDot> _useDot; 0112 NamedParameter<bool, Key_limitFileBuffer, Tag_limitFileBuffer> _limitFileBuffer; 0113 NamedParameter<qint64, Key_limitFileBufferSize, Tag_limitFileBufferSize> _limitFileBufferSize; 0114 NamedParameter<int, Key_useThreads, Tag_useThreads> _useThreads; 0115 NamedParameter<double, Key_dataRate, Tag_dataRate> _dataRate; 0116 NamedParameter<bool, Key_offsetDateTime, Tag_offsetDateTime> _offsetDateTime; 0117 NamedParameter<bool, Key_offsetFileDate, Tag_offsetFileDate> _offsetFileDate; 0118 NamedParameter<bool, Key_offsetRelative, Tag_offsetRelative> _offsetRelative; 0119 NamedParameter<QDateTime, Key_dateTimeOffset, Tag_dateTimeOffset> _dateTimeOffset; 0120 NamedParameter<double, Key_relativeOffset, Tag_relativeOffset> _relativeOffset; 0121 NamedParameter<int, Key_nanValue, Tag_nanValue> _nanValue; 0122 NamedParameter<int, Key_updateType, Tag_updateType> _updateType; 0123 0124 private: 0125 void save(QSettings& cfg) const; 0126 void read(QSettings& cfg); 0127 }; 0128 0129 Q_DECLARE_METATYPE(AsciiSourceConfig::Interpretation) 0130 Q_DECLARE_METATYPE(AsciiSourceConfig::ColumnType) 0131 0132 #endif