OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
MachineEditPartFactory Class Reference

#include <MachineEditPartFactory.hh>

Inheritance diagram for MachineEditPartFactory:
Inheritance graph
Collaboration diagram for MachineEditPartFactory:
Collaboration graph

Public Member Functions

 MachineEditPartFactory (EditPolicyFactory &editPolicyFactory)
 
virtual ~MachineEditPartFactory ()
 
virtual EditPartcreateEditPart (TTAMachine::MachinePart *component)
 
EditPartcreateEditPart (TTAMachine::Machine *machine)
 
- Public Member Functions inherited from EditPartFactory
virtual ~EditPartFactory ()
 
void registerFactory (Factory *factory)
 
- Public Member Functions inherited from Factory
virtual ~Factory ()
 

Private Member Functions

MachineEditPartFactoryoperator= (MachineEditPartFactory &old)
 Assignment not allowed.
 
 MachineEditPartFactory (MachineEditPartFactory &old)
 Copying not allowed.
 
EditPartgetUnits (TTAMachine::Machine *machine)
 
EditPartgetSockets (TTAMachine::Machine *machine)
 
EditPartgetBusChains (TTAMachine::Machine *machine)
 
ConnectionEditPartcreateBiDirBridge (ConnectionEditPart *bridge, TTAMachine::Bridge *opposite)
 
void findConnectedBridges (ConnectionEditPart *&bridgeEditPart, ConnectionEditPart *&biDirBridge, std::vector< TTAMachine::Bridge * > &bridges, TTAMachine::Bus *bus)
 
bool connected (const TTAMachine::Bridge *bridge, const TTAMachine::Bus *bus1, const TTAMachine::Bus *bus2)
 

Additional Inherited Members

- Protected Member Functions inherited from EditPartFactory
 EditPartFactory (EditPolicyFactory &editPolicyFactory)
 
EditPartcheckCache (const TTAMachine::MachinePart *component) const
 
void writeToCache (EditPart *editPart)
 
- Protected Member Functions inherited from Factory
 Factory ()
 
- Protected Attributes inherited from EditPartFactory
std::vector< Factory * > factories_
 Registered factories.
 
EditPolicyFactoryeditPolicyFactory_
 Factory which creates edit policies for edit parts.
 
- Static Protected Attributes inherited from EditPartFactory
static std::vector< EditPart * > created_
 Container for already created EditParts.
 

Detailed Description

Factory for creating EditParts from any Machine component or the Machine itself.

Definition at line 55 of file MachineEditPartFactory.hh.

Constructor & Destructor Documentation

◆ MachineEditPartFactory() [1/2]

MachineEditPartFactory::MachineEditPartFactory ( EditPolicyFactory editPolicyFactory)
explicit

The Constructor.

Definition at line 73 of file MachineEditPartFactory.cc.

74 :
75 EditPartFactory(editPolicyFactory) {
76
77 registerFactory(new GCUFactory(editPolicyFactory));
78 registerFactory(new FUFactory(editPolicyFactory));
79 registerFactory(new IUFactory(editPolicyFactory));
80 registerFactory(new RFFactory(editPolicyFactory));
81 registerFactory(new BridgeFactory(editPolicyFactory));
82 registerFactory(new SocketFactory(editPolicyFactory));
83 registerFactory(new BusFactory(editPolicyFactory));
84}
void registerFactory(Factory *factory)

References EditPartFactory::registerFactory().

Here is the call graph for this function:

◆ ~MachineEditPartFactory()

MachineEditPartFactory::~MachineEditPartFactory ( )
virtual

The Destructor.

Definition at line 90 of file MachineEditPartFactory.cc.

90 {
91}

◆ MachineEditPartFactory() [2/2]

MachineEditPartFactory::MachineEditPartFactory ( MachineEditPartFactory old)
private

Copying not allowed.

Member Function Documentation

◆ connected()

bool MachineEditPartFactory::connected ( const TTAMachine::Bridge bridge,
const TTAMachine::Bus bus1,
const TTAMachine::Bus bus2 
)
private

Tells whether a bridge is connected to two specific buses.

Parameters
bridgeThe bridge.
bus1One bus.
bus2The other bus.
Returns
True if the bridge is connected to the buses, false otherwise.

Definition at line 415 of file MachineEditPartFactory.cc.

418 {
419
420 return (bridge->sourceBus() == bus1 &&
421 bridge->destinationBus() == bus2) ||
422 (bridge->destinationBus() == bus1 &&
423 bridge->sourceBus() == bus2);
424}
Bus * destinationBus() const
Bus * sourceBus() const

