32 #ifndef ARNSCRIPTJOB_HPP 33 #define ARNSCRIPTJOB_HPP 46 class ArnScriptWatchdog;
54 class ArnScriptJobB :
public QObject
60 explicit ArnScriptJobB(
int id, QObject* parent = arnNullptr);
61 bool evaluateScript(
const QByteArray&
script,
const QString& idName);
62 bool evaluateScriptFile(
const QString& fileName);
69 ArnScriptWatchdog* watchdog()
const;
71 void setSleepState(
bool isSleepState =
true);
72 void setWatchDogTime(
int time);
74 void setWatchDog(
int time = -1,
bool persist =
true);
75 void setPollTime(
int time);
77 bool isSleepState()
const;
78 bool isRunable()
const;
79 bool isStopped()
const;
80 bool isRunning()
const;
81 void errorLog(
const QString& txt);
84 void scheduleRequest(
int callerId);
85 void quitRequest(
int callerId);
86 void timeoutAbort(
int id);
94 void doTimeoutAbort();
97 virtual void customEvent( QEvent* ev);
99 void installInterface(
const QString&
id, QObject* obj);
119 bool _quitInProgress;
121 ArnScriptWatchdog* _watchdog;
125 class ArnScriptWatchdog :
public QObject
129 ArnScriptWatchdog(
ARN_JSENGINE* jsEngine, QObject* parent = arnNullptr);
130 ~ArnScriptWatchdog();
135 void setTime(
int timeMs);
141 void setTimeNow(
int timeMs);
156 Q_PROPERTY(
bool sleepState WRITE setSleepState READ isSleepState )
157 Q_PROPERTY(
bool running READ isRunning )
158 Q_PROPERTY(
int watchDog WRITE setWatchDog READ watchDogTime )
159 Q_PROPERTY(
int poll WRITE setPollTime READ pollTime )
160 Q_PROPERTY( QString name READ name )
162 explicit
ArnScriptJob(
int id, QObject* parent = arnNullptr);
168 void setWatchDogTime(
int time) {ArnScriptJobB::setWatchDogTime( time);}
169 void yield() {ArnScriptJobB::yield();}
170 void quit() {ArnScriptJobB::quit();}
171 void errorLog(
const QString& txt) {ArnScriptJobB::errorLog( txt);}
181 virtual bool installExtension(
const QString&
id,
ARN_JSENGINE& engine,
186 static bool setupInterface(
const QString&
id, QObject* interface,
ARN_JSENGINE& engine);
197 QString name()
const;
198 void setName(
const QString& name);
199 void addInterface(
const QString&
id);
200 void addInterfaceList(
const QStringList& interfaceList);
201 QByteArray script()
const;
202 void loadScriptFile(
const QString& fileName);
203 QVariant config(
const char* name)
const;
204 bool setConfig(
const char* name,
const QVariant& value);
205 void addConfig( QObject* obj);
207 void setThreaded(
bool isThreaded);
211 void scriptChanged(
int id);
212 void errorText(
const QString& txt);
215 void setScript(
const QByteArray& script);
219 static QAtomicInt _idCount;
223 QStringList _interfaceList;
228 mutable QMutex _mutex;
232 #endif // ARNSCRIPTJOB_HPP
QByteArray script() const
bool setConfig(const char *name, const QVariant &value)
void errorText(const QString &txt)
Must be thread-safe as subclassed.
void errorLog(const QString &txt)
Is thread-safe (except doSetupJob)
Interface class to be normally used, is also Script Job interface.
void addConfig(QObject *obj)
#define ARNLIBSHARED_EXPORT