OpenASIP  2.0
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 
47 using std::vector;
48 using 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  */
64 }
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  */
74 EditPart*
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 }
EditPolicyFactory
Definition: EditPolicyFactory.hh:46
WxConversion::toWxString
static wxString toWxString(const std::string &source)
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
EditPart::setSelectable
void setSelectable(bool selectable)
UnitPortFactory.hh
EditPart::installEditPolicy
void installEditPolicy(EditPolicy *editpolicy)
Definition: EditPart.cc:247
AddressSpace.hh
FUFactory::~FUFactory
virtual ~FUFactory()
Definition: FUFactory.cc:63
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
EditPolicyFactory::createFUPortEditPolicy
virtual EditPolicy * createFUPortEditPolicy()
EditPartFactory::registerFactory
void registerFactory(Factory *factory)
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
EditPolicyFactory.hh
HWOperation.hh
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
EditPart.hh
EditPolicyFactory::createFUEditPolicy
virtual EditPolicy * createFUEditPolicy()
EditPartFactory
Definition: EditPartFactory.hh:48
UnitFigure::setInfo
void setInfo(const wxString &info)
Definition: UnitFigure.cc:323
EditPart::setModel
void setModel(TTAMachine::MachinePart *model)
TTAMachine::MachinePart
Definition: MachinePart.hh:57
FUFactory.hh
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
UnitFigure::setName
void setName(const wxString &name)
Definition: UnitFigure.cc:304
EditPolicy
Definition: EditPolicy.hh:47
EditPart
Definition: EditPart.hh:60
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
UnitFigure.hh
UnitPortFactory
Definition: UnitPortFactory.hh:45
FUFactory::createEditPart
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
Definition: FUFactory.cc:75
FUFactory::FUFactory
FUFactory(EditPolicyFactory &editPolicyFactory)
Definition: FUFactory.cc:53
UnitFigure
Definition: UnitFigure.hh:46
FUPort.hh
EditPart::setFigure
void setFigure(Figure *figure)
WxConversion.hh
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
EditPart::addChild
void addChild(EditPart *child)
Definition: EditPart.cc:260
TTAMachine
Definition: Assembler.hh:48
EditPartFactory::editPolicyFactory_
EditPolicyFactory & editPolicyFactory_
Factory which creates edit policies for edit parts.
Definition: EditPartFactory.hh:64
FunctionUnit.hh
EditPartFactory::factories_
std::vector< Factory * > factories_
Registered factories.
Definition: EditPartFactory.hh:60