OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
ModifyBridgeCmd Class Reference

#include <ModifyBridgeCmd.hh>

Inheritance diagram for ModifyBridgeCmd:
Inheritance graph
Collaboration diagram for ModifyBridgeCmd:
Collaboration graph

Public Member Functions

 ModifyBridgeCmd (EditPart *editPart)
 
virtual ~ModifyBridgeCmd ()
 
virtual bool Do ()
 
- Public Member Functions inherited from ComponentCommand
 ComponentCommand ()
 
virtual ~ComponentCommand ()
 
wxWindow * parentWindow ()
 
void setParentWindow (wxWindow *window)
 

Private Attributes

EditParteditPart_
 Bridge to modify. More...
 

Detailed Description

Command which displays a bridge dialog with precompleted values for modifying a bridge.

Definition at line 45 of file ModifyBridgeCmd.hh.

Constructor & Destructor Documentation

◆ ModifyBridgeCmd()

ModifyBridgeCmd::ModifyBridgeCmd ( EditPart editPart)

The Constructor.

Parameters
editPartEditPart of the component to modify.

Definition at line 52 of file ModifyBridgeCmd.cc.

52  :
54  editPart_(editPart) {
55 
56 }

◆ ~ModifyBridgeCmd()

ModifyBridgeCmd::~ModifyBridgeCmd ( )
virtual

The Destructor.

Definition at line 62 of file ModifyBridgeCmd.cc.

62  {
63 }

Member Function Documentation

◆ Do()

bool ModifyBridgeCmd::Do ( )
virtual

Executes the command.

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

Implements ComponentCommand.

Definition at line 72 of file ModifyBridgeCmd.cc.

72  {
73 
74  Bridge* bridge = NULL;
75  Bridge* opposite = NULL;
76 
77  if (editPart_->childCount() == 0) {
78  bridge = dynamic_cast<Bridge*>(editPart_->model());
79  editPart_->setModel(NULL);
80  assert (bridge != NULL);
81  } else {
82  // bidirectional bridge
83  assert(editPart_->childCount() == 2);
84  // find bridges of both direction
85  bridge = dynamic_cast<Bridge*>(editPart_->child(0)->model());
86  opposite = dynamic_cast<Bridge*>(editPart_->child(1)->model());
87  editPart_->setModel(NULL);
88  }
89 
90  assert(opposite != bridge);
91 
92  BridgeDialog dialog(parentWindow(), bridge, opposite);
93 
94  if (dialog.ShowModal() == wxID_OK) {
95  return true;
96  } else {
97  // modification was cancelled
98  return false;
99  }
100 
101  return false;
102 }

References assert, EditPart::child(), EditPart::childCount(), editPart_, EditPart::model(), ComponentCommand::parentWindow(), and EditPart::setModel().

Here is the call graph for this function:

Member Data Documentation

◆ editPart_

EditPart* ModifyBridgeCmd::editPart_
private

Bridge to modify.

Definition at line 53 of file ModifyBridgeCmd.hh.

Referenced by Do().


The documentation for this class was generated from the following files:
TTAMachine::Bridge
Definition: Bridge.hh:51
ComponentCommand::ComponentCommand
ComponentCommand()
Definition: ComponentCommand.cc:38
assert
#define assert(condition)
Definition: Application.hh:86
BridgeDialog
Definition: BridgeDialog.hh:46
EditPart::setModel
void setModel(TTAMachine::MachinePart *model)
EditPart::child
EditPart * child(unsigned int index) const
EditPart::childCount
int childCount() const
EditPart::model
TTAMachine::MachinePart * model() const
ModifyBridgeCmd::editPart_
EditPart * editPart_
Bridge to modify.
Definition: ModifyBridgeCmd.hh:53
ComponentCommand::parentWindow
wxWindow * parentWindow()
Definition: ComponentCommand.cc:66