References TTAMachine::Bridge::destinationBus(), and TTAMachine::Bridge::sourceBus().

Referenced by findConnectedBridges().

Here is the call graph for this function:

◆ createBiDirBridge()

ConnectionEditPart * MachineEditPartFactory::createBiDirBridge ( ConnectionEditPart bridge,
TTAMachine::Bridge opposite 
)
private

Creates an EditPart for a bidirectional bridge.

Parameters
bridgeEditPart representing one of the bridges.
oppositeThe opposite bridge.
Returns
EditPart for the bidirectional bridge.

Definition at line 340 of file MachineEditPartFactory.cc.

342 {
343
344 ConnectionEditPart* biDirBridge = new ConnectionEditPart();
345 biDirBridge->setSelectable(true);
348 biDirBridge->setFigure(fig);
349 EditPart* oppositeBridge = createEditPart(opposite);
350 bridge->setSelectable(false);
351 oppositeBridge->setSelectable(false);
352
353 biDirBridge->setModel(bridge->model());
354 biDirBridge->setSource(bridge->source());
355 biDirBridge->setTarget(bridge->target());
356
357 biDirBridge->installEditPolicy(
359
360 biDirBridge->addChild(bridge);
361 biDirBridge->addChild(oppositeBridge);
362
363 return biDirBridge;
364}
void setDirection(BridgeFigure::Direction direction)
EditPart * source() const
EditPart * target() const
void setSource(EditPart *source)
void setTarget(EditPart *target)
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
TTAMachine::MachinePart * model() const
virtual EditPolicy * createBridgeEditPolicy()
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)

References EditPart::addChild(), EditPolicyFactory::createBridgeEditPolicy(), createEditPart(), BridgeFigure::DIR_BIDIR, EditPartFactory::editPolicyFactory_, EditPart::installEditPolicy(), EditPart::model(), BridgeFigure::setDirection(), EditPart::setFigure(), EditPart::setModel(), EditPart::setSelectable(), ConnectionEditPart::setSource(), ConnectionEditPart::setTarget(), ConnectionEditPart::source(), and ConnectionEditPart::target().

Referenced by findConnectedBridges().

Here is the call graph for this function:

◆ createEditPart() [1/2]

EditPart * MachineEditPartFactory::createEditPart ( TTAMachine::Machine machine)

Overloaded implementation for creating the contents EditPart from the machine.

Parameters
machineMachine to create the EditPart from.
Returns
The created contents EditPart corresponding to the machine.

Definition at line 130 of file MachineEditPartFactory.cc.

130 {
131
132 EditPart* contents = new EditPart();
133 contents->setFigure(new ContentsFigure());
134
135 contents->addChild(getUnits(machine));
136 contents->addChild(getSockets(machine));
137 contents->addChild(getBusChains(machine));
138
139 return contents;
140}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
EditPart * getUnits(TTAMachine::Machine *machine)
EditPart * getSockets(TTAMachine::Machine *machine)
EditPart * getBusChains(TTAMachine::Machine *machine)

References EditPart::addChild(), getBusChains(), getSockets(), getUnits(), machine, and EditPart::setFigure().

Here is the call graph for this function:

◆ createEditPart() [2/2]

EditPart * MachineEditPartFactory::createEditPart ( TTAMachine::MachinePart component)
virtual

Delegates to registered factories to create the EditPart.

Parameters
componentComponent of which to create the corresponding EditPart.
Returns
NULL if none of the factories can create the EditPart.

Implements Factory.

Definition at line 101 of file MachineEditPartFactory.cc.

101 {
102
103 EditPart* ep = EditPartFactory::checkCache(component);
104
105 if (ep != NULL) {
106 return ep;
107 }
108
109 vector<Factory*>::const_iterator i = factories_.begin();
110
111 for (; i != factories_.end(); i++) {
112 ep = (*i)->createEditPart(component);
113 if (ep != NULL) {
115 return ep;
116 }
117 }
118
119 return NULL;
120}
std::vector< Factory * > factories_
Registered factories.
EditPart * checkCache(const TTAMachine::MachinePart *component) const
void writeToCache(EditPart *editPart)

References EditPartFactory::checkCache(), EditPartFactory::factories_, and EditPartFactory::writeToCache().

Referenced by createBiDirBridge(), findConnectedBridges(), getBusChains(), getSockets(), getUnits(), and MachineCanvas::updateMachine().

Here is the call graph for this function:

◆ findConnectedBridges()

