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

#include <DeleteBridgeCmd.hh>

Inheritance diagram for DeleteBridgeCmd:
Inheritance graph
Collaboration diagram for DeleteBridgeCmd:
Collaboration graph

Public Member Functions

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

Private Attributes

EditParteditPart_
 Bridge to delete. More...
 

Detailed Description

Command for deleting bridges from the Machine.

Definition at line 44 of file DeleteBridgeCmd.hh.

Constructor & Destructor Documentation

◆ DeleteBridgeCmd()

DeleteBridgeCmd::DeleteBridgeCmd ( EditPart editPart)

The Constructor.

Parameters
editPartBridge to delete.

Definition at line 46 of file DeleteBridgeCmd.cc.

46  :
48  editPart_(editPart) {
49 }

◆ ~DeleteBridgeCmd()

DeleteBridgeCmd::~DeleteBridgeCmd ( )
virtual

The Destructor.

Definition at line 55 of file DeleteBridgeCmd.cc.

55  {
56 }

Member Function Documentation

◆ Do()

bool DeleteBridgeCmd::Do ( )
virtual

Executes the command.

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

Implements ComponentCommand.

Definition at line 65 of file DeleteBridgeCmd.cc.

65  {
66 
67  if (editPart_->childCount() == 0) {
68  Bridge* bridge = dynamic_cast<Bridge*>(editPart_->model());
69  assert (bridge != NULL);
70  delete bridge;
71  bridge = NULL;
72  } else {
73  // bidirectional bridge
74  assert(editPart_->childCount() == 2);
75  // delete bridges of both direction
76  for (int i = 0; i < editPart_->childCount(); i++) {
77  Bridge* bridge =
78  dynamic_cast<Bridge*>(editPart_->child(i)->model());
79  assert (bridge != NULL);
80  delete bridge;
81  bridge = NULL;
82  }
83  }
84 
85  return true;
86 }

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

Here is the call graph for this function:

Member Data Documentation

◆ editPart_

EditPart* DeleteBridgeCmd::editPart_
private

Bridge to delete.

Definition at line 52 of file DeleteBridgeCmd.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
EditPart::child
EditPart * child(unsigned int index) const
EditPart::childCount
int childCount() const
EditPart::model
TTAMachine::MachinePart * model() const
DeleteBridgeCmd::editPart_
EditPart * editPart_
Bridge to delete.
Definition: DeleteBridgeCmd.hh:52