OpenASIP 2.2
Loading...
Searching...
No Matches
GCUFactory.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 GCUFactory.cc
26 *
27 * Definition of GCUFactory 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 <string>
35#include <vector>
36
37#include "WxConversion.hh"
38#include "GCUFactory.hh"
39#include "UnitPortFactory.hh"
40#include "ControlUnit.hh"
41#include "EditPart.hh"
42#include "UnitFigure.hh"
43#include "FUPort.hh"
45#include "EditPolicyFactory.hh"
46#include "HWOperation.hh"
47
48using std::vector;
49using namespace TTAMachine;
50
51/**
52 * The Constructor.
53 */
55 EditPartFactory(editPolicyFactory) {
56 registerFactory(new UnitPortFactory(editPolicyFactory));
57}
58
59/**
60 * The Destructor.
61 */
64
65/**
66 * Returns an EditPart corresponding to a global control unit.
67 *
68 * @param component Global control unit of which to create the EditPart.
69 * @return NULL if the parameter is not an instance of the
70 * ControlUnit class.
71 */
74
75 ControlUnit* gcu = dynamic_cast<ControlUnit*>(component);
76
77 if (gcu != NULL) {
78 EditPart* gcuEditPart = new EditPart();
79 gcuEditPart->setModel(gcu);
80
81 UnitFigure* fig = new UnitFigure();
82 wxString name = WxConversion::toWxString(gcu->name());
83 name.Prepend(_T("GCU: "));
84 fig->setName(name);
85 gcuEditPart->setFigure(fig);
86
87 // Create editparts of operation ports.
88 for (int i = 0; i < gcu->operationPortCount(); i++) {
89 vector<Factory*>::const_iterator iter;
90 for (iter = factories_.begin(); iter != factories_.end(); iter++) {
91 EditPart* portEditPart =
92 (*iter)->createEditPart(gcu->operationPort(i));
93 if (portEditPart != NULL) {
94 EditPolicy* portEditPolicy =
96 if (portEditPolicy != NULL) {
97 portEditPart->installEditPolicy(portEditPolicy);
98 }
99 gcuEditPart->addChild(portEditPart);
100 }
101 }
102 }
103
104 // Create editparts of special register ports.
105 for (int i = 0; i < gcu->specialRegisterPortCount(); i++) {
106 vector<Factory*>::const_iterator iter;
107 for (iter = factories_.begin(); iter != factories_.end(); iter++) {
108 EditPart* portEditPart =
109 (*iter)->createEditPart(gcu->specialRegisterPort(i));
110 if (portEditPart != NULL) {
111 EditPolicy* portEditPolicy =
113 if (portEditPolicy != NULL) {
114 portEditPart->installEditPolicy(portEditPolicy);
115 }
116 gcuEditPart->addChild(portEditPart);
117 }
118 }
119 }
120
121 wxString operations = _T("{ ");
122 for (int i = 0; i < gcu->operationCount(); i++) {
123 if (i > 0) {
124 operations.Append(_T(", "));
125 }
126 operations.Append(
128 }
129 operations.Append(_T(" }"));
130
131 fig->setInfo(operations);
132
133 gcuEditPart->setSelectable(true);
134
136 if (editPolicy != NULL) {
137 gcuEditPart->installEditPolicy(editPolicy);
138 }
139
140 return gcuEditPart;
141
142 } else {
143 return NULL;
144 }
145}
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 * createGCUEditPolicy()
virtual EditPolicy * createSRPortEditPolicy()
virtual ~GCUFactory()
Definition GCUFactory.cc:62
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
Definition GCUFactory.cc:73
GCUFactory(EditPolicyFactory &editPolicyFactory)
Definition GCUFactory.cc:54
virtual TCEString name() const
SpecialRegisterPort * specialRegisterPort(int index) const
int specialRegisterPortCount() const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual FUPort * operationPort(const std::string &name) const
virtual int operationPortCount() const
const std::string & name() const
void setName(const wxString &name)
void setInfo(const wxString &info)
static wxString toWxString(const std::string &source)