OpenASIP 2.2
Loading...
Searching...
No Matches
SocketFactory.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 SocketFactory.cc
26 *
27 * Definition of SocketFactory 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 "Machine.hh"
35#include "SocketFactory.hh"
36#include "Socket.hh"
37#include "EditPart.hh"
38#include "InputSocketFigure.hh"
39#include "OutputSocketFigure.hh"
41#include "EditPolicyFactory.hh"
42
43using std::vector;
44using namespace TTAMachine;
45
46/**
47 * The Constructor.
48 */
50 EditPartFactory(editPolicyFactory) {
51}
52
53/**
54 * The Destructor.
55 */
58
59/**
60 * Returns an EditPart corresponding to a socket.
61 *
62 * @param component Socket of which to create the EditPart.
63 * @return NULL if the parameter is not an instance of the Socket class.
64 */
67
68 EditPart* socketEditPart = EditPartFactory::checkCache(component);
69
70 if (socketEditPart != NULL) {
71 return socketEditPart;
72 }
73
74 Socket* socket = dynamic_cast<Socket*>(component);
75
76 if (socket != NULL) {
77
78 socketEditPart = new EditPart();
79 socketEditPart->setModel(socket);
80
81 Figure* fig = NULL;
82
83 if (socket->direction() == Socket::INPUT) {
84 fig = new InputSocketFigure();
85 } else if (socket->direction() == Socket::OUTPUT) {
86 fig = new OutputSocketFigure();
87 } else {
88 fig = new UnknownSocketFigure();
89 }
90 socketEditPart->setFigure(fig);
91
92 socketEditPart->setSelectable(true);
93
95 if (editPolicy != NULL) {
96 socketEditPart->installEditPolicy(editPolicy);
97 }
98
99 EditPartFactory::writeToCache(socketEditPart);
100 return socketEditPart;
101
102 } else {
103 return NULL;
104 }
105}
EditPart * checkCache(const TTAMachine::MachinePart *component) const
EditPolicyFactory & editPolicyFactory_
Factory which creates edit policies for edit parts.
void writeToCache(EditPart *editPart)
void setModel(TTAMachine::MachinePart *model)
void installEditPolicy(EditPolicy *editpolicy)
Definition EditPart.cc:247
void setFigure(Figure *figure)
void setSelectable(bool selectable)
virtual EditPolicy * createSocketEditPolicy()
SocketFactory(EditPolicyFactory &editPolicyFactory)
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
virtual ~SocketFactory()
@ OUTPUT
Data goes from port to bus.
Definition Socket.hh:60
@ INPUT
Data goes from bus to port.
Definition Socket.hh:59
Direction direction() const