OpenASIP  2.0
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. More...
 
 MachineEditPartFactory (MachineEditPartFactory &old)
 Copying not allowed. More...
 
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. More...
 
EditPolicyFactoryeditPolicyFactory_
 Factory which creates edit policies for edit parts. More...
 
- Static Protected Attributes inherited from EditPartFactory
static std::vector< EditPart * > created_
 Container for already created EditParts. More...
 

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 }

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 }

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 }

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 }

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 }

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 }

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 }

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 }

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 
158  ControlUnit* gcu = machine->controlUnit();
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 }

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:
ConnectionEditPart::setSource
void setSource(EditPart *source)
Definition: ConnectionEditPart.cc:56
BridgeFigure::setDirection
void setDirection(BridgeFigure::Direction direction)
TTAMachine::Bridge::sourceBus
Bus * sourceBus() const
TTAMachine::Bridge::destinationBus
Bus * destinationBus() const
FUFactory
Definition: FUFactory.hh:45
IUFactory
Definition: IUFactory.hh:45
MachineEditPartFactory::findConnectedBridges
void findConnectedBridges(ConnectionEditPart *&bridgeEditPart, ConnectionEditPart *&biDirBridge, std::vector< TTAMachine::Bridge * > &bridges, TTAMachine::Bus *bus)
Definition: MachineEditPartFactory.cc:377
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
GCUFactory
Definition: GCUFactory.hh:45
BridgeFactory
Definition: BridgeFactory.hh:45
EditPart::setSelectable
void setSelectable(bool selectable)
MachineEditPartFactory::createEditPart
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
Definition: MachineEditPartFactory.cc:101
TTAMachine::Bus
Definition: Bus.hh:53
EditPartFactory::checkCache
EditPart * checkCache(const TTAMachine::MachinePart *component) const
Definition: EditPartFactory.cc:72
EditPart::installEditPolicy
void installEditPolicy(EditPolicy *editpolicy)
Definition: EditPart.cc:247
BusContainerFigure
Definition: BusContainerFigure.hh:47
SocketContainerFigure
Definition: SocketContainerFigure.hh:46
ConnectionEditPart::target
EditPart * target() const
EditPolicyFactory::createBridgeEditPolicy
virtual EditPolicy * createBridgeEditPolicy()
BridgeFigure::DIR_BIDIR
@ DIR_BIDIR
Definition: BridgeFigure.hh:49
TTAMachine::Machine::Navigator::count
int count() const
BusChainFigure
Definition: BusChainFigure.hh:47
TTAMachine::Bus::hasPreviousBus
virtual bool hasPreviousBus() const
Definition: Bus.cc:473
ConnectionEditPart::source
EditPart * source() const
ContentsFigure
Definition: ContentsFigure.hh:49
EditPartFactory::registerFactory
void registerFactory(Factory *factory)
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
EditPartFactory::writeToCache
void writeToCache(EditPart *editPart)
Definition: EditPartFactory.cc:89
SocketFactory
Definition: SocketFactory.hh:47
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::Machine::bridgeNavigator
virtual BridgeNavigator bridgeNavigator() const
Definition: Machine.cc:404
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
BidirBridgeFigure
Definition: BidirBridgeFigure.hh:46
UnitContainerFigure
Definition: UnitContainerFigure.hh:46
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
EditPart::setModel
void setModel(TTAMachine::MachinePart *model)
TTAMachine::Socket
Definition: Socket.hh:53
MachineEditPartFactory::createBiDirBridge
ConnectionEditPart * createBiDirBridge(ConnectionEditPart *bridge, TTAMachine::Bridge *opposite)
Definition: MachineEditPartFactory.cc:340
EditPartFactory::EditPartFactory
EditPartFactory(EditPolicyFactory &editPolicyFactory)
Definition: EditPartFactory.cc:49
EditPart
Definition: EditPart.hh:60
TTAMachine::Machine::socketNavigator
virtual SocketNavigator socketNavigator() const
Definition: Machine.cc:368
EditPart::model
TTAMachine::MachinePart * model() const
BusFactory
Definition: BusFactory.hh:45
MachineEditPartFactory::getUnits
EditPart * getUnits(TTAMachine::Machine *machine)
Definition: MachineEditPartFactory.cc:152
TTAMachine::Bus::hasNextBus
virtual bool hasNextBus() const
Definition: Bus.cc:488
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
TTAMachine::Bus::previousBus
virtual Bus * previousBus() const
Definition: Bus.cc:518
RFFactory
Definition: RFFactory.hh:45
MachineEditPartFactory::getSockets
EditPart * getSockets(TTAMachine::Machine *machine)
Definition: MachineEditPartFactory.cc:208
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
EditPart::setFigure
void setFigure(Figure *figure)
MachineEditPartFactory::connected
bool connected(const TTAMachine::Bridge *bridge, const TTAMachine::Bus *bus1, const TTAMachine::Bus *bus2)
Definition: MachineEditPartFactory.cc:415
ConnectionEditPart
Definition: ConnectionEditPart.hh:42
ConnectionEditPart::setTarget
void setTarget(EditPart *target)
Definition: ConnectionEditPart.cc:71
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
EditPart::addChild
void addChild(EditPart *child)
Definition: EditPart.cc:260
MachineEditPartFactory::getBusChains
EditPart * getBusChains(TTAMachine::Machine *machine)
Definition: MachineEditPartFactory.cc:239
EditPartFactory::editPolicyFactory_
EditPolicyFactory & editPolicyFactory_
Factory which creates edit policies for edit parts.
Definition: EditPartFactory.hh:64
TTAMachine::Bus::nextBus
virtual Bus * nextBus() const
Definition: Bus.cc:501
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
EditPartFactory::factories_
std::vector< Factory * > factories_
Registered factories.
Definition: EditPartFactory.hh:60
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50