OpenASIP  2.0
Public Member Functions | List of all members
ExpressionScript Class Reference

#include <ExpressionScript.hh>

Inheritance diagram for ExpressionScript:
Inheritance graph
Collaboration diagram for ExpressionScript:
Collaboration graph

Public Member Functions

 ExpressionScript (ScriptInterpreter *interpreter, std::string scriptLine)
 
 ExpressionScript (ScriptInterpreter *interpreter, std::vector< std::string > &script)
 
virtual ~ExpressionScript ()
 
bool resultChanged ()
 
- Public Member Functions inherited from Script
 Script (ScriptInterpreter *interpreter, std::string scriptLine)
 
 Script (ScriptInterpreter *interpreter, std::vector< std::string > &script)
 
virtual ~Script ()
 
virtual DataObject execute ()
 
DataObject lastResult ()
 
virtual std::vector< std::string > script () const
 

Additional Inherited Members

- Protected Attributes inherited from Script
ScriptInterpreterinterpreter_
 Interpreter executing the commands. More...
 

Detailed Description

ExpressionScript contains a script which changes can be inspected.

Definition at line 44 of file ExpressionScript.hh.

Constructor & Destructor Documentation

◆ ExpressionScript() [1/2]

ExpressionScript::ExpressionScript ( ScriptInterpreter interpreter,
std::string  scriptLine 
)

Constructor.

Parameters
interpreterThe interpreter for the script.
scriptLineA line of script.

Definition at line 45 of file ExpressionScript.cc.

47  : Script(interpreter, scriptLine) {
48 }

◆ ExpressionScript() [2/2]

ExpressionScript::ExpressionScript ( ScriptInterpreter interpreter,
std::vector< std::string > &  script 
)

Constructor.

Parameters
interpreterThe interpreter for the script.
scriptThe script.

Definition at line 56 of file ExpressionScript.cc.

58  : Script(interpreter, script) {
59 }

◆ ~ExpressionScript()

ExpressionScript::~ExpressionScript ( )
virtual

Destructor.

Definition at line 64 of file ExpressionScript.cc.

64  {
65 }

Member Function Documentation

◆ resultChanged()

bool ExpressionScript::resultChanged ( )

Returns true, if the result of the script has changed.

Returns
True, if the result of the script has changed, otherwise false.
Exceptions
ScriptExecutionFailureIf the execution of the script fails.
NumberFormatExceptionIf DataObject operation fails.

Definition at line 75 of file ExpressionScript.cc.

75  {
76  DataObject obj;
77  try {
78  obj = lastResult();
79  } catch (const InvalidData& i) {
80  return false;
81  }
82 
83  DataObject exec = execute();
84 
86 
87  if (obj != exec) {
88  return true;
89  }
90  return false;
91 }

References Script::execute(), Script::interpreter_, Script::lastResult(), and ScriptInterpreter::setResult().

Referenced by Watch::isTriggered().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
Script::lastResult
DataObject lastResult()
Script::execute
virtual DataObject execute()
Definition: Script.cc:82
Script::script
virtual std::vector< std::string > script() const
Definition: Script.cc:106
DataObject
Definition: DataObject.hh:50
InvalidData
Definition: Exception.hh:149
Script::interpreter_
ScriptInterpreter * interpreter_
Interpreter executing the commands.
Definition: Script.hh:58
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
Script::Script
Script(ScriptInterpreter *interpreter, std::string scriptLine)
Definition: Script.cc:47