OpenASIP 2.2
Loading...
Searching...
No Matches
ProximPortEditPolicy.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 ProximPortEditPolicy.cc
26 *
27 * Implementation of ProximPortEditPolicy class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
34#include "Request.hh"
36#include "Port.hh"
37#include "FUPort.hh"
38#include "EditPart.hh"
40
41using namespace TTAMachine;
42
43/**
44 * The Constructor.
45 */
49
50
51/**
52 * The Destructor.
53 */
56
57/**
58 * Tells whether this EditPolicy can handle request of the given type.
59 *
60 * @param Request to be handled.
61 * @return True, if the editpolicy can handle give request type.
62 */
63bool
65
66 Request::RequestType type = request->type();
67 if (type == Request::STATUS_REQUEST) {
68 return true;
69 } else if (type == Request::DETAILS_REQUEST) {
70 // Details only available for function unit ports.
71 const FUPort* fuPort =
72 dynamic_cast<const FUPort*>(host_->model());
73
74 if (fuPort != NULL) {
75 return true;
76 }
77 }
78
79 return false;
80}
81
82
83/**
84 * Returns command correspoding to the request type.
85 *
86 * @param request Request to handle.
87 * @return NULL, if the request can't be handled.
88 */
91
92 Request::RequestType type = request->type();
93
94 if (type == Request::STATUS_REQUEST) {
95 const Port* port = dynamic_cast<Port*>(host_->model());
96 assert(port != NULL);
97 std::string name = port->name();
98 return new ProximComponentStatusCmd("Port: " + name);
99 } else if (type == Request::DETAILS_REQUEST) {
100 const FUPort* fuPort =
101 dynamic_cast<const FUPort*>(host_->model());
102 if (fuPort == NULL) {
103 return NULL;
104 } else {
105 return new ProximFUPortDetailsCmd(*fuPort);
106 }
107 }
108
109 return NULL;
110}
#define assert(condition)
TTAMachine::MachinePart * model() const
EditPart * host_
Host EditPart of this EditPolicy.
Definition EditPolicy.hh:74
virtual bool canHandle(Request *request) const
virtual ComponentCommand * getCommand(Request *request)
RequestType
Data type for determining the type of a Request.
Definition Request.hh:46
@ DETAILS_REQUEST
Detailed info request.
Definition Request.hh:53
@ STATUS_REQUEST
Status request.
Definition Request.hh:52
RequestType type() const
virtual std::string name() const
Definition Port.cc:141