OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CmdQuit Class Reference

#include <TestOsal.hh>

Inheritance diagram for CmdQuit:
Inheritance graph
Collaboration diagram for CmdQuit:
Collaboration graph

Public Member Functions

 CmdQuit ()
 
 CmdQuit (const CmdQuit &cmd)
 
virtual ~CmdQuit ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
virtual std::string helpText () const
 
- Public Member Functions inherited from CustomCommand
 CustomCommand (std::string name)
 
 CustomCommand (const CustomCommand &cmd)
 
virtual ~CustomCommand ()
 
std::string name () const
 
void setContext (InterpreterContext *context)
 
InterpreterContextcontext () const
 
void setInterpreter (ScriptInterpreter *si)
 
ScriptInterpreterinterpreter () const
 
bool checkArgumentCount (int argumentCount, int minimum, int maximum)
 
bool checkIntegerArgument (const DataObject &argument)
 
bool checkPositiveIntegerArgument (const DataObject &argument)
 
bool checkUnsignedIntegerArgument (const DataObject &argument)
 
bool checkDoubleArgument (const DataObject &argument)
 

Detailed Description

Command that quits the execution of the program.

Definition at line 94 of file TestOsal.hh.

Constructor & Destructor Documentation

◆ CmdQuit() [1/2]

CmdQuit::CmdQuit ( )

Constructor.

Definition at line 549 of file TestOsal.cc.

549 : CustomCommand("quit") {
550}

◆ CmdQuit() [2/2]

CmdQuit::CmdQuit ( const CmdQuit cmd)
explicit

Copy constructor.

Parameters
cmdCommand to be copied.

Definition at line 557 of file TestOsal.cc.

557 : CustomCommand(cmd) {
558}

◆ ~CmdQuit()

CmdQuit::~CmdQuit ( )
virtual

Destructor.

Definition at line 563 of file TestOsal.cc.

563 {
564}

Member Function Documentation

◆ execute()

bool CmdQuit::execute ( const std::vector< DataObject > &  arguments)
virtual

Executes the command.

The execution of the quit command will stop the program.

Parameters
argumentsArguments for the command.
Exceptions
NumberFormatExceptionIf DataObject conversion fails.
Returns
True if execution is successful, false otherwise.

Implements CustomCommand.

Definition at line 576 of file TestOsal.cc.

576 {
577 ScriptInterpreter* scriptInterp = interpreter();
578 OsalInterpreter* interp = dynamic_cast<OsalInterpreter*>(scriptInterp);
579 DataObject* result = new DataObject();
580 assert(interp != NULL);
581
582 if (arguments.size() != 1) {
583 result->setString("wrong number of arguments");
584 interp->setResult(result);
585 return false;
586 }
587
588 InterpreterContext& interpCont = interp->context();
589 TesterContext& testCont = *dynamic_cast<TesterContext*>(&interpCont);
590 testCont.stop();
591 result->setString("");
592 interp->setResult(result);
593 return true;
594}
#define assert(condition)
ScriptInterpreter * interpreter() const
virtual void setString(std::string value)
virtual void setResult(DataObject *result)
virtual InterpreterContext & context() const

References assert, SimpleScriptInterpreter::context(), CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), and TesterContext::stop().

Here is the call graph for this function:

◆ helpText()

string CmdQuit::helpText ( ) const
virtual

Returns the help text of the command.

Returns
The help text.

Implements CustomCommand.

Definition at line 602 of file TestOsal.cc.

602 {
603 return "exits the program";
604}

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