trikRuntime
trikScriptRunner::TrikScriptRunner Class Reference

General wrapper for other executors (such as Python, JavaScript) More...

#include <trikScriptRunner.h>

Inheritance diagram for trikScriptRunner::TrikScriptRunner:
Collaboration diagram for trikScriptRunner::TrikScriptRunner:

Public Slots

void run (const QString &script, const QString &fileName="") override
 See corresponding TrikScriptRunnerInterface method. More...
 
void runDirectCommand (const QString &command) override
 See corresponding TrikScriptRunnerInterface method. More...
 
void abort () override
 See corresponding TrikScriptRunnerInterface method. More...
 
void abortAll ()
 Aborts all scripts from all engines. More...
 
void brickBeep () override
 See corresponding TrikScriptRunnerInterface method. More...
 
- Public Slots inherited from trikScriptRunner::TrikScriptRunnerInterface
virtual void run (const QString &script, const QString &fileName="")=0
 Executes given script asynchronously. More...
 
virtual void runDirectCommand (const QString &command)=0
 Executes given script as direct command, so it will use existing script execution environment (or create one if needed) and will not reset execution state before or after execution. More...
 
virtual void abort ()=0
 Aborts script execution. More...
 
virtual void brickBeep ()=0
 Plays "beep" sound. More...
 

Public Member Functions

 TrikScriptRunner (trikControl::BrickInterface &brick, trikNetwork::MailboxInterface *mailbox)
 Constructor. More...
 
 ~TrikScriptRunner () override
 
void setDefaultRunner (ScriptType t)
 Choose default runner type (Python or JavaScript) More...
 
void registerUserFunction (const QString &name, QScriptEngine::FunctionSignature function) override
 Registers given C++ function as callable from script, with given name. More...
 
void addCustomEngineInitStep (const std::function< void(QScriptEngine *)> &step) override
 Adds custom initialization steps when creating script engine (useful when used from outside of the TrikRuntime). More...
 
bool wasError () override
 Get status of last direct command/script. More...
 
QStringList knownMethodNamesFor (ScriptType t)
 Create completion list for interpreted language. More...
 
QStringList knownMethodNames () const override
 See corresponding TrikScriptRunnerInterface method. More...
 
void run (const QString &script, ScriptType stype, const QString &fileName="")
 Execute script with a corresponding engine of specified type. More...
 

Additional Inherited Members

- Signals inherited from trikScriptRunner::TrikScriptRunnerInterface
void completed (const QString &error, int scriptId)
 Emitted when current script completes execution (for event-driven mode it means that script requested to quit or was aborted). More...
 
void startedScript (const QString &fileName, int scriptId)
 Emitted when new script from file started. More...
 
void startedDirectScript (int scriptId)
 Emitted when new direct script started. More...
 
void sendMessage (const QString &text)
 Emitted when a message must be sent to a desktop. More...
 

Detailed Description

General wrapper for other executors (such as Python, JavaScript)

Constructor & Destructor Documentation

TrikScriptRunner::TrikScriptRunner ( trikControl::BrickInterface brick,
trikNetwork::MailboxInterface mailbox 
)

Constructor.

Parameters
brick- reference to trikControl::Brick instance.
mailbox- mailbox object used to communicate with other robots.
TrikScriptRunner::~TrikScriptRunner ( )
override

Member Function Documentation

void TrikScriptRunner::abort ( )
overrideslot

See corresponding TrikScriptRunnerInterface method.

void TrikScriptRunner::abortAll ( )
slot

Aborts all scripts from all engines.

void TrikScriptRunner::addCustomEngineInitStep ( const std::function< void(QScriptEngine *)> &  step)
overridevirtual

Adds custom initialization steps when creating script engine (useful when used from outside of the TrikRuntime).

Implements trikScriptRunner::TrikScriptRunnerInterface.

void TrikScriptRunner::brickBeep ( )
overrideslot

See corresponding TrikScriptRunnerInterface method.

QStringList TrikScriptRunner::knownMethodNames ( ) const
overridevirtual
QStringList TrikScriptRunner::knownMethodNamesFor ( ScriptType  t)

Create completion list for interpreted language.

void TrikScriptRunner::registerUserFunction ( const QString &  name,
QScriptEngine::FunctionSignature  function 
)
overridevirtual

Registers given C++ function as callable from script, with given name.

Implements trikScriptRunner::TrikScriptRunnerInterface.

void TrikScriptRunner::run ( const QString &  script,
ScriptType  stype,
const QString &  fileName = "" 
)

Execute script with a corresponding engine of specified type.

void TrikScriptRunner::run ( const QString &  script,
const QString &  fileName = "" 
)
overrideslot

See corresponding TrikScriptRunnerInterface method.

void TrikScriptRunner::runDirectCommand ( const QString &  command)
overrideslot

See corresponding TrikScriptRunnerInterface method.

void TrikScriptRunner::setDefaultRunner ( ScriptType  t)

Choose default runner type (Python or JavaScript)

bool TrikScriptRunner::wasError ( )
overridevirtual

Get status of last direct command/script.

Implements trikScriptRunner::TrikScriptRunnerInterface.


The documentation for this class was generated from the following files: