OpenASIP 2.2
Loading...
Searching...
No Matches
FUFactory.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 FUFactory.cc
26 *
27 * Definition of FUFactory 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 "WxConversion.hh"
37#include "FUFactory.hh"
38#include "UnitPortFactory.hh"
39#include "FunctionUnit.hh"
40#include "EditPart.hh"
41#include "UnitFigure.hh"
42#include "FUPort.hh"
43#include "EditPolicyFactory.hh"
44#include "HWOperation.hh"
45#include "AddressSpace.hh"
46
47using std::vector;
48using namespace TTAMachine;
49
50/**
51 * The Constructor.
52 */
54 EditPartFactory(editPolicyFactory) {
55
56 registerFactory(new UnitPortFactory(editPolicyFactory));
57}
58
59
60/**
61 * The Destructor.
62 */
65
66
67/**
68 * Returns an EditPart corresponding to a function unit.
69 *
70 * @param component Function unit of which to create the EditPart.
71 * @return NULL if the parameter is not an instance of the
72 * FunctionUnit class.
73 */
76
77 FunctionUnit* fu = dynamic_cast<FunctionUnit*>(component);
78
79 if (fu != NULL) {
80 EditPart* fuEditPart = new EditPart();
81 fuEditPart->setModel(fu);
82
83 UnitFigure* fig = new UnitFigure();
84 wxString name = WxConversion::toWxString(fu->name());
85 name.Prepend(_T("FU: "));
86 fig->setName(name);
87 fuEditPart->setFigure(fig);
88
89 for (int i = 0; i < fu->portCount(); i++) {
90 vector<Factory*>::const_iterator iter;
91 for (iter = factories_.begin(); iter != factories_.end(); iter++) {
92 EditPart* portEditPart =
93 (*iter)->createEditPart(fu->port(i));
94 if (portEditPart != NULL) {
95 fuEditPart->addChild(portEditPart);
96 EditPolicy* editPolicy =
98 if (editPolicy != NULL) {
99 portEditPart->installEditPolicy(editPolicy);
100 }
101 }
102 }
103 }
104
105 wxString operations = _T("{ ");
106 AddressSpace* as = fu->addressSpace();
107 if (as != NULL) {
108 operations.Append(_T("AS: "));
109 operations.Append(
111 operations.Append(_T(" Ops:"));
112 }
113
114 for (int i = 0; i < fu->operationCount(); i++) {
115 if (i > 0) {
116 operations.Append(_T(", "));
117 }
118 operations.Append(
120 }
121 operations.Append(_T(" }"));
122 fig->setInfo(operations);
123
124 fuEditPart->setSelectable(true);
125
127 if (editPolicy != NULL) {
128 fuEditPart->installEditPolicy(editPolicy);
129 }
130
131 return fuEditPart;
132
133 } else {
134 return NULL;
135 }
136}
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)
void addChild(EditPart *child)
Definition EditPart.cc:260
virtual EditPolicy * createFUPortEditPolicy()
virtual EditPolicy * createFUEditPolicy()
virtual ~FUFactory()
Definition FUFactory.cc:63
FUFactory(EditPolicyFactory &editPolicyFactory)
Definition FUFactory.cc:53
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
Definition FUFactory.cc:75
virtual TCEString name() const
virtual AddressSpace * addressSpace() const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual BaseFUPort * port(const std::string &name) const
const std::string & name() const
virtual int portCount() const
Definition Unit.cc:135
void setName(const wxString &name)
void setInfo(const wxString &info)
static wxString toWxString(const std::string &source)