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

#include <EditTemplatesCmd.hh>

Inheritance diagram for EditTemplatesCmd:
Inheritance graph
Collaboration diagram for EditTemplatesCmd:
Collaboration graph

Public Member Functions

 EditTemplatesCmd ()
 
virtual ~EditTemplatesCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual EditTemplatesCmdcreate () const
 
virtual std::string icon () 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
 
- 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 editing instruction templates.

Opens a TemplateListDialog which lists instruction templates in the machine.

Definition at line 43 of file EditTemplatesCmd.hh.

Constructor & Destructor Documentation

◆ EditTemplatesCmd()

EditTemplatesCmd::EditTemplatesCmd ( )

The Constructor.

Definition at line 52 of file EditTemplatesCmd.cc.

Referenced by create().

◆ ~EditTemplatesCmd()

EditTemplatesCmd::~EditTemplatesCmd ( )
virtual

The Destructor.

Definition at line 60 of file EditTemplatesCmd.cc.

60 {}

Member Function Documentation

◆ create()

EditTemplatesCmd * EditTemplatesCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
A new instance of this command.

Implements GUICommand.

Definition at line 109 of file EditTemplatesCmd.cc.

109  {
110  return new EditTemplatesCmd();
111 }

References EditTemplatesCmd().

Here is the call graph for this function:

◆ Do()

bool EditTemplatesCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 69 of file EditTemplatesCmd.cc.

69  {
70 
71  assert(parentWindow() != NULL);
72  assert(view() != NULL);
73 
74  Model* model = dynamic_cast<MDFDocument*>(
75  view()->GetDocument())->getModel();
76 
77  model->pushToStack();
78 
79  TemplateListDialog dialog(parentWindow(), model->getMachine());
80 
81  if (dialog.ShowModal() == wxID_OK) {
82  model->notifyObservers();
83  return true;
84  } else {
85  // Cancel button was pressed, templates are not modified.
86  model->popFromStack();
87  return false;
88  }
89 }

References assert, Model::getMachine(), Model::notifyObservers(), GUICommand::parentWindow(), Model::popFromStack(), Model::pushToStack(), and EditorCommand::view().

Here is the call graph for this function:

◆ icon()

string EditTemplatesCmd::icon ( ) const
virtual

Returns path to the command's icon file.

Returns
path to the command's icon file.

Reimplemented from EditorCommand.

Definition at line 121 of file EditTemplatesCmd.cc.

121  {
123 }

References ProDeConstants::CMD_ICON_EDIT_TEMPLATES.

◆ id()

int EditTemplatesCmd::id ( ) const
virtual

Returns id of this command.

Returns
Id of this command.

Implements GUICommand.

Definition at line 98 of file EditTemplatesCmd.cc.

98  {
100 }

References ProDeConstants::COMMAND_EDIT_TEMPLATES.

◆ isEnabled()

bool EditTemplatesCmd::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 145 of file EditTemplatesCmd.cc.

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

◆ shortName()

string EditTemplatesCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short version of the command name.

Reimplemented from GUICommand.

Definition at line 132 of file EditTemplatesCmd.cc.

132  {
134 }

References ProDeConstants::CMD_SNAME_EDIT_TEMPLATES.


The documentation for this class was generated from the following files:
EditTemplatesCmd::EditTemplatesCmd
EditTemplatesCmd()
Definition: EditTemplatesCmd.cc:52
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
ProDeConstants::CMD_SNAME_EDIT_TEMPLATES
static const std::string CMD_SNAME_EDIT_TEMPLATES
Command name for the "Edit Templates" command.
Definition: ProDeConstants.hh:231
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
ProDeConstants::CMD_NAME_EDIT_TEMPLATES
static const std::string CMD_NAME_EDIT_TEMPLATES
Command name for the "Edit Tempaltes" command.
Definition: ProDeConstants.hh:139
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
ProDeConstants::CMD_ICON_EDIT_TEMPLATES
static const std::string CMD_ICON_EDIT_TEMPLATES
Icon location for the "Edit Templates" command.
Definition: ProDeConstants.hh:340
MDFDocument
Definition: MDFDocument.hh:51
ProDeConstants::COMMAND_EDIT_TEMPLATES
@ COMMAND_EDIT_TEMPLATES
Definition: ProDeConstants.hh:441
Model
Definition: Model.hh:50
TemplateListDialog
Definition: TemplateListDialog.hh:50
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88