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

#include <ProximExecuteFileCmd.hh>

Inheritance diagram for ProximExecuteFileCmd:
Inheritance graph
Collaboration diagram for ProximExecuteFileCmd:
Collaboration graph

Public Member Functions

 ProximExecuteFileCmd ()
 
virtual ~ProximExecuteFileCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual ProximExecuteFileCmdcreate () const
 
virtual std::string icon () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Private Attributes

SimulatorFrontendsimulator_
 

Detailed Description

Command for executing commands from a log file.

Definition at line 43 of file ProximExecuteFileCmd.hh.

Constructor & Destructor Documentation

◆ ProximExecuteFileCmd()

ProximExecuteFileCmd::ProximExecuteFileCmd ( )

The Constructor.

Definition at line 49 of file ProximExecuteFileCmd.cc.

References ProximToolbox::frontend(), and simulator_.

Referenced by create().

Here is the call graph for this function:

◆ ~ProximExecuteFileCmd()

ProximExecuteFileCmd::~ProximExecuteFileCmd ( )
virtual

The Destructor.

Definition at line 58 of file ProximExecuteFileCmd.cc.

58  {
59 }

Member Function Documentation

◆ create()

ProximExecuteFileCmd * ProximExecuteFileCmd::create ( ) const
virtual

Creates and returns a new isntance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 126 of file ProximExecuteFileCmd.cc.

126  {
127  return new ProximExecuteFileCmd();
128 }

References ProximExecuteFileCmd().

Here is the call graph for this function:

◆ Do()

bool ProximExecuteFileCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 66 of file ProximExecuteFileCmd.cc.

66  {
67  wxString message = _T("Choose a file.");
68  wxString wildcard = _T("Command history logs (*.log)|*.log|All files|*.*");
69  wxFileDialog dialog(
70  parentWindow(), message, _T(""), _T(""), wildcard, wxOPEN);
71 
72  if (dialog.ShowModal() == wxID_CANCEL) {
73  return false;
74  }
75 
76  std::string filename = WxConversion::toString(dialog.GetPath());
77  std::ifstream file(filename.c_str());
78 
79  if (file.bad()) {
80  wxString message = _T("Error opening file '");
81  message.Append(dialog.GetPath());
82  message.Append(_T("'."));
83  ErrorDialog dialog(parentWindow(), message);
84  dialog.ShowModal();
85  return false;
86  }
87 
89 
90  while (!file.eof()) {
91  std::string command;
92  getline(file, command);
93  lineReader.input(command);
94  }
95 
96  return true;
97 }

References ProximLineReader::input(), ProximToolbox::lineReader(), GUICommand::parentWindow(), and WxConversion::toString().

Here is the call graph for this function:

◆ icon()

std::string ProximExecuteFileCmd::icon ( ) const
virtual

Returns full path to the command icon file.

Returns
Full path to the command icon file.

Implements GUICommand.

Definition at line 106 of file ProximExecuteFileCmd.cc.

106  {
107  return "exec.png";
108 }

◆ id()

int ProximExecuteFileCmd::id ( ) const
virtual

Returns ID of this command.

Implements GUICommand.

Definition at line 115 of file ProximExecuteFileCmd.cc.

115  {
117 }

References ProximConstants::COMMAND_EXECUTE_FILE.

◆ isEnabled()

bool ProximExecuteFileCmd::isEnabled ( )
virtual

Returns true if the command is enabled, false otherwise.

Returns
True if the simulation is initialized or stopped.

Implements GUICommand.

Definition at line 137 of file ProximExecuteFileCmd.cc.

137  {
138 
139  if (simulator_ != NULL) {
140  return true;
141  } else {
142  return false;
143  }
144 }

References simulator_.

Member Data Documentation

◆ simulator_

SimulatorFrontend* ProximExecuteFileCmd::simulator_
private

Definition at line 54 of file ProximExecuteFileCmd.hh.

Referenced by isEnabled(), and ProximExecuteFileCmd().


The documentation for this class was generated from the following files:
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
ProximLineReader::input
void input(std::string command)
Definition: ProximLineReader.cc:131
ProximConstants::COMMAND_EXECUTE_FILE
@ COMMAND_EXECUTE_FILE
Definition: ProximConstants.hh:70
ErrorDialog
Definition: ErrorDialog.hh:42
ProximExecuteFileCmd::ProximExecuteFileCmd
ProximExecuteFileCmd()
Definition: ProximExecuteFileCmd.cc:49
ProximLineReader
Definition: ProximLineReader.hh:60
ProximExecuteFileCmd::simulator_
SimulatorFrontend * simulator_
Definition: ProximExecuteFileCmd.hh:54
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
WxConversion::toString
static std::string toString(const wxString &source)
ProximConstants::COMMAND_NAME_EXECUTE_FILE
static const std::string COMMAND_NAME_EXECUTE_FILE
Name of the execute file command.
Definition: ProximConstants.hh:138
ProximToolbox::lineReader
static ProximLineReader & lineReader()
Definition: ProximToolbox.cc:238
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75