OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
AddBusCmd Class Reference

#include <AddBusCmd.hh>

Inheritance diagram for AddBusCmd:
Inheritance graph
Collaboration diagram for AddBusCmd:
Collaboration graph

Public Member Functions

 AddBusCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddBusCmdcreate () 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 buses to the Machine.

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

Definition at line 43 of file AddBusCmd.hh.

Constructor & Destructor Documentation

◆ AddBusCmd()

AddBusCmd::AddBusCmd ( )

The Constructor.

Definition at line 56 of file AddBusCmd.cc.

56 :
58}
static const std::string CMD_NAME_ADD_BUS
Command name for the "Add Bus" command.

Referenced by create().

Member Function Documentation

◆ create()

AddBusCmd * AddBusCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 130 of file AddBusCmd.cc.

130 {
131 return new AddBusCmd();
132}

References AddBusCmd().

Here is the call graph for this function:

◆ Do()

bool AddBusCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 68 of file AddBusCmd.cc.

68 {
69
70 assert(parentWindow() != NULL);
71 assert(view() != NULL);
72
73 Model* model = dynamic_cast<MDFDocument*>(
74 view()->GetDocument())->getModel();
75
76 model->pushToStack();
77
78 // Generate name for the new bus.
79 Machine::BusNavigator navigator =
80 model->getMachine()->busNavigator();
81 int i = 1;
84 while (navigator.hasItem(newName)) {
87 i++;
88 }
89 Bus* bus =
92 bus->setMachine(*(model->getMachine()));
93
94 // Create an always-true guard for the bus by default.
95 new UnconditionalGuard(false, *bus);
96
97 // Add a default segment to the bus.
99
100 BusDialog dialog(parentWindow(), bus);
101
102 if (dialog.ShowModal() == wxID_OK) {
103 model->notifyObservers();
104 return true;
105 } else {
106 // bus creation was cancelled
107 model->popFromStack();
108 return false;
109 }
110}
#define assert(condition)
static std::string toString(const T &source)
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static const int DEFAULT_WIDTH
Default bit width.
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_BUS
Prefix for new bus names.
static const std::string COMP_DEFAULT_NAME_SEGMENT
Name for the default segments of busses.
virtual void setMachine(Machine &mach)
Definition Bus.cc:671
bool hasItem(const std::string &name) const
virtual BusNavigator busNavigator() const
Definition Machine.cc:356
@ ZERO
Zero extension.
Definition Machine.hh:81

References assert, TTAMachine::Machine::busNavigator(), ProDeConstants::COMP_DEFAULT_NAME_SEGMENT, ProDeConstants::COMP_NEW_NAME_PREFIX_BUS, ModelConstants::DEFAULT_WIDTH, Model::getMachine(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), Model::notifyObservers(), GUICommand::parentWindow(), Model::popFromStack(), Model::pushToStack(), TTAMachine::Bus::setMachine(), Conversion::toString(), EditorCommand::view(), and TTAMachine::Machine::ZERO.

Here is the call graph for this function:

◆ id()

int AddBusCmd::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 119 of file AddBusCmd.cc.

References ProDeConstants::COMMAND_ADD_BUS.

◆ isEnabled()

bool AddBusCmd::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 154 of file AddBusCmd.cc.

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

◆ shortName()

string AddBusCmd::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 141 of file AddBusCmd.cc.

141 {
143}
static const std::string CMD_SNAME_ADD_BUS
Command name for the "Add Bus" command.

References ProDeConstants::CMD_SNAME_ADD_BUS.


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