File indexing completed on 2024-12-22 04:17:19
0001 /*************************************************************************** 0002 dataststring.h - a string from a data source 0003 ------------------- 0004 begin : September, 2008 0005 copyright : (C) 2008 by cbn 0006 email : netterfield@astro.utoronto.ca 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef DATASTRING_H 0019 #define DATASTRING_H 0020 0021 #include "kst_export.h" 0022 #include "dataprimitive.h" 0023 #include "string_kst.h" 0024 0025 class QXmlStreamWriter; 0026 0027 namespace Kst { 0028 0029 /**A class for handling data strings for kst. 0030 *@author cbn 0031 */ 0032 0033 /** A string which gets its value from a data file. */ 0034 class KSTCORE_EXPORT DataString : public String, public DataPrimitive 0035 { 0036 Q_OBJECT 0037 0038 protected: 0039 DataString(ObjectStore *store); 0040 friend class ObjectStore; 0041 0042 virtual QString _automaticDescriptiveName() const; 0043 0044 /** Update the string */ 0045 virtual qint64 minInputSerial() const; 0046 virtual qint64 maxInputSerialOfLastChange() const; 0047 0048 public: 0049 virtual ~DataString(); 0050 virtual void internalUpdate(); 0051 0052 struct KSTCORE_EXPORT ReadInfo 0053 { 0054 ReadInfo(QString* s, int f=0) : value(s), frame(f) {} 0055 QString* value; 0056 int frame; // used for fields that have <string>s as a function of index 0057 }; 0058 0059 struct KSTCORE_EXPORT DataInfo 0060 { 0061 DataInfo(); 0062 int frameCount; // used for fields that have <string>s as a function of index 0063 }; 0064 0065 0066 void reload(); 0067 0068 virtual void reset(); 0069 0070 virtual const QString& typeString() const; 0071 static const QString staticTypeString; 0072 static const QString staticTypeTag; 0073 0074 /** change the properties of a DataString */ 0075 void change(DataSourcePtr file, const QString &field, int frame); 0076 void changeFile(DataSourcePtr file); 0077 0078 // used for fields that have <string>s as a function of index 0079 int frame() const {return _frame;} 0080 void setFrame(int f) {_frame = f;} 0081 bool isStream(); 0082 0083 /** Save data string to kst session file */ 0084 virtual void save(QXmlStreamWriter &s); 0085 0086 virtual QString descriptionTip() const; 0087 0088 virtual QString propertyString() const; 0089 0090 bool isValid() const; 0091 0092 virtual ScriptInterface* createScriptInterface(); 0093 0094 int fileLength() const; 0095 0096 private: 0097 /** make a copy of the DataString */ 0098 virtual PrimitivePtr makeDuplicate() const; 0099 virtual bool checkValidity(const DataSourcePtr& ds) const; 0100 0101 int _frame; 0102 0103 }; 0104 0105 typedef SharedPtr<DataString> DataStringPtr; 0106 typedef ObjectList<DataString> DataStringList; 0107 0108 } 0109 0110 #endif 0111 // vim: ts=2 sw=2 et