1 /*************************************************************************** 2 datastscalar.h - a scalar from a data source 3 ------------------- 4 begin : September, 2008 5 copyright : (C) 2008 by cbn 6 email : netterfield@astro.utoronto.ca 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef DATASCALAR_H 19 #define DATASCALAR_H 20 21 #include "kst_export.h" 22 #include "dataprimitive.h" 23 #include "scalar.h" 24 25 class QXmlStreamWriter; 26 27 namespace Kst { 28 29 /**A class for handling data scalars for kst. 30 *@author cbn 31 */ 32 33 /** A scalar which gets its value from a data file. */ 34 class KSTCORE_EXPORT DataScalar : public Scalar, public DataPrimitive 35 { 36 Q_OBJECT 37 38 protected: 39 DataScalar(ObjectStore *store); 40 friend class ObjectStore; 41 42 virtual QString _automaticDescriptiveName() const; 43 44 /** Update the scalar.*/ 45 virtual qint64 minInputSerial() const; 46 virtual qint64 maxInputSerialOfLastChange() const; 47 48 49 public: 50 virtual ~DataScalar(); 51 52 struct ReadInfo { ReadInfoReadInfo53 ReadInfo(double* d) : value(d) {} 54 double* value; 55 }; 56 57 struct DataInfo { 58 }; 59 60 virtual void internalUpdate(); 61 virtual const QString& typeString() const; 62 static const QString staticTypeString; 63 static const QString staticTypeTag; 64 65 /** change the properties of a DataScalar */ 66 void change(DataSourcePtr file, const QString &field); 67 void changeFile(DataSourcePtr file); 68 69 /** Save scalar information */ 70 virtual void save(QXmlStreamWriter &s); 71 72 virtual QString descriptionTip() const; 73 74 virtual QString propertyString() const; 75 bool isValid() const; 76 77 virtual void reset(); 78 void reload(); 79 80 virtual ScriptInterface* createScriptInterface(); 81 82 private: 83 /** make a copy of the DataScalar */ 84 virtual PrimitivePtr makeDuplicate() const; 85 virtual bool checkValidity(const DataSourcePtr& ds) const; 86 }; 87 88 typedef SharedPtr<DataScalar> DataScalarPtr; 89 typedef ObjectList<DataScalar> DataScalarList; 90 91 } 92 93 #endif 94 // vim: ts=2 sw=2 et 95