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

#include <AddASCmd.hh>

Inheritance diagram for AddASCmd:
Inheritance graph
Collaboration diagram for AddASCmd:
Collaboration graph

Public Member Functions

 AddASCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddASCmdcreate () 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 address spaces to the Machine.

Displays a address space dialog and creates a new address space according to the dialog output.

Definition at line 43 of file AddASCmd.hh.

Constructor & Destructor Documentation

◆ AddASCmd()

AddASCmd::AddASCmd ( )

The Constructor.

Definition at line 52 of file AddASCmd.cc.

Referenced by create().

Member Function Documentation

◆ create()

AddASCmd * AddASCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 127 of file AddASCmd.cc.

127  {
128  return new AddASCmd();
129 }

References AddASCmd().

Here is the call graph for this function:

◆ Do()

bool AddASCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 64 of file AddASCmd.cc.

64  {
65 
66  assert(parentWindow() != NULL);
67  assert(view() != NULL);
68 
69  Model* model = dynamic_cast<MDFDocument*>(
70  view()->GetDocument())->getModel();
71 
72  model->pushToStack();
73 
74  // Generate name for the new AS.
77  int i = 1;
80  while (navigator.hasItem(newName)) {
83  i++;
84  }
85 
86  AddressSpace* addressSpace =
87  new AddressSpace(newName,
91  *model->getMachine());
92 
93 
94  AddressSpaceDialog dialog(parentWindow(), model->getMachine(),
95  addressSpace);
96 
97  if (dialog.ShowModal() == wxID_OK) {
98  model->notifyObservers();
99  return true;
100  } else {
101  // as creation was cancelled
102  model->popFromStack();
103  return false;
104  }
105 
106  return false;
107 }

References TTAMachine::Machine::addressSpaceNavigator(), assert, ProDeConstants::COMP_NEW_NAME_PREFIX_AS, ModelConstants::DEFAULT_AS_MAX_ADDRESS, ModelConstants::DEFAULT_AS_MIN_ADDRESS, ModelConstants::DEFAULT_WIDTH, Model::getMachine(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), Model::notifyObservers(), GUICommand::parentWindow(), Model::popFromStack(), Model::pushToStack(), Conversion::toString(), and EditorCommand::view().

Here is the call graph for this function:

◆ id()

int AddASCmd::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 116 of file AddASCmd.cc.

116  {
118 }

References ProDeConstants::COMMAND_ADD_AS.

◆ isEnabled()

bool AddASCmd::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 151 of file AddASCmd.cc.

151  {
152  wxDocManager* manager = wxGetApp().docManager();
153  if (manager->GetCurrentView() != NULL) {
154  return true;
155  }
156  return false;
157 }

◆ shortName()

string AddASCmd::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 138 of file AddASCmd.cc.

138  {
140 }

References ProDeConstants::CMD_SNAME_ADD_AS.


The documentation for this class was generated from the following files:
AddASCmd::AddASCmd
AddASCmd()
Definition: AddASCmd.cc:52
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
ProDeConstants::COMP_NEW_NAME_PREFIX_AS
static const std::string COMP_NEW_NAME_PREFIX_AS
Prefix for new address space names.
Definition: ProDeConstants.hh:379
ModelConstants::DEFAULT_AS_MIN_ADDRESS
static const int DEFAULT_AS_MIN_ADDRESS
Default address space min address.
Definition: ModelConstants.hh:68
AddressSpaceDialog
Definition: AddressSpaceDialog.hh:50
ProDeConstants::COMMAND_ADD_AS
@ COMMAND_ADD_AS
Definition: ProDeConstants.hh:424
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
ModelConstants::DEFAULT_AS_MAX_ADDRESS
static const int DEFAULT_AS_MAX_ADDRESS
Default address space max address.
Definition: ModelConstants.hh:70
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
ModelConstants::DEFAULT_WIDTH
static const int DEFAULT_WIDTH
Default bit width.
Definition: ModelConstants.hh:46
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
TTAMachine::Machine::addressSpaceNavigator
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition: Machine.cc:392
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
MDFDocument
Definition: MDFDocument.hh:51
Model
Definition: Model.hh:50
ProDeConstants::CMD_NAME_ADD_AS
static const std::string CMD_NAME_ADD_AS
Command name for the "Add Address Space" command.
Definition: ProDeConstants.hh:107
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
ProDeConstants::CMD_SNAME_ADD_AS
static const std::string CMD_SNAME_ADD_AS
Command name for the "Add Address Space" command.
Definition: ProDeConstants.hh:219
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88