OpenASIP 2.2
Loading...
Searching...
No Matches
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.

50 :
52
54}
static const std::string COMMAND_NAME_QUIT
Name of the quit command.
SimulatorFrontend * simulator_
static TracedSimulatorFrontend * frontend()

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}
#define assert(condition)
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static TCEString userConfPath(const std::string &fileName)
std::string errorMessage() const
Definition Exception.cc:123
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static const std::string SCL_QUIT
Command for quiting the simulation.
static const std::string CONFIGURATION_NAME
Configuration file top-level element name.
void input(std::string command)
static ProximLineReader & lineReader()
bool isSimulationStopped() const
bool isSimulationRunning() const
static wxString toWxString(const std::string &source)

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.

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: