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

#include <ProDeSocketEditPolicy.hh>

Inheritance diagram for ProDeSocketEditPolicy:
Inheritance graph
Collaboration diagram for ProDeSocketEditPolicy:
Collaboration graph

Public Member Functions

 ProDeSocketEditPolicy ()
 
virtual ~ProDeSocketEditPolicy ()
 
virtual ComponentCommandgetCommand (Request *request)
 
virtual bool canHandle (Request *request) const
 
- Public Member Functions inherited from EditPolicy
 EditPolicy ()
 
virtual ~EditPolicy ()
 
EditParthost () const
 
void setHost (EditPart *host)
 

Private Member Functions

ComponentCommandcreateConnectCmd (Request *request)
 
ProDeSocketEditPolicyoperator= (ProDeSocketEditPolicy &old)
 Assignment not allowed.
 
 ProDeSocketEditPolicy (ProDeSocketEditPolicy &old)
 Copying not allowed.
 

Additional Inherited Members

- Protected Attributes inherited from EditPolicy
EditParthost_
 Host EditPart of this EditPolicy.
 

Detailed Description

Determines how a socket EditPart acts when a Request is performed on it.

Converts a given Request to a Command if the EditPolicy supports. the Request.

Definition at line 49 of file ProDeSocketEditPolicy.hh.

Constructor & Destructor Documentation

◆ ProDeSocketEditPolicy() [1/2]

ProDeSocketEditPolicy::ProDeSocketEditPolicy ( )

The Constructor.

Definition at line 61 of file ProDeSocketEditPolicy.cc.

61 : EditPolicy() {
62}

◆ ~ProDeSocketEditPolicy()

ProDeSocketEditPolicy::~ProDeSocketEditPolicy ( )
virtual

The Destructor.

Definition at line 67 of file ProDeSocketEditPolicy.cc.

67 {
68}

◆ ProDeSocketEditPolicy() [2/2]

ProDeSocketEditPolicy::ProDeSocketEditPolicy ( ProDeSocketEditPolicy old)
private

Copying not allowed.

Member Function Documentation

◆ canHandle()

bool ProDeSocketEditPolicy::canHandle ( Request request) const
virtual

Tells whether this EditPolicy is able to handle a certain type of Request.

Parameters
requestRequest to be asked if it can be handled.
Returns
True if the Request can be handled, false otherwise.

Implements EditPolicy.

Definition at line 115 of file ProDeSocketEditPolicy.cc.

115 {
116 Request::RequestType type = request->type();
117 if (type == Request::MODIFY_REQUEST ||
118 type == Request::DELETE_REQUEST ||
119 type == Request::COPY_REQUEST ||
120 type == Request::STATUS_REQUEST) {
121 return true;
122 } else if (type == Request::CONNECT_REQUEST) {
123 ConnectRequest* cr = dynamic_cast<ConnectRequest*>(request);
124 assert(cr != NULL);
125 EditPart* part = cr->part();
126
127 if (part == NULL) {
128 // No selection.
129 // Socket can be selected for connecting, return true.
130 return true;
131 }
132
133 Port* port = dynamic_cast<Port*>(part->model());
134 Segment* segment = dynamic_cast<Segment*>(part->model());
135 if (port == NULL && segment == NULL) {
136 // Socket can be connected only to ports and segments.
137 return false;
138 }
139 MachineTester* tester = NULL;
140 if (port != NULL) {
141 tester = new MachineTester(*(port->parentUnit()->machine()));
142 } else {
143 tester = new MachineTester(*(segment->parentBus()->machine()));
144 }
145 Socket* socket = dynamic_cast<Socket*>(host_->model());
146 if ((port != NULL && (
147 port->isConnectedTo(*socket) ||
148 tester->canConnect(*socket, *port))) ||
149 (segment != NULL && (
150 socket->isConnectedTo(*segment) ||
151 tester->canConnect(*socket, *segment)))) {
152
153 delete tester;
154 return true;
155 }
156 delete tester;
157 return false;
158 } else {
159 return false;
160 }
161}
#define assert(condition)
EditPart * part()
TTAMachine::MachinePart * model() const
EditPart * host_
Host EditPart of this EditPolicy.
Definition EditPolicy.hh:74
virtual bool canConnect(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment)
RequestType
Data type for determining the type of a Request.
Definition Request.hh:46
@ STATUS_REQUEST
Status request.
Definition Request.hh:52
@ MODIFY_REQUEST
Modfify request.
Definition Request.hh:48
@ DELETE_REQUEST
Delete request.
Definition Request.hh:49
@ COPY_REQUEST
Copy request.
Definition Request.hh:51
@ CONNECT_REQUEST
Connect request.
Definition Request.hh:50
RequestType type() const
virtual Machine * machine() const
virtual bool isConnectedTo(const Socket &socket) const
Definition Port.cc:393
Unit * parentUnit() const
Bus * parentBus() const
bool isConnectedTo(const Bus &bus) const
Definition Socket.cc:331

References assert, MachineTester::canConnect(), Request::CONNECT_REQUEST, Request::COPY_REQUEST, Request::DELETE_REQUEST, EditPolicy::host_, TTAMachine::Socket::isConnectedTo(), TTAMachine::Port::isConnectedTo(), TTAMachine::Component::machine(), EditPart::model(), Request::MODIFY_REQUEST, TTAMachine::Segment::parentBus(), TTAMachine::Port::parentUnit(), ConnectRequest::part(), Request::STATUS_REQUEST, and Request::type().

Referenced by createConnectCmd().

Here is the call graph for this function:

◆ createConnectCmd()

ComponentCommand * ProDeSocketEditPolicy::createConnectCmd ( Request request)
private

Creates a command which connects the selected component to the requested component.

Parameters
requestConnectionRequest with the target component for the connection.
Returns
Command for connecting the selected and requested components.

Definition at line 173 of file ProDeSocketEditPolicy.cc.

173 {
174
175 ConnectRequest* cr = dynamic_cast<ConnectRequest*>(request);
176 assert(cr != NULL);
177 EditPart* part = cr->part();
178
179 if (canHandle(request)) {
180 Port* port = dynamic_cast<Port*>(part->model());
181 Segment* segment = dynamic_cast<Segment*>(part->model());
182 Socket* socket = dynamic_cast<Socket*>(host_->model());
183 if (port == NULL && segment == NULL) {
184 return NULL;
185 }
186 ComponentCommand* cmd = NULL;
187 if (port != NULL) {
188 cmd = new SocketPortConnCmd(socket, port);
189 } else {
190 cmd = new SocketBusConnCmd(socket, segment);
191 }
192 return cmd;
193 } else {
194 return NULL;
195 }
196}
virtual bool canHandle(Request *request) const

References assert, canHandle(), EditPolicy::host_, EditPart::model(), and ConnectRequest::part().

Referenced by getCommand().

Here is the call graph for this function:

◆ getCommand()

ComponentCommand * ProDeSocketEditPolicy::getCommand ( Request request)
virtual

Returns the Command corresponding to the type of the Request.

Parameters
requestRequest to be handled.
Returns
NULL if the Request cannot be handled.

Implements EditPolicy.

Definition at line 77 of file ProDeSocketEditPolicy.cc.

77 {
78
79 Request::RequestType type = request->type();
80
81 if (type == Request::MODIFY_REQUEST) {
82 ModifySocketCmd* modifyCmd = new ModifySocketCmd(host_);
83 return modifyCmd;
84
85 } else if (type == Request::DELETE_REQUEST) {
86 DeleteSocketCmd* deleteCmd = new DeleteSocketCmd(host_);
87 return deleteCmd;
88
89 } else if (type == Request::COPY_REQUEST) {
90 CopyComponent* copyCmd = new CopyComponent(host_);
91 return copyCmd;
92
93 } else if (type == Request::STATUS_REQUEST) {
94 Socket* socket = dynamic_cast<Socket*>(host_->model());
96 format fmt = generator->text(ProDeTextGenerator::STATUS_SOCKET);
97 fmt % socket->name();
98 SetStatusTextCmd* statusCmd = new SetStatusTextCmd(fmt.str());
99 return statusCmd;
100 } if (type == Request::CONNECT_REQUEST) {
101 return createConnectCmd(request);
102 } else {
103 return NULL;
104 }
105}
ComponentCommand * createConnectCmd(Request *request)
static ProDeTextGenerator * instance()
@ STATUS_SOCKET
Status line template for sockets.
virtual TCEString name() const
virtual boost::format text(int textId)

References Request::CONNECT_REQUEST, Request::COPY_REQUEST, createConnectCmd(), Request::DELETE_REQUEST, EditPolicy::host_, ProDeTextGenerator::instance(), EditPart::model(), Request::MODIFY_REQUEST, TTAMachine::Component::name(), Request::STATUS_REQUEST, ProDeTextGenerator::STATUS_SOCKET, Texts::TextGenerator::text(), and Request::type().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.


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