OpenASIP  2.0
Public Member Functions | List of all members
InfoBussesCommand Class Reference
Inheritance diagram for InfoBussesCommand:
Inheritance graph
Collaboration diagram for InfoBussesCommand:
Collaboration graph

Public Member Functions

 InfoBussesCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoBussesCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
- Public Member Functions inherited from SimControlLanguageSubCommand
 SimControlLanguageSubCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~SimControlLanguageSubCommand ()
 
virtual SimControlLanguageCommandparent ()
 

Detailed Description

Implementation of "info busses".

Definition at line 413 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoBussesCommand()

InfoBussesCommand::InfoBussesCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 418 of file InfoCommand.cc.

418  :
419  SimControlLanguageSubCommand(parentCommand) {
420  }

◆ ~InfoBussesCommand()

virtual InfoBussesCommand::~InfoBussesCommand ( )
inlinevirtual

Destructor.

Definition at line 425 of file InfoCommand.cc.

425  {
426  }

Member Function Documentation

◆ execute()

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

Executes the "info busses" command.

"info busses" prints information of the busses of the machine.

Parameters
argumentsNo arguments should be given.
Returns
Always true.

Implements SimControlLanguageSubCommand.

Definition at line 436 of file InfoCommand.cc.

436  {
437 
438  const int argumentCount = arguments.size() - 2;
439 
440  if (!parent().checkArgumentCount(argumentCount, 0, 1)) {
441  return false;
442  }
443  const TTAMachine::Machine& mach =
445 
446  if (argumentCount == 0) {
448  mach.busNavigator();
449  std::string result = "";
450  bool isFirst = true;
451  for (int i = 0; i < nav.count(); ++i) {
452  if (!isFirst)
453  result += "\n";
454  TTAMachine::Bus* bus = nav.item(i);
455  assert(bus != NULL);
456  result += bus->name() + ": ";
457  bool isFirstSegment = true;
458  for (int j = 0; j < bus->segmentCount(); ++j) {
459  if (!isFirstSegment)
460  result += " ";
461  result += bus->segment(j)->name();
462  isFirstSegment = false;
463  }
464  isFirst = false;
465  }
466  parent().interpreter()->setResult(result);
467  return true;
468  } else if (argumentCount == 1) {
470  mach.busNavigator();
471  const std::string busName = arguments.at(2).stringValue();
472 
473  if (!nav.hasItem(busName)) {
476  Texts::TXT_BUS_NOT_FOUND).str());
477  return false;
478  }
479 
480  TTAMachine::Bus* bus = nav.item(busName);
481  assert(bus != NULL);
482  std::string result = "";
483  result += bus->name() + ": ";
484  bool isFirstSegment = true;
485  for (int j = 0; j < bus->segmentCount(); ++j) {
486  if (!isFirstSegment)
487  result += " ";
488  result += bus->segment(j)->name();
489  isFirstSegment = false;
490  }
491  parent().interpreter()->setResult(result);
492  return true;
493  }
494  return false;
495  }

References assert, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), CustomCommand::interpreter(), TTAMachine::Machine::Navigator< ComponentType >::item(), SimulatorFrontend::machine(), TTAMachine::Segment::name(), TTAMachine::Component::name(), SimControlLanguageSubCommand::parent(), TTAMachine::Bus::segment(), TTAMachine::Bus::segmentCount(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_BUS_NOT_FOUND.

Here is the call graph for this function:

The documentation for this class was generated from the following file:
SimControlLanguageSubCommand::parent
virtual SimControlLanguageCommand & parent()
Definition: SimControlLanguageCommand.cc:842
SimControlLanguageSubCommand::SimControlLanguageSubCommand
SimControlLanguageSubCommand(SimControlLanguageCommand &parentCommand)
Definition: SimControlLanguageCommand.cc:824
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
TTAMachine::Bus
Definition: Bus.hh:53
TTAMachine::Machine::Navigator::count
int count() const
TTAMachine::Bus::segment
virtual Segment * segment(int index) const
Definition: Bus.cc:329
assert
#define assert(condition)
Definition: Application.hh:86
Texts::TXT_BUS_NOT_FOUND
@ TXT_BUS_NOT_FOUND
Definition: SimulatorTextGenerator.hh:57
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
TTAMachine::Segment::name
std::string name() const
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::Bus::segmentCount
virtual int segmentCount() const
Definition: Bus.cc:385
TTAMachine::Machine
Definition: Machine.hh:73