void MachineEditPartFactory::findConnectedBridges ( ConnectionEditPart *&  bridgeEditPart,
ConnectionEditPart *&  biDirBridge,
std::vector< TTAMachine::Bridge * > &  bridges,
TTAMachine::Bus bus 
)
private

Finds and returns the bridge or bridges that are connected to a bus.

Parameters
bridgeEditPartWhere to store one bridge, no change if no bridge found.
biDirBridgeWhere to store the other bridge, no change if no other bridge found.
bridgesWhich bridges to search.
busBus to which the searched bridges should be connected.

Definition at line 377 of file MachineEditPartFactory.cc.

381 {
382
383 unsigned int j = 0;
384
385 while (j < bridges.size()) {
386 if (connected(bridges[j], bus, bus->nextBus())) {
387 bridgeEditPart = dynamic_cast<ConnectionEditPart*>(
388 createEditPart(bridges[j]));
389 break;
390 }
391 j++;
392 }
393
394 // check if the bridge is bidirectional
395 j++;
396 while (j < bridges.size()) {
397 if (connected(bridges[j], bus, bus->nextBus())) {
398 biDirBridge =
399 createBiDirBridge(bridgeEditPart, bridges[j]);
400 break;
401 }
402 j++;
403 }
404}
bool connected(const TTAMachine::Bridge *bridge, const TTAMachine::Bus *bus1, const TTAMachine::Bus *bus2)
ConnectionEditPart * createBiDirBridge(ConnectionEditPart *bridge, TTAMachine::Bridge *opposite)
virtual Bus * nextBus() const
Definition Bus.cc:501

References connected(), createBiDirBridge(), createEditPart(), and TTAMachine::Bus::nextBus().

Referenced by getBusChains().

Here is the call graph for this function:

◆ getBusChains()

EditPart * MachineEditPartFactory::getBusChains ( TTAMachine::Machine machine)
private

Navigates through the machine and creates a bus container EditPart.

Returns a NULL pointer if there are no buses in the given machine.

Parameters
machineMachine to navigate through.
Returns
An EditPart containing EditParts for all the buses and bus chains in the given machine or NULL if there aren't any.

Definition at line 239 of file MachineEditPartFactory.cc.

239 {
240
242
243 EditPart* busContainer = NULL;
244
245 if (busNav.count() > 0) {
246
247 set<Bus*> sorted;
248 busContainer = new EditPart();
249 busContainer->setFigure(new BusContainerFigure());
250 vector<Bus*> buses;
251
252 for (int i = 0; i < busNav.count(); i++) {
253 buses.push_back(busNav.item(i));
254 }
255
256 // get bridges
257
259 vector<Bridge*> bridges;
260
261 for (int i = 0; i < bridgeNav.count(); i++) {
262 bridges.push_back(bridgeNav.item(i));
263 }
264
265 // sort the bus chains
266
267 for (unsigned int i = 0; i < buses.size(); i++) {
268
269 if (!ContainerTools::containsValue(sorted, buses[i])) {
270
271 sorted.insert(buses[i]);
272 Bus* first = buses[i];
273
274 // browse to the beginning of the chain
275 while (first->hasPreviousBus()) {
276 first = first->previousBus();
277 }
278
279 // start adding buses to the chain
280
281 if (first->hasNextBus()) {
282
283 EditPart* busChain = new EditPart();
284 busChain->setFigure(new BusChainFigure());
285
286 while (true) {
287 sorted.insert(first);
288
289 // find also the bridge(s) in between
290 ConnectionEditPart* bridgeEditPart = NULL;
291 ConnectionEditPart* biDirBridge = NULL;
292
293 if (first->hasNextBus()) {
295 bridgeEditPart, biDirBridge, bridges, first);
296 }
297
298 // add the bus and the following bridge to the chain
299
300 EditPart* nextEditPart = createEditPart(first);
301 assert(nextEditPart != NULL);
302 busChain->addChild(nextEditPart);
303
304 if (biDirBridge != NULL) {
305 busChain->addChild(biDirBridge);
306 } else if (bridgeEditPart != NULL) {
307 busChain->addChild(bridgeEditPart);
308 }
309
310 if (first->hasNextBus()) {
311 first = first->nextBus();
312 } else {
313 break;
314 }
315 }
316
317 busContainer->addChild(busChain);
318
319 } else {
320 // add a single bus
321 EditPart* busEditPart = createEditPart(buses[i]);
322 assert(busEditPart != NULL);
323 busContainer->addChild(busEditPart);
324 }
325 }
326 }
327 }
328
329 return busContainer;
330}
#define assert(condition)
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
void findConnectedBridges(ConnectionEditPart *&bridgeEditPart, ConnectionEditPart *&biDirBridge, std::vector< TTAMachine::Bridge * > &bridges, TTAMachine::Bus *bus)
virtual Bus * previousBus() const
Definition Bus.cc:518
virtual bool hasPreviousBus() const
Definition Bus.cc:473
virtual bool hasNextBus() const
Definition Bus.cc:488
ComponentType * item(int index) const
virtual BridgeNavigator bridgeNavigator() const
Definition Machine.cc:404
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

