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

#include <ConditionScript.hh>

Inheritance diagram for ConditionScript:
Inheritance graph
Collaboration diagram for ConditionScript:
Collaboration graph

Public Member Functions

 ConditionScript (ScriptInterpreter *interpreter, std::string scriptLine)
 
 ConditionScript (ScriptInterpreter *interpreter, std::vector< std::string > &script)
 
virtual ~ConditionScript ()
 
virtual bool conditionOk ()
 
virtual ConditionScriptcopy () const
 
- 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

Class that contains a script that defines a condition for some action.

Definition at line 45 of file ConditionScript.hh.

Constructor & Destructor Documentation

◆ ConditionScript() [1/2]

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

Constructor.

Parameters
interpreterInterpreter for the script.
scriptLineA line of script.

Definition at line 46 of file ConditionScript.cc.

48  : Script(interpreter, scriptLine) {
49 }

Referenced by copy().

◆ ConditionScript() [2/2]

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

Constructor.

Parameters
interpreterInterpreter for the script.
scriptThe script.

Definition at line 57 of file ConditionScript.cc.

59  : Script(interpreter, script) {
60 }

◆ ~ConditionScript()

ConditionScript::~ConditionScript ( )
virtual

Destructor.

Definition at line 65 of file ConditionScript.cc.

65  {
66 }

Member Function Documentation

◆ conditionOk()

bool ConditionScript::conditionOk ( )
virtual

Tests if condition is true of false.

Returns
True, if condition is true, false otherwise.
Exceptions
NumberFormatExceptionIf DataObject operation fails.
ScriptExecutionFailureIf script execution fails.

Definition at line 76 of file ConditionScript.cc.

76  {
77  vector<string> scripts = script();
78  if (scripts.size() == 1 && scripts[0] == "") {
79  return true;
80  }
81 
82  DataObject obj = execute();
83  if (obj.stringValue() == "0") {
85  return false;
86  }
88  return true;
89 }

References Script::execute(), Script::interpreter_, Script::script(), ScriptInterpreter::setResult(), and DataObject::stringValue().

Referenced by StopPoint::isConditionOK().

Here is the call graph for this function:

◆ copy()

ConditionScript * ConditionScript::copy ( ) const
virtual

Copies the condition script.

Allows dynamically bound copy.

Returns
a new instance which is identical to this.

Reimplemented in TclConditionScript.

Definition at line 99 of file ConditionScript.cc.

99  {
100  return new ConditionScript(*this);
101 }

References ConditionScript().

Referenced by Breakpoint::copy(), Watch::copy(), and StopPoint::setCondition().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
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
DataObject::stringValue
virtual std::string stringValue() const
Definition: DataObject.cc:344
ConditionScript::ConditionScript
ConditionScript(ScriptInterpreter *interpreter, std::string scriptLine)
Definition: ConditionScript.cc:46
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