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

#include <ProximOpenMachineCmd.hh>

Inheritance diagram for ProximOpenMachineCmd:
Inheritance graph
Collaboration diagram for ProximOpenMachineCmd:
Collaboration graph

Public Member Functions

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

Detailed Description

Command for opening a machine desctiption file in Proxim.

The command displays a file dialog for choosing the machine file to open.

Definition at line 43 of file ProximOpenMachineCmd.hh.

Constructor & Destructor Documentation

◆ ProximOpenMachineCmd()

ProximOpenMachineCmd::ProximOpenMachineCmd ( )

The Constructor.

Definition at line 48 of file ProximOpenMachineCmd.cc.

48  :
50 
51  }

Referenced by create().

◆ ~ProximOpenMachineCmd()

ProximOpenMachineCmd::~ProximOpenMachineCmd ( )
virtual

The Destructor.

Definition at line 56 of file ProximOpenMachineCmd.cc.

56  {
57 }

Member Function Documentation

◆ create()

ProximOpenMachineCmd * ProximOpenMachineCmd::create ( ) const
virtual

Creates and returns a new isntance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 122 of file ProximOpenMachineCmd.cc.

122  {
123  return new ProximOpenMachineCmd();
124 }

References ProximOpenMachineCmd().

Here is the call graph for this function:

◆ Do()

bool ProximOpenMachineCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 64 of file ProximOpenMachineCmd.cc.

64  {
65  assert(parentWindow() != NULL);
66 
67  wxString wildcard = _T("Architecture Definition Files (*.adf)|*.adf");
68  wildcard.Append(_T("|Processor Configuration Files (*.pcf)|*.pcf"));
69  wildcard.Append(_T("|All files|*.*"));
70  wxFileDialog dialog(
71  parentWindow(), _T("Choose a file."), _T(""), _T(""),
72  wildcard, wxOPEN);
73 
74  if (dialog.ShowModal() == wxID_CANCEL) {
75  return false;
76  }
77 
78  std::string command;
79  std::string file = WxConversion::toString(dialog.GetPath());
80  std::string extension = FileSystem::fileExtension(file);
81 
82  // Simulator interpreter command is chose according to file extension.
83  // Processor configuration files (.pcf), have to be opened using
84  // 'conf' command.
85  if (extension == ".pcf") {
86  command = ProximConstants::SCL_LOAD_CONF + " \"" + file + "\"";
87  } else {
88  command = ProximConstants::SCL_LOAD_MACHINE + " \"" + file + "\"";
89  }
90 
91  wxGetApp().simulation()->lineReader().input(command);
92  return true;
93 }

References assert, FileSystem::fileExtension(), GUICommand::parentWindow(), ProximConstants::SCL_LOAD_CONF, ProximConstants::SCL_LOAD_MACHINE, and WxConversion::toString().

Here is the call graph for this function:

◆ icon()

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

Returns full path to the command icon file.

Returns
Full path to the command icon file.

Implements GUICommand.

Definition at line 102 of file ProximOpenMachineCmd.cc.

102  {
103  return "open_machine.png";
104 }

◆ id()

int ProximOpenMachineCmd::id ( ) const
virtual

Returns ID of this command.

Implements GUICommand.

Definition at line 111 of file ProximOpenMachineCmd.cc.

111  {
113 }

References ProximConstants::COMMAND_OPEN_MACHINE.

◆ isEnabled()

bool ProximOpenMachineCmd::isEnabled ( )
virtual

Returns true if the command is enabled, false otherwise.

Returns
Always true.

Implements GUICommand.

Definition at line 133 of file ProximOpenMachineCmd.cc.

133  {
134  return true;
135 }

◆ shortName()

std::string ProximOpenMachineCmd::shortName ( ) const
virtual

Returns shortened name of the command for toolbar button text.

Returns
Short version of the command name.

Reimplemented from GUICommand.

Definition at line 143 of file ProximOpenMachineCmd.cc.

143  {
144  return "Machine";
145 }

The documentation for this class was generated from the following files:
ProximOpenMachineCmd::ProximOpenMachineCmd
ProximOpenMachineCmd()
Definition: ProximOpenMachineCmd.cc:48
assert
#define assert(condition)
Definition: Application.hh:86
ProximConstants::SCL_LOAD_MACHINE
static const std::string SCL_LOAD_MACHINE
Command for loading a new machine in the simulator.
Definition: ProximConstants.hh:147
FileSystem::fileExtension
static std::string fileExtension(const std::string &fileName)
Definition: FileSystem.cc:279
ProximConstants::COMMAND_NAME_OPEN_MACHINE
static const std::string COMMAND_NAME_OPEN_MACHINE
Name of the open machine command.
Definition: ProximConstants.hh:106
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
ProximConstants::SCL_LOAD_CONF
static const std::string SCL_LOAD_CONF
Command for loading a new machine configuration file in the simulator.
Definition: ProximConstants.hh:149
WxConversion::toString
static std::string toString(const wxString &source)
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
ProximConstants::COMMAND_OPEN_MACHINE
@ COMMAND_OPEN_MACHINE
Definition: ProximConstants.hh:53