OpenASIP 2.2
Loading...
Searching...
No Matches
BridgeFactory.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 BridgeFactory.cc
26 *
27 * Definition of BridgeFactory class.
28 *
29 * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30 * @note rating: yellow
31 * @note reviewed Jul 14 2004 by jm, ll, jn, am
32 */
33
34#include <vector>
35
36#include "Application.hh"
37#include "Bridge.hh"
38#include "BridgeFigure.hh"
39#include "BridgeFactory.hh"
40#include "ConnectionEditPart.hh"
41#include "BusFactory.hh"
42#include "EditPolicyFactory.hh"
43
44using std::vector;
45using namespace TTAMachine;
46
47/**
48 * The Constructor.
49 */
51 EditPartFactory(editPolicyFactory) {
52
53 registerFactory(new BusFactory(editPolicyFactory));
54}
55
56/**
57 * The Destructor.
58 */
61
62/**
63 * Returns an EditPart corresponding to a bridge.
64 *
65 * @param component Bridge of which to create the EditPart.
66 * @return NULL if the parameter is not an instance of the
67 * Bridge class.
68 */
71
72 Bridge* bridge = dynamic_cast<Bridge*>(component);
73
74 if (bridge != NULL) {
75
76 ConnectionEditPart* bridgeEditPart = new ConnectionEditPart();
77
78 bridgeEditPart->setModel(bridge);
79 BridgeFigure* fig = new BridgeFigure();
80 bridgeEditPart->setFigure(fig);
81
82 vector<Factory*>::const_iterator iter;
83
84 for (iter = factories_.begin(); iter != factories_.end(); iter++) {
85
86 EditPart* busEditPart = (*iter)->createEditPart(
87 (MachinePart*)bridge->sourceBus());
88
89 if (busEditPart != NULL) {
90 bridgeEditPart->setSource(busEditPart);
91 bridgeEditPart->setTarget(
92 (*iter)->createEditPart(
93 (MachinePart*)bridge->destinationBus()));
94 break;
95 }
96 }
97
98 assert(bridgeEditPart->target() != NULL &&
99 bridgeEditPart->source() != NULL);
100
101 bridgeEditPart->setSelectable(true);
102
104 if (editPolicy != NULL) {
105 bridgeEditPart->installEditPolicy(editPolicy);
106 }
107
108 return bridgeEditPart;
109
110 } else {
111 return NULL;
112 }
113}
#define assert(condition)
virtual ~BridgeFactory()
BridgeFactory(EditPolicyFactory &editPolicyFactory)
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
EditPart * source() const
EditPart * target() const
void setSource(EditPart *source)
void setTarget(EditPart *target)
void registerFactory(Factory *factory)
std::vector< Factory * > factories_
Registered factories.
EditPolicyFactory & editPolicyFactory_
Factory which creates edit policies for edit parts.
void setModel(TTAMachine::MachinePart *model)
void installEditPolicy(EditPolicy *editpolicy)
Definition EditPart.cc:247
void setFigure(Figure *figure)
void setSelectable(bool selectable)
virtual EditPolicy * createBridgeEditPolicy()
Bus * destinationBus() const
Bus * sourceBus() const