OpenASIP  2.0
ProximRFEditPolicy.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 ProximRFEditPolicy.cc
26  *
27  * Implementation of ProximRFEditPolicy class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include "ProximRFEditPolicy.hh"
35 #include "Application.hh"
36 #include "Request.hh"
37 #include "RegisterFile.hh"
38 #include "EditPart.hh"
41 #include "ProximRFDetailsCmd.hh"
42 #include "ProximConstants.hh"
43 
44 using namespace TTAMachine;
45 using std::string;
46 
47 /**
48  * The Constructor.
49  */
51  EditPolicy() {
52 }
53 
54 /**
55  * The Destructor.
56  */
58 }
59 
60 /**
61  * Tells whether this EditPolicy can handle request of the given type.
62  *
63  * @param Request to be handled.
64  * @return True, if the editpolicy can handle give request type.
65  */
66 bool
68 
69  Request::RequestType type = request->type();
70  if (type == Request::MODIFY_REQUEST ||
71  type == Request::STATUS_REQUEST ||
72  type == Request::DETAILS_REQUEST) {
73 
74  return true;
75  }
76 
77  return false;
78 }
79 
80 
81 /**
82  * Creates command corresponding to a request.
83  *
84  * @paran request Request to handle.
85  * @return Null, if the request can't be handled.
86  */
89 
90  Request::RequestType type = request->type();
91  if (type == Request::MODIFY_REQUEST) {
92  return new ProximShowRegistersCmd(host_);
93  } else if (type == Request::STATUS_REQUEST) {
94 
95  const RegisterFile* rf = dynamic_cast<const RegisterFile*>(
96  host_->model());
97 
98  assert(rf != NULL);
99  string status = ProximConstants::MACH_WIN_RF_LABEL + rf->name();
100  return new ProximComponentStatusCmd(status);
101 
102  } else if (type == Request::DETAILS_REQUEST) {
103 
104  const RegisterFile* rf = dynamic_cast<const RegisterFile*>(
105  host_->model());
106 
107  assert(rf != NULL);
108  return new ProximRFDetailsCmd(*rf);
109  }
110  return NULL;
111 }
Request::type
RequestType type() const
ProximComponentStatusCmd.hh
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ProximRFEditPolicy::getCommand
virtual ComponentCommand * getCommand(Request *request)
Definition: ProximRFEditPolicy.cc:88
ProximRFEditPolicy.hh
ProximRFEditPolicy::ProximRFEditPolicy
ProximRFEditPolicy()
Definition: ProximRFEditPolicy.cc:50
assert
#define assert(condition)
Definition: Application.hh:86
ProximShowRegistersCmd
Definition: ProximShowRegistersCmd.hh:45
Request.hh
Request::DETAILS_REQUEST
@ DETAILS_REQUEST
Detailed info request.
Definition: Request.hh:53
EditPart.hh
ProximConstants::MACH_WIN_RF_LABEL
static const std::string MACH_WIN_RF_LABEL
Label precing register file names in the machine state window.
Definition: ProximConstants.hh:214
ProximRFDetailsCmd.hh
EditPolicy::host_
EditPart * host_
Host EditPart of this EditPolicy.
Definition: EditPolicy.hh:74
Application.hh
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
ProximRFEditPolicy::canHandle
virtual bool canHandle(Request *request) const
Definition: ProximRFEditPolicy.cc:67
ProximConstants.hh
RegisterFile.hh
ProximShowRegistersCmd.hh
Request::MODIFY_REQUEST
@ MODIFY_REQUEST
Modfify request.
Definition: Request.hh:48
Request::STATUS_REQUEST
@ STATUS_REQUEST
Status request.
Definition: Request.hh:52
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine
Definition: Assembler.hh:48
ProximComponentStatusCmd
Definition: ProximComponentStatusCmd.hh:42
ProximRFEditPolicy::~ProximRFEditPolicy
virtual ~ProximRFEditPolicy()
Definition: ProximRFEditPolicy.cc:57
ProximRFDetailsCmd
Definition: ProximRFDetailsCmd.hh:46