OpenASIP 2.2
Loading...
Searching...
No Matches
IUFactory.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 IUFactory.cc
26 *
27 * Definition of IUFactory 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 "IUFactory.hh"
38#include "UnitPortFactory.hh"
39#include "ImmediateUnit.hh"
40#include "EditPart.hh"
41#include "UnitFigure.hh"
42#include "FUPort.hh"
43#include "WxConversion.hh"
44#include "EditPolicyFactory.hh"
45
46using std::vector;
47using namespace TTAMachine;
48
49/**
50 * The Constructor.
51 */
53 EditPartFactory(editPolicyFactory) {
54
55 registerFactory(new UnitPortFactory(editPolicyFactory));
56}
57
58/**
59 * The Destructor.
60 */
63
64/**
65 * Returns an EditPart corresponding to a immediate unit.
66 *
67 * @param component Immediate unit of which to create the EditPart.
68 * @return NULL if the parameter is not an instance of the
69 * ImmediateUnit class.
70 */
73
74 ImmediateUnit* imm = dynamic_cast<ImmediateUnit*>(component);
75
76 if (imm != NULL) {
77 EditPart* immEditPart = new EditPart();
78 immEditPart->setModel(imm);
79
80 UnitFigure* fig = new UnitFigure();
81 wxString name = WxConversion::toWxString(imm->name());
82 name.Prepend(_T("IMM: "));
83 fig->setName(name);
84 immEditPart->setFigure(fig);
85
86 for (int i = 0; i < imm->portCount(); i++) {
87 vector<Factory*>::const_iterator iter;
88 for (iter = factories_.begin(); iter != factories_.end(); iter++) {
89 EditPart* portEditPart =
90 (*iter)->createEditPart(imm->port(i));
91 if (portEditPart != NULL) {
92 EditPolicy* editPolicy =
94 if (editPolicy != NULL) {
95 portEditPart->installEditPolicy(editPolicy);
96 }
97 immEditPart->addChild(portEditPart);
98 }
99 }
100 }
101
102
103 wxString info = WxConversion::toWxString(imm->numberOfRegisters());
104 info.Append(_T("x"));
105 info.Append(WxConversion::toWxString(imm->width()));
106 fig->setInfo(info);
107 immEditPart->setSelectable(true);
108
110 if (editPolicy != NULL) {
111 immEditPart->installEditPolicy(editPolicy);
112 }
113
114 return immEditPart;
115
116 } else {
117 return NULL;
118 }
119}
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 * createIUPortEditPolicy()
virtual EditPolicy * createIUEditPolicy()
virtual ~IUFactory()
Definition IUFactory.cc:61
IUFactory(EditPolicyFactory &editPolicyFactory)
Definition IUFactory.cc:52
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
Definition IUFactory.cc:72
virtual int numberOfRegisters() const
virtual int width() const
virtual RFPort * port(const std::string &name) const
virtual TCEString 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)