OpenASIP 2.2
Loading...
Searching...
No Matches
RFFactory.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 RFFactory.cc
26 *
27 * Definition of RFFactory 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 "RFFactory.hh"
38#include "UnitPortFactory.hh"
39#include "RegisterFile.hh"
40#include "EditPart.hh"
41#include "UnitFigure.hh"
42#include "WxConversion.hh"
43#include "FUPort.hh"
44#include "EditPolicyFactory.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 * The Destructor.
61 */
64
65/**
66 * Returns an EditPart corresponding to a register file.
67 *
68 * @param component Register file of which to create the EditPart.
69 * @return NULL if the parameter is not an instance of the
70 * RegisterFile class.
71 */
74
75 RegisterFile* rf = dynamic_cast<RegisterFile*>(component);
76
77 if (rf != NULL) {
78 EditPart* rfEditPart = new EditPart();
79 rfEditPart->setModel(rf);
80
81 UnitFigure* fig = new UnitFigure();
82 wxString name = WxConversion::toWxString(rf->name().c_str());
83 name.Prepend(_T("RF: "));
84 fig->setName(name);
85 rfEditPart->setFigure(fig);
86
87 for (int i = 0; i < rf->portCount(); i++) {
88 vector<Factory*>::const_iterator iter;
89 for (iter = factories_.begin(); iter != factories_.end(); iter++) {
90 EditPart* portEditPart =
91 (*iter)->createEditPart(rf->port(i));
92 if (portEditPart != NULL) {
93
94 EditPolicy* editPolicy =
96
97 if (editPolicy != NULL) {
98 portEditPart->installEditPolicy(editPolicy);
99 }
100
101 rfEditPart->addChild(portEditPart);
102 }
103 }
104 }
105
106 wxString info;
107 if (dynamic_cast<UnboundedRegisterFile*>(rf) != NULL) {
108 info.Append(_T("?"));
109 } else {
111 }
112 info.Append(_T("x"));
113 info.Append(WxConversion::toWxString(rf->width()));
114
115 fig->setInfo(info);
116
117 rfEditPart->setSelectable(true);
118
120 if (editPolicy != NULL) {
121 rfEditPart->installEditPolicy(editPolicy);
122 }
123
124 return rfEditPart;
125
126 } else {
127 return NULL;
128 }
129}
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 * createRFPortEditPolicy()
virtual EditPolicy * createRFEditPolicy()
virtual ~RFFactory()
Definition RFFactory.cc:62
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
Definition RFFactory.cc:73
RFFactory(EditPolicyFactory &editPolicyFactory)
Definition RFFactory.cc:53
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)