OpenASIP
2.0
src
procgen
ProDe
ModifyBridgeCmd.cc
Go to the documentation of this file.
1
/*
2
Copyright (c) 2002-2009 Tampere University.
3
4
This file is part of TTA-Based Codesign Environment (TCE).
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
*/
24
/**
25
* @file ModifyBridgeCmd.cc
26
*
27
* Definition of ModifyBridgeCmd class.
28
*
29
* @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30
* @note rating: red
31
* @note reviewed Jun 23 2004 by ml, jn, jm, vpj
32
*/
33
34
#include <string>
35
36
#include "
Application.hh
"
37
#include "
ModifyBridgeCmd.hh
"
38
#include "
Bridge.hh
"
39
#include "
EditPart.hh
"
40
#include "
BridgeDialog.hh
"
41
#include "
ErrorDialog.hh
"
42
43
using
std::string;
44
using namespace
TTAMachine
;
45
46
47
/**
48
* The Constructor.
49
*
50
* @param editPart EditPart of the component to modify.
51
*/
52
ModifyBridgeCmd::ModifyBridgeCmd
(
EditPart
* editPart):
53
ComponentCommand
(),
54
editPart_(editPart) {
55
56
}
57
58
59
/**
60
* The Destructor.
61
*/
62
ModifyBridgeCmd::~ModifyBridgeCmd
() {
63
}
64
65
66
/**
67
* Executes the command.
68
*
69
* @return true, if the command was succesfully executed, false otherwise.
70
*/
71
bool
72
ModifyBridgeCmd::Do
() {
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
}
TTAMachine::Bridge
Definition:
Bridge.hh:51
ModifyBridgeCmd::Do
virtual bool Do()
Definition:
ModifyBridgeCmd.cc:72
assert
#define assert(condition)
Definition:
Application.hh:86
BridgeDialog
Definition:
BridgeDialog.hh:46
EditPart.hh
ErrorDialog.hh
Application.hh
EditPart::setModel
void setModel(TTAMachine::MachinePart *model)
EditPart
Definition:
EditPart.hh:60
EditPart::child
EditPart * child(unsigned int index) const
EditPart::childCount
int childCount() const
EditPart::model
TTAMachine::MachinePart * model() const
ComponentCommand
Definition:
ComponentCommand.hh:46
ModifyBridgeCmd::~ModifyBridgeCmd
virtual ~ModifyBridgeCmd()
Definition:
ModifyBridgeCmd.cc:62
ModifyBridgeCmd::editPart_
EditPart * editPart_
Bridge to modify.
Definition:
ModifyBridgeCmd.hh:53
BridgeDialog.hh
ModifyBridgeCmd.hh
TTAMachine
Definition:
Assembler.hh:48
Bridge.hh
ModifyBridgeCmd::ModifyBridgeCmd
ModifyBridgeCmd(EditPart *editPart)
Definition:
ModifyBridgeCmd.cc:52
ComponentCommand::parentWindow
wxWindow * parentWindow()
Definition:
ComponentCommand.cc:66
Generated by
1.8.17