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

52 :
54}
static const std::string CMD_NAME_ADD_AS
Command name for the "Add Address Space" command.

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}
#define assert(condition)
static std::string toString(const T &source)
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static const int DEFAULT_AS_MIN_ADDRESS
Default address space min address.
static const int DEFAULT_WIDTH
Default bit width.
static const int DEFAULT_AS_MAX_ADDRESS
Default address space max address.
Definition Model.hh:50
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
void popFromStack(bool modified=false)
Definition Model.cc:195
TTAMachine::Machine * getMachine()
Definition Model.cc:88
static const std::string COMP_NEW_NAME_PREFIX_AS
Prefix for new address space names.
bool hasItem(const std::string &name) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392

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.

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}
static const std::string CMD_SNAME_ADD_AS
Command name for the "Add Address Space" command.

References ProDeConstants::CMD_SNAME_ADD_AS.


The documentation for this class was generated from the following files: