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

#include <ProximQuitCmd.hh>

Inheritance diagram for ProximQuitCmd:
Inheritance graph
Collaboration diagram for ProximQuitCmd:
Collaboration graph

Public Member Functions

 ProximQuitCmd ()
 
virtual ~ProximQuitCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual ProximQuitCmdcreate () 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 quiting Proxim.

Definition at line 43 of file ProximQuitCmd.hh.

Constructor & Destructor Documentation

◆ ProximQuitCmd()

ProximQuitCmd::ProximQuitCmd ( )

The Constructor.

Definition at line 50 of file ProximQuitCmd.cc.

References ProximToolbox::frontend(), and simulator_.

Referenced by create().

Here is the call graph for this function:

◆ ~ProximQuitCmd()

ProximQuitCmd::~ProximQuitCmd ( )
virtual

The Destructor.

Definition at line 59 of file ProximQuitCmd.cc.

59  {
60 }

Member Function Documentation

◆ create()

ProximQuitCmd * ProximQuitCmd::create ( ) const
virtual

Creates and returns a new isntance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 145 of file ProximQuitCmd.cc.

145  {
146  return new ProximQuitCmd();
147 }

References ProximQuitCmd().

Here is the call graph for this function:

◆ Do()

bool ProximQuitCmd::Do ( )
virtual

Executes the command.

Returns
True, if the command was succesfully executed.

Implements GUICommand.

Definition at line 69 of file ProximQuitCmd.cc.

69  {
70 
71  assert(parentWindow() != NULL);
72 
74  wxString message = _T("Simulation is still running.\n");
75  message.Append(_T("Are you sure you want to stop the simulation "));
76  message.Append(_T("and quit?"));
77  ConfirmDialog dialog(parentWindow(), message);
78 
79  if (dialog.ShowModal() != wxID_YES) {
80  return false;
81  }
82 
83  wxGetApp().simulation()->finishSimulation();
84  }
85 
86  GUIOptions& options = wxGetApp().options();
87  if (options.isModified()) {
88  wxString message = _T("Options are modified.\n");
89  message.Append(_T("Do you want to save changes?"));
90  ConfirmDialog dialog(parentWindow(), message);
91 
92  int returnValue = dialog.ShowModal();
93  if (returnValue == wxID_YES) {
94 
96  try {
97  writer.setDestinationFile(
98  Environment::userConfPath("Proxim.conf"));
99  writer.writeOptions(options);
100  options.clearModified();
101  } catch (Exception& e) {
102  wxString message = _T("Error saving options:\n\n");
103  message.Append(WxConversion::toWxString(e.errorMessage()));
104  ErrorDialog errorDialog(parentWindow(), message);
105  errorDialog.ShowModal();
106  return false;
107  }
108  } else if (returnValue == wxID_CANCEL) {
109  return false;
110  }
111  }
112 
114 
115  return true;
116 }

References assert, ProximConstants::CONFIGURATION_NAME, Exception::errorMessage(), ProximLineReader::input(), SimulatorFrontend::isSimulationRunning(), SimulatorFrontend::isSimulationStopped(), ProximToolbox::lineReader(), options, GUICommand::parentWindow(), ProximConstants::SCL_QUIT, XMLSerializer::setDestinationFile(), simulator_, WxConversion::toWxString(), Environment::userConfPath(), and GUIOptionsSerializer::writeOptions().

Here is the call graph for this function:

◆ icon()

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

Returns full path to the command icon file.

Returns
Full path to the command icon file.

Implements GUICommand.

Definition at line 125 of file ProximQuitCmd.cc.

125  {
126  return "quit.png";
127 }

◆ id()

int ProximQuitCmd::id ( ) const
virtual

Returns ID of this command.

Implements GUICommand.

Definition at line 134 of file ProximQuitCmd.cc.

134  {
136 }

References ProximConstants::COMMAND_QUIT.

◆ isEnabled()

bool ProximQuitCmd::isEnabled ( )
virtual

Returns true if the command is enabled, false otherwise.

Returns
Always true.

Implements GUICommand.

Definition at line 156 of file ProximQuitCmd.cc.

156  {
157  return true;
158 }

Member Data Documentation

◆ simulator_

SimulatorFrontend* ProximQuitCmd::simulator_
private

Definition at line 54 of file ProximQuitCmd.hh.

Referenced by Do(), and ProximQuitCmd().


The documentation for this class was generated from the following files:
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
WxConversion::toWxString
static wxString toWxString(const std::string &source)
ProximConstants::CONFIGURATION_NAME
static const std::string CONFIGURATION_NAME
Configuration file top-level element name.
Definition: ProximConstants.hh:247
SimulatorFrontend::isSimulationStopped
bool isSimulationStopped() const
Definition: SimulatorFrontend.cc:1271
ProximQuitCmd::simulator_
SimulatorFrontend * simulator_
Definition: ProximQuitCmd.hh:54
ProximLineReader::input
void input(std::string command)
Definition: ProximLineReader.cc:131
ProximConstants::COMMAND_NAME_QUIT
static const std::string COMMAND_NAME_QUIT
Name of the quit command.
Definition: ProximConstants.hh:114
Environment::userConfPath
static TCEString userConfPath(const std::string &fileName)
Definition: Environment.cc:303
assert
#define assert(condition)
Definition: Application.hh:86
ErrorDialog
Definition: ErrorDialog.hh:42
Exception
Definition: Exception.hh:54
ConfirmDialog
Definition: ConfirmDialog.hh:41
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
ProximConstants::COMMAND_QUIT
@ COMMAND_QUIT
Definition: ProximConstants.hh:57
SimulatorFrontend::isSimulationRunning
bool isSimulationRunning() const
Definition: SimulatorFrontend.cc:1260
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
GUIOptions
Definition: GUIOptions.hh:58
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
ProximConstants::SCL_QUIT
static const std::string SCL_QUIT
Command for quiting the simulation.
Definition: ProximConstants.hh:161
ProximQuitCmd::ProximQuitCmd
ProximQuitCmd()
Definition: ProximQuitCmd.cc:50
ProximToolbox::lineReader
static ProximLineReader & lineReader()
Definition: ProximToolbox.cc:238
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
GUIOptionsSerializer
Definition: GUIOptionsSerializer.hh:52