OpenASIP  2.0
Public Member Functions | Private Member Functions | List of all members
UnitPortFactory Class Reference

#include <UnitPortFactory.hh>

Inheritance diagram for UnitPortFactory:
Inheritance graph
Collaboration diagram for UnitPortFactory:
Collaboration graph

Public Member Functions

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

Private Member Functions

UnitPortFactoryoperator= (UnitPortFactory &old)
 Assignment not allowed. More...
 
 UnitPortFactory (UnitPortFactory &old)
 Copying not allowed. More...
 
void addSocket (EditPart *portEditPart, TTAMachine::MachinePart *socket) const
 

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 port EditParts corresponding to a given Machine port object.

Definition at line 45 of file UnitPortFactory.hh.

Constructor & Destructor Documentation

◆ UnitPortFactory() [1/2]

UnitPortFactory::UnitPortFactory ( EditPolicyFactory editPolicyFactory)

The Constructor.

Definition at line 54 of file UnitPortFactory.cc.

54  :
55  EditPartFactory(editPolicyFactory) {
56 
57  registerFactory(new SocketFactory(editPolicyFactory));
58 }

References EditPartFactory::registerFactory().

Here is the call graph for this function:

◆ ~UnitPortFactory()

UnitPortFactory::~UnitPortFactory ( )
virtual

The Destructor.

Definition at line 63 of file UnitPortFactory.cc.

63  {
64 }

◆ UnitPortFactory() [2/2]

UnitPortFactory::UnitPortFactory ( UnitPortFactory old)
private

Copying not allowed.

Member Function Documentation

◆ addSocket()

void UnitPortFactory::addSocket ( EditPart portEditPart,
TTAMachine::MachinePart socket 
) const
private

Creates an EditPart of a socket and adds it as a child to the given EditPart.

Parameters
socketSocket of which to create the EditPart.
portEditPartPort in which to add the socket as a child.

Definition at line 136 of file UnitPortFactory.cc.

138  {
139 
140  EditPart* socketEditPart = NULL;
141  vector<Factory*>::const_iterator i = factories_.begin();
142 
143  while (socketEditPart == NULL && i != factories_.end()) {
144  socketEditPart = (*i)->createEditPart(socket);
145  i++;
146  }
147 
148  assert(socketEditPart != NULL);
149 
150  SocketPortConnFactory connFactory;
151 
152  socketEditPart->addChild(
153  connFactory.createConnection(
154  portEditPart, socketEditPart));
155  portEditPart->addChild(socketEditPart);
156 }

References EditPart::addChild(), assert, SocketPortConnFactory::createConnection(), and EditPartFactory::factories_.

Referenced by createEditPart().

Here is the call graph for this function:

◆ createEditPart()

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

Returns an EditPart corresponding to a port.

Parameters
componentPort of which to create the EditPart.
Returns
NULL if the parameter is not an instance of the Port class.

Implements Factory.

Definition at line 73 of file UnitPortFactory.cc.

73  {
74 
75  Port* port = dynamic_cast<Port*>(component);
76  EditPart* portEditPart = NULL;
77 
78  if (port != NULL) {
79 
80  portEditPart = new EditPart();
81  portEditPart->setModel(port);
82 
83  Figure* fig = NULL;
84 
85  FUPort* fuPort = dynamic_cast<FUPort*>(component);
86  if (fuPort != NULL && fuPort->isTriggering()) {
87  fig = new TriggeringPortFigure(port->name(), port->width());
88  } else {
89  fig = new UnitPortFigure(port->name(), port->width());
90  }
91 
92  portEditPart->setFigure(fig);
93 
94  if (port->inputSocket() != NULL) {
95  addSocket(portEditPart, port->inputSocket());
96  }
97 
98  if (port->outputSocket() != NULL) {
99  addSocket(portEditPart, port->outputSocket());
100  }
101 
102  // number of possible unconnected sockets
103  int unconnectedSockets = 2 - portEditPart->childCount();
104 
105  while (unconnectedSockets > 0) {
106  if (port->unconnectedSocket(unconnectedSockets - 1) != NULL) {
107  addSocket(
108  portEditPart,
109  port->unconnectedSocket(unconnectedSockets - 1));
110  }
111  unconnectedSockets--;
112  }
113  } else {
114  return NULL;
115  }
116 
117  portEditPart->setSelectable(true);
118 
119  // Install editpolicy common to all ports.
121  if (editPolicy != NULL) {
122  portEditPart->installEditPolicy(editPolicy);
123  }
124 
125  return portEditPart;
126 }

References addSocket(), EditPart::childCount(), EditPolicyFactory::createPortEditPolicy(), EditPartFactory::editPolicyFactory_, TTAMachine::Port::inputSocket(), EditPart::installEditPolicy(), TTAMachine::FUPort::isTriggering(), TTAMachine::Port::name(), TTAMachine::Port::outputSocket(), EditPart::setFigure(), EditPart::setModel(), EditPart::setSelectable(), TTAMachine::Port::unconnectedSocket(), and TTAMachine::Port::width().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.


The documentation for this class was generated from the following files:
TTAMachine::Port::unconnectedSocket
virtual Socket * unconnectedSocket(int index) const
Definition: Port.cc:323
SocketPortConnFactory::createConnection
virtual EditPart * createConnection(EditPart *source, EditPart *target) const
Definition: SocketPortConnFactory.cc:66
TTAMachine::Port::inputSocket
virtual Socket * inputSocket() const
Definition: Port.cc:261
EditPolicyFactory::createPortEditPolicy
virtual EditPolicy * createPortEditPolicy()
EditPart::setSelectable
void setSelectable(bool selectable)
EditPart::installEditPolicy
void installEditPolicy(EditPolicy *editpolicy)
Definition: EditPart.cc:247
TTAMachine::Port::width
virtual int width() const =0
UnitPortFigure
Definition: UnitPortFigure.hh:46
TTAMachine::FUPort::isTriggering
virtual bool isTriggering() const
Definition: FUPort.cc:182
EditPartFactory::registerFactory
void registerFactory(Factory *factory)
assert
#define assert(condition)
Definition: Application.hh:86
UnitPortFactory::addSocket
void addSocket(EditPart *portEditPart, TTAMachine::MachinePart *socket) const
Definition: UnitPortFactory.cc:136
TTAMachine::FUPort
Definition: FUPort.hh:46
SocketFactory
Definition: SocketFactory.hh:47
SocketPortConnFactory
Definition: SocketPortConnFactory.hh:44
TTAMachine::Port
Definition: Port.hh:54
Figure
Definition: Figure.hh:50
EditPart::setModel
void setModel(TTAMachine::MachinePart *model)
EditPartFactory::EditPartFactory
EditPartFactory(EditPolicyFactory &editPolicyFactory)
Definition: EditPartFactory.cc:49
EditPolicy
Definition: EditPolicy.hh:47
EditPart
Definition: EditPart.hh:60
EditPart::childCount
int childCount() const
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
EditPart::setFigure
void setFigure(Figure *figure)
TTAMachine::Port::outputSocket
virtual Socket * outputSocket() const
Definition: Port.cc:281
TriggeringPortFigure
Definition: TriggeringPortFigure.hh:45
EditPart::addChild
void addChild(EditPart *child)
Definition: EditPart.cc:260
EditPartFactory::editPolicyFactory_
EditPolicyFactory & editPolicyFactory_
Factory which creates edit policies for edit parts.
Definition: EditPartFactory.hh:64
EditPartFactory::factories_
std::vector< Factory * > factories_
Registered factories.
Definition: EditPartFactory.hh:60