References EditPart::addChild(), assert, TTAMachine::Machine::bridgeNavigator(), TTAMachine::Machine::busNavigator(), ContainerTools::containsValue(), TTAMachine::Machine::Navigator< ComponentType >::count(), createEditPart(), findConnectedBridges(), TTAMachine::Bus::hasNextBus(), TTAMachine::Bus::hasPreviousBus(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, TTAMachine::Bus::nextBus(), TTAMachine::Bus::previousBus(), and EditPart::setFigure().

Referenced by createEditPart().

Here is the call graph for this function:

◆ getSockets()

EditPart * MachineEditPartFactory::getSockets ( TTAMachine::Machine machine)
private

Navigates through the machine and creates a socket container EditPart.

Returns a NULL pointer if there are no sockets in the given machine.

Parameters
machineMachine to navigate through.
Returns
An EditPart containing EditParts for all the sockets in the given machine or NULL if there aren't any.

Definition at line 208 of file MachineEditPartFactory.cc.

208 {
209
211 EditPart* sockets = NULL;
212
213 if (socketNav.count() > 0) {
214
215 sockets = new EditPart();
216 sockets->setFigure(new SocketContainerFigure());
217
218 for (int i = 0; i < socketNav.count(); i++) {
219 Socket* socket = socketNav.item(i);
220 EditPart* ep = createEditPart(socket);
221 assert(ep != NULL);
222 sockets->addChild(ep);
223 }
224 }
225
226 return sockets;
227}
virtual SocketNavigator socketNavigator() const
Definition Machine.cc:368

References EditPart::addChild(), assert, TTAMachine::Machine::Navigator< ComponentType >::count(), createEditPart(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, EditPart::setFigure(), and TTAMachine::Machine::socketNavigator().

Referenced by createEditPart().

Here is the call graph for this function:

◆ getUnits()

EditPart * MachineEditPartFactory::getUnits ( TTAMachine::Machine machine)
private

Navigates through the machine and creates a unit container EditPart.

Returns a NULL pointer if there are no units in the given machine.

Parameters
machineMachine to navigate through.
Returns
An EditPart containing EditParts for all the units in the given machine or NULL if there aren't any.

Definition at line 152 of file MachineEditPartFactory.cc.

152 {
153
157
159 EditPart* units = NULL;
160
161 if (fuNav.count() > 0 || rfNav.count() > 0 || iuNav.count() > 0 ||
162 gcu != NULL) {
163
164 units = new EditPart();
165 units->setFigure(new UnitContainerFigure());
166
167 for (int i = 0; i < fuNav.count(); i++) {
168 FunctionUnit* fu = fuNav.item(i);
169 EditPart* ep = createEditPart(fu);
170 assert(ep != NULL);
171 units->addChild(ep);
172 }
173
174 for (int i = 0; i < rfNav.count(); i++) {
175 RegisterFile* rf = rfNav.item(i);
176 EditPart* ep = createEditPart(rf);
177 assert(ep != NULL);
178 units->addChild(ep);
179 }
180
181 for (int i = 0; i < iuNav.count(); i++) {
182 ImmediateUnit* iu = iuNav.item(i);
183 EditPart* ep = createEditPart(iu);
184 assert(ep != NULL);
185 units->addChild(ep);
186 }
187
188 if (gcu != NULL) {
189 EditPart* ep = createEditPart(gcu);
190 assert(ep != NULL);
191 units->addChild(ep);
192 }
193 }
194
195 return units;
196}
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

References EditPart::addChild(), assert, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), createEditPart(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, TTAMachine::Machine::registerFileNavigator(), and EditPart::setFigure().

Referenced by createEditPart().

Here is the call graph for this function:

◆ operator=()

MachineEditPartFactory & MachineEditPartFactory::operator= ( MachineEditPartFactory old)
private

Assignment not allowed.


The documentation for this class was generated from the following files: