OpenASIP
2.2
Loading...
Searching...
No Matches
src
procgen
ProDe
ProDeBusEditPolicy.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 ProDeBusEditPolicy.cc
26
*
27
* Definition of ProDeBusEditPolicy class.
28
*
29
* @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30
* @note rating: yellow
31
* @note reviewed Jul 20 2004 by vpj, jn, am
32
*/
33
34
#include <string>
35
#include <boost/format.hpp>
36
37
#include "
ProDeBusEditPolicy.hh
"
38
#include "
Request.hh
"
39
#include "
ComponentCommand.hh
"
40
#include "
SetStatusTextCmd.hh
"
41
#include "
ModifyBusCmd.hh
"
42
#include "
DeleteBusCmd.hh
"
43
#include "
CopyComponent.hh
"
44
#include "
EditPart.hh
"
45
#include "
MachinePart.hh
"
46
#include "
Bus.hh
"
47
#include "
ProDeTextGenerator.hh
"
48
#include "
Conversion.hh
"
49
50
using
boost::format;
51
using
std::string;
52
using namespace
TTAMachine
;
53
54
/**
55
* The Constructor.
56
*/
57
ProDeBusEditPolicy::ProDeBusEditPolicy
():
EditPolicy
() {
58
}
59
60
/**
61
* The Destructor.
62
*/
63
ProDeBusEditPolicy::~ProDeBusEditPolicy
() {
64
}
65
66
/**
67
* Returns the Command corresponding to the type of the Request.
68
*
69
* @param request Request to be handled.
70
* @return NULL if the Request cannot be handled.
71
*/
72
ComponentCommand
*
73
ProDeBusEditPolicy::getCommand
(
Request
* request) {
74
75
Request::RequestType
type = request->
type
();
76
77
if
(type ==
Request::MODIFY_REQUEST
) {
78
ModifyBusCmd
* modifyCmd =
new
ModifyBusCmd
(
host_
);
79
return
modifyCmd;
80
81
}
else
if
(type ==
Request::DELETE_REQUEST
) {
82
DeleteBusCmd
* deleteCmd =
new
DeleteBusCmd
(
host_
);
83
return
deleteCmd;
84
85
}
else
if
(type ==
Request::COPY_REQUEST
) {
86
CopyComponent
* copyCmd =
new
CopyComponent
(
host_
);
87
return
copyCmd;
88
89
}
else
if
(type ==
Request::STATUS_REQUEST
) {
90
Bus
* bus =
dynamic_cast<
Bus
*
>
(
host_
->
model
());
91
ProDeTextGenerator
* generator =
ProDeTextGenerator::instance
();
92
format fmt = generator->
text
(
ProDeTextGenerator::STATUS_BUS
);
93
string
extension =
""
;
94
if
(bus->
signExtends
()) {
95
extension = generator->
text
(
96
ProDeTextGenerator::TXT_RADIO_EXTENSION_SIGN
).str();
97
}
else
{
98
extension = generator->
text
(
99
ProDeTextGenerator::TXT_RADIO_EXTENSION_ZERO
).str();
100
}
101
fmt % bus->
name
() %
Conversion::toString
(bus->
width
()) %
102
Conversion::toString
(bus->
immediateWidth
()) %
103
extension;
104
SetStatusTextCmd
* statusCmd =
new
SetStatusTextCmd
(fmt.str());
105
return
statusCmd;
106
107
}
else
{
108
return
NULL;
109
}
110
}
111
112
/**
113
* Tells whether this EditPolicy is able to handle a certain type
114
* of Request.
115
*
116
* @param request Request to be asked if it can be handled.
117
* @return True if the Request can be handled, false otherwise.
118
*/
119
bool
120
ProDeBusEditPolicy::canHandle
(
Request
* request)
const
{
121
Request::RequestType
type = request->
type
();
122
if
(type ==
Request::MODIFY_REQUEST
||
123
type ==
Request::DELETE_REQUEST
||
124
type ==
Request::COPY_REQUEST
||
125
type ==
Request::STATUS_REQUEST
) {
126
return
true
;
127
}
else
{
128
return
false
;
129
}
130
}
Bus.hh
ComponentCommand.hh
Conversion.hh
CopyComponent.hh
DeleteBusCmd.hh
EditPart.hh
MachinePart.hh
ModifyBusCmd.hh
ProDeBusEditPolicy.hh
ProDeTextGenerator.hh
Request.hh
SetStatusTextCmd.hh
ComponentCommand
Definition
ComponentCommand.hh:46
Conversion::toString
static std::string toString(const T &source)
CopyComponent
Definition
CopyComponent.hh:42
DeleteBusCmd
Definition
DeleteBusCmd.hh:42
EditPart::model
TTAMachine::MachinePart * model() const
EditPolicy
Definition
EditPolicy.hh:47
EditPolicy::host_
EditPart * host_
Host EditPart of this EditPolicy.
Definition
EditPolicy.hh:74
ModifyBusCmd
Definition
ModifyBusCmd.hh:43
ProDeBusEditPolicy::canHandle
virtual bool canHandle(Request *request) const
Definition
ProDeBusEditPolicy.cc:120
ProDeBusEditPolicy::getCommand
virtual ComponentCommand * getCommand(Request *request)
Definition
ProDeBusEditPolicy.cc:73
ProDeBusEditPolicy::ProDeBusEditPolicy
ProDeBusEditPolicy()
Definition
ProDeBusEditPolicy.cc:57
ProDeBusEditPolicy::~ProDeBusEditPolicy
virtual ~ProDeBusEditPolicy()
Definition
ProDeBusEditPolicy.cc:63
ProDeTextGenerator
Definition
ProDeTextGenerator.hh:49
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition
ProDeTextGenerator.cc:382
ProDeTextGenerator::STATUS_BUS
@ STATUS_BUS
Status line template for buses.
Definition
ProDeTextGenerator.hh:289
ProDeTextGenerator::TXT_RADIO_EXTENSION_ZERO
@ TXT_RADIO_EXTENSION_ZERO
Label for 'zero' radio button.
Definition
ProDeTextGenerator.hh:100
ProDeTextGenerator::TXT_RADIO_EXTENSION_SIGN
@ TXT_RADIO_EXTENSION_SIGN
Label for 'sign' radio button.
Definition
ProDeTextGenerator.hh:101
Request
Definition
Request.hh:43
Request::RequestType
RequestType
Data type for determining the type of a Request.
Definition
Request.hh:46
Request::STATUS_REQUEST
@ STATUS_REQUEST
Status request.
Definition
Request.hh:52
Request::MODIFY_REQUEST
@ MODIFY_REQUEST
Modfify request.
Definition
Request.hh:48
Request::DELETE_REQUEST
@ DELETE_REQUEST
Delete request.
Definition
Request.hh:49
Request::COPY_REQUEST
@ COPY_REQUEST
Copy request.
Definition
Request.hh:51
Request::type
RequestType type() const
SetStatusTextCmd
Definition
SetStatusTextCmd.hh:43
TTAMachine::Bus
Definition
Bus.hh:53
TTAMachine::Bus::width
int width() const
Definition
Bus.cc:149
TTAMachine::Bus::immediateWidth
int immediateWidth() const
Definition
Bus.cc:160
TTAMachine::Bus::signExtends
bool signExtends() const
Definition
Bus.cc:171
TTAMachine::Component::name
virtual TCEString name() const
Definition
MachinePart.cc:125
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition
TextGenerator.cc:94
TTAMachine
Definition
Assembler.hh:48
Generated by
1.9.8