OpenASIP  2.0
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 
33 #include "ProximPortEditPolicy.hh"
34 #include "Request.hh"
36 #include "Port.hh"
37 #include "FUPort.hh"
38 #include "EditPart.hh"
40 
41 using namespace TTAMachine;
42 
43 /**
44  * The Constructor.
45  */
47  EditPolicy() {
48 }
49 
50 
51 /**
52  * The Destructor.
53  */
55 }
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  */
63 bool
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 }
ProximPortEditPolicy::getCommand
virtual ComponentCommand * getCommand(Request *request)
Definition: ProximPortEditPolicy.cc:90
Request::type
RequestType type() const
ProximPortEditPolicy::ProximPortEditPolicy
ProximPortEditPolicy()
Definition: ProximPortEditPolicy.cc:46
ProximComponentStatusCmd.hh
ProximFUPortDetailsCmd
Definition: ProximFUPortDetailsCmd.hh:46
assert
#define assert(condition)
Definition: Application.hh:86
Port.hh
TTAMachine::FUPort
Definition: FUPort.hh:46
Request.hh
ProximFUPortDetailsCmd.hh
Request::DETAILS_REQUEST
@ DETAILS_REQUEST
Detailed info request.
Definition: Request.hh:53
EditPart.hh
TTAMachine::Port
Definition: Port.hh:54
EditPolicy::host_
EditPart * host_
Host EditPart of this EditPolicy.
Definition: EditPolicy.hh:74
Request::RequestType
RequestType
Data type for determining the type of a Request.
Definition: Request.hh:46
EditPolicy
Definition: EditPolicy.hh:47
EditPart::model
TTAMachine::MachinePart * model() const
Request
Definition: Request.hh:43
ComponentCommand
Definition: ComponentCommand.hh:46
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
FUPort.hh
ProximPortEditPolicy.hh
Request::STATUS_REQUEST
@ STATUS_REQUEST
Status request.
Definition: Request.hh:52
TTAMachine
Definition: Assembler.hh:48
ProximComponentStatusCmd
Definition: ProximComponentStatusCmd.hh:42
ProximPortEditPolicy::canHandle
virtual bool canHandle(Request *request) const
Definition: ProximPortEditPolicy.cc:64
ProximPortEditPolicy::~ProximPortEditPolicy
virtual ~ProximPortEditPolicy()
Definition: ProximPortEditPolicy.cc:54