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

#include <AddSocketCmd.hh>

Inheritance diagram for AddSocketCmd:
Inheritance graph
Collaboration diagram for AddSocketCmd:
Collaboration graph

Public Member Functions

 AddSocketCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddSocketCmdcreate () const
 
virtual std::string shortName () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
virtual std::string icon () 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 adding new sockets to the Machine.

Displays a socket dialog and creates a new socket according to the dialog output.

Definition at line 43 of file AddSocketCmd.hh.

Constructor & Destructor Documentation

◆ AddSocketCmd()

AddSocketCmd::AddSocketCmd ( )

The Constructor.

Definition at line 53 of file AddSocketCmd.cc.

Referenced by create().

Member Function Documentation

◆ create()

AddSocketCmd * AddSocketCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 120 of file AddSocketCmd.cc.

120  {
121  return new AddSocketCmd();
122 }

References AddSocketCmd().

Here is the call graph for this function:

◆ Do()

bool AddSocketCmd::Do ( )
virtual

Executes the command.

Returns
true, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 65 of file AddSocketCmd.cc.

65  {
66 
67  assert(parentWindow() != NULL);
68  assert(view() != NULL);
69 
70  Model* model = dynamic_cast<MDFDocument*>(
71  view()->GetDocument())->getModel();
72 
73  model->pushToStack();
74 
75  // Generate name for the new socket.
76  Machine::SocketNavigator navigator =
77  model->getMachine()->socketNavigator();
78  int i = 1;
81  while (navigator.hasItem(newName)) {
84  i++;
85  }
86 
87  Socket* socket = new Socket(newName);
88  socket->setMachine(*(model->getMachine()));
89 
90  SocketDialog dialog(parentWindow(), socket);
91 
92  if (dialog.ShowModal() == wxID_OK) {
93  model->notifyObservers();
94  return true;
95  } else {
96  model->popFromStack();
97  return false;
98  }
99  return false;
100 }

References assert, ProDeConstants::COMP_NEW_NAME_PREFIX_SOCKET, Model::getMachine(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), Model::notifyObservers(), GUICommand::parentWindow(), Model::popFromStack(), Model::pushToStack(), TTAMachine::Socket::setMachine(), TTAMachine::Machine::socketNavigator(), Conversion::toString(), and EditorCommand::view().

Here is the call graph for this function:

◆ id()

int AddSocketCmd::id ( ) const
virtual

Returns id of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 109 of file AddSocketCmd.cc.

109  {
111 }

References ProDeConstants::COMMAND_ADD_SOCKET.

◆ isEnabled()

bool AddSocketCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a document is open.

Returns
True, if a document is open.

Reimplemented from EditorCommand.

Definition at line 144 of file AddSocketCmd.cc.

144  {
145  wxDocManager* manager = wxGetApp().docManager();
146  if (manager->GetCurrentView() != NULL) {
147  return true;
148  }
149  return false;
150 }

◆ shortName()

string AddSocketCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short name of the command to be used in the toolbar.

Reimplemented from GUICommand.

Definition at line 131 of file AddSocketCmd.cc.

131  {
133 }

References ProDeConstants::CMD_SNAME_ADD_SOCKET.


The documentation for this class was generated from the following files:
AddSocketCmd::AddSocketCmd
AddSocketCmd()
Definition: AddSocketCmd.cc:53
Conversion::toString
static std::string toString(const T &source)
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
TTAMachine::Socket::setMachine
virtual void setMachine(Machine &mach)
Definition: Socket.cc:432
TTAMachine::Socket
Definition: Socket.hh:53
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
TTAMachine::Machine::socketNavigator
virtual SocketNavigator socketNavigator() const
Definition: Machine.cc:368
ProDeConstants::COMP_NEW_NAME_PREFIX_SOCKET
static const std::string COMP_NEW_NAME_PREFIX_SOCKET
Prefix for new socket names..
Definition: ProDeConstants.hh:369
SocketDialog
Definition: SocketDialog.hh:50
MDFDocument
Definition: MDFDocument.hh:51
Model
Definition: Model.hh:50
ProDeConstants::CMD_NAME_ADD_SOCKET
static const std::string CMD_NAME_ADD_SOCKET
Command name for the "Add Socket" command.
Definition: ProDeConstants.hh:99
ProDeConstants::COMMAND_ADD_SOCKET
@ COMMAND_ADD_SOCKET
Definition: ProDeConstants.hh:420
ProDeConstants::CMD_SNAME_ADD_SOCKET
static const std::string CMD_SNAME_ADD_SOCKET
Command name for the "Add Socket" command.
Definition: ProDeConstants.hh:211
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88