File indexing completed on 2024-12-22 04:17:24
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2014 Barth Netterfield * 0004 * 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 VECTORSCRIPTINTERFACE_H 0014 #define VECTORSCRIPTINTERFACE_H 0015 0016 #include <QString> 0017 0018 #include "scriptinterface.h" 0019 #include "datavector.h" 0020 #include "generatedvector.h" 0021 #include "editablevector.h" 0022 0023 namespace Kst { 0024 0025 /*******************/ 0026 class KSTCORE_EXPORT VectorCommonSI : public ScriptInterface 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 QString value(QString& command); 0032 QString length(QString&); 0033 QString min(QString&); 0034 QString max(QString&); 0035 QString mean(QString&); 0036 QString store(QString &command); 0037 0038 protected: 0039 VectorPtr _vector; 0040 QString noSuchFn(QString&) {return ""; } 0041 0042 }; 0043 0044 0045 /*******************/ 0046 class VectorSI; 0047 typedef QString (VectorSI::*VectorInterfaceMemberFn)(QString& command); 0048 0049 class KSTCORE_EXPORT VectorSI : public VectorCommonSI 0050 { 0051 Q_OBJECT 0052 public: 0053 explicit VectorSI(VectorPtr it); 0054 QString doCommand(QString); 0055 bool isValid(); 0056 QByteArray endEditUpdate(); 0057 0058 static ScriptInterface* newVector(ObjectStore *); 0059 0060 private: 0061 QMap<QString,VectorInterfaceMemberFn> _fnMap; 0062 }; 0063 0064 0065 /*******************/ 0066 class DataVectorSI; 0067 typedef QString (DataVectorSI::*DataVectorInterfaceMemberFn)(QString& command); 0068 0069 class KSTCORE_EXPORT DataVectorSI : public VectorCommonSI 0070 { 0071 Q_OBJECT 0072 public: 0073 explicit DataVectorSI(DataVectorPtr it); 0074 QString doCommand(QString); 0075 bool isValid(); 0076 QByteArray endEditUpdate(); 0077 0078 static ScriptInterface* newVector(ObjectStore *store); 0079 0080 QString change(QString &command); 0081 QString changeFrames(QString &command); 0082 QString field(QString &command); 0083 QString filename(QString &command); 0084 QString start(QString &command); 0085 QString NFrames(QString &command); 0086 QString skip(QString &command); 0087 QString boxcarFirst(QString &command); 0088 0089 private: 0090 DataVectorPtr _datavector; 0091 QMap<QString,DataVectorInterfaceMemberFn> _fnMap; 0092 }; 0093 0094 /*******************/ 0095 class GeneratedVectorSI; 0096 typedef QString (GeneratedVectorSI::*GeneratedVectorInterfaceMemberFn)(QString& command); 0097 0098 class KSTCORE_EXPORT GeneratedVectorSI : public VectorCommonSI 0099 { 0100 Q_OBJECT 0101 public: 0102 explicit GeneratedVectorSI(GeneratedVectorPtr it); 0103 QString doCommand(QString); 0104 bool isValid(); 0105 QByteArray endEditUpdate(); 0106 0107 static ScriptInterface* newVector(ObjectStore *store); 0108 0109 QString change(QString &command); 0110 0111 private: 0112 GeneratedVectorPtr _generatedvector; 0113 QMap<QString,GeneratedVectorInterfaceMemberFn> _fnMap; 0114 }; 0115 0116 0117 /*******************/ 0118 class EditableVectorSI; 0119 typedef QString (EditableVectorSI::*EditableVectorInterfaceMemberFn)(QString& command); 0120 0121 class KSTCORE_EXPORT EditableVectorSI : public VectorCommonSI 0122 { 0123 Q_OBJECT 0124 public: 0125 explicit EditableVectorSI(EditableVectorPtr it); 0126 QString doCommand(QString); 0127 bool isValid(); 0128 QByteArray endEditUpdate(); 0129 0130 static ScriptInterface* newVector(ObjectStore *); 0131 0132 QString load(QString &command); 0133 QString setValue(QString &command); 0134 QString resize(QString &command); 0135 QString zero(QString &); 0136 0137 private: 0138 EditableVectorPtr _editablevector; 0139 QMap<QString,EditableVectorInterfaceMemberFn> _fnMap; 0140 0141 }; 0142 0143 } 0144 #endif // VECTORSCRIPTINTERFACE_H