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

#include <HelpCommand.hh>

Inheritance diagram for HelpCommand:
Inheritance graph
Collaboration diagram for HelpCommand:
Collaboration graph

Public Member Functions

 HelpCommand ()
 
virtual ~HelpCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
virtual std::string helpText () const
 
- Public Member Functions inherited from SimControlLanguageCommand
 SimControlLanguageCommand (const std::string &name)
 
virtual ~SimControlLanguageCommand ()
 
SimulatorFrontendsimulatorFrontend ()
 
const SimulatorFrontendsimulatorFrontendConst ()
 
virtual void printNextInstruction ()
 
virtual void printStopInformation ()
 
virtual void printStopReasons ()
 
virtual bool printBreakpointInfo (unsigned int breakpointHandle)
 
virtual void printSimulationTime ()
 
virtual std::ostream & outputStream ()
 
bool checkSimulationInitialized ()
 
bool checkSimulationNotAlreadyRunning ()
 
bool checkSimulationStopped ()
 
bool checkSimulationEnded ()
 
bool checkProgramLoaded ()
 
bool checkMachineLoaded ()
 
InstructionAddress parseInstructionAddressExpression (const std::string &expression)
 
TTAProgram::Address parseDataAddressExpression (const std::string &expression)
 
bool parseBreakpoint (const std::vector< DataObject > &arguments, Breakpoint &target)
 
bool askConditionFromUser (TclConditionScript &target)
 
bool askExpressionFromUser (ExpressionScript &target)
 
bool verifyBreakpointHandles (const std::vector< DataObject > &arguments, std::size_t startIndex=1)
 
void setErrorMessage (const TCEString &errorMsg)
 
- 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)
 

Private Member Functions

HelpCommandoperator= (const HelpCommand &)
 Assignment not allowed. More...
 
 HelpCommand (const HelpCommand &cmd)
 Copying not allowed. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SimControlLanguageCommand
bool setMemoryAddress (const std::string &addressString, std::string &addressSpaceName, std::size_t &memoryAddress)
 
bool setMemoryPointer (MemorySystem::MemoryPtr &memory, const std::string &addressSpaceName)
 

Detailed Description

Implementation of the "help" command of the Simulator Control Language.

Definition at line 45 of file HelpCommand.hh.

Constructor & Destructor Documentation

◆ HelpCommand() [1/2]

HelpCommand::HelpCommand ( )

Constructor.

Definition at line 47 of file HelpCommand.cc.

47  : SimControlLanguageCommand("help") {
48 }

◆ ~HelpCommand()

HelpCommand::~HelpCommand ( )
virtual

Destructor.

Definition at line 53 of file HelpCommand.cc.

53  {
54 }

◆ HelpCommand() [2/2]

HelpCommand::HelpCommand ( const HelpCommand cmd)
private

Copying not allowed.

Member Function Documentation

◆ execute()

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

Executes the help command.

Prints a help message briefly describing command command. If no command is given, prints general help and a listing of available commands.

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

Implements CustomCommand.

Definition at line 67 of file HelpCommand.cc.

67  {
68  if (!checkArgumentCount(arguments.size() - 1, 0, 1)) {
69  return false;
70  }
71 
72  if (arguments.size() == 1) {
75  << std::endl << std::endl;
76 
79 
80  vector<string> names = interpreter()->customCommandsSortedByName();
81  for (size_t i = 0; i < names.size(); i++) {
82  outputStream() << names[i] + " ";
83  }
84  outputStream() << std::endl;
85  return true;
86  }
87 
88  DataObject* obj = new DataObject();
89  string cmdName = arguments[1].stringValue();
90  CustomCommand* command = interpreter()->customCommand(cmdName);
91  if (command == NULL) {
92  obj->setString(
95  interpreter()->setResult(obj);
96  return false;
97  } else {
98  outputStream() << command->helpText() << std::endl;
99  return true;
100  }
101 
102  return true;
103 }

References CustomCommand::checkArgumentCount(), ScriptInterpreter::customCommand(), ScriptInterpreter::customCommandsSortedByName(), CustomCommand::helpText(), CustomCommand::interpreter(), SimControlLanguageCommand::outputStream(), ScriptInterpreter::setResult(), DataObject::setString(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_CLI_ONLINE_HELP, Texts::TXT_INTERP_HELP_COMMANDS_AVAILABLE, and Texts::TXT_UNKNOWN_COMMAND.

Here is the call graph for this function:

◆ helpText()

string HelpCommand::helpText ( ) const
virtual

Returns help text.

Returns
Help text.
Todo:
TextGenerator.

Implements CustomCommand.

Definition at line 112 of file HelpCommand.cc.

112  {
115 }

References Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_HELP_HELP.

Here is the call graph for this function:

◆ operator=()

HelpCommand& HelpCommand::operator= ( const HelpCommand )
private

Assignment not allowed.


The documentation for this class was generated from the following files:
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
SimControlLanguageCommand::outputStream
virtual std::ostream & outputStream()
Definition: SimControlLanguageCommand.cc:351
Texts::TXT_UNKNOWN_COMMAND
@ TXT_UNKNOWN_COMMAND
Definition: TextGenerator.hh:64
DataObject
Definition: DataObject.hh:50
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
SimControlLanguageCommand::SimControlLanguageCommand
SimControlLanguageCommand(const std::string &name)
Definition: SimControlLanguageCommand.cc:67
Texts::TXT_CLI_ONLINE_HELP
@ TXT_CLI_ONLINE_HELP
Online help text.
Definition: SimulatorTextGenerator.hh:109
ScriptInterpreter::customCommandsSortedByName
std::vector< std::string > customCommandsSortedByName()
Definition: ScriptInterpreter.cc:342
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
CustomCommand
Definition: CustomCommand.hh:54
ScriptInterpreter::customCommand
virtual CustomCommand * customCommand(const std::string &commandName)
Definition: ScriptInterpreter.cc:110
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
Texts::TXT_INTERP_HELP_COMMANDS_AVAILABLE
@ TXT_INTERP_HELP_COMMANDS_AVAILABLE
Description of the execution trace setting.
Definition: SimulatorTextGenerator.hh:160
DataObject::setString
virtual void setString(std::string value)
Definition: DataObject.cc:130
CustomCommand::helpText
virtual std::string helpText() const =0
Texts::TXT_INTERP_HELP_HELP
@ TXT_INTERP_HELP_HELP
Help text for command "help" of the CLI.
Definition: SimulatorTextGenerator.hh:81