OpenASIP 2.2
Loading...
Searching...
No Matches
ProDeGCUEditPolicy.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 ProDeGCUEditPolicy.cc
26 *
27 * Definition of ProDeGCUEditPolicy 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 "ProDeGCUEditPolicy.hh"
38#include "Request.hh"
39#include "ComponentCommand.hh"
40#include "ModifyGCUCmd.hh"
41#include "DeleteGCUCmd.hh"
42#include "CopyComponent.hh"
43#include "EditPart.hh"
44#include "ControlUnit.hh"
45#include "ProDeTextGenerator.hh"
46#include "SetStatusTextCmd.hh"
47
48using std::string;
49using boost::format;
50using namespace TTAMachine;
51
52/**
53 * The Constructor.
54 */
57
58/**
59 * The Destructor.
60 */
63
64/**
65 * Returns the Command corresponding to the type of the Request.
66 *
67 * @param request Request to be handled.
68 * @return NULL if the Request cannot be handled.
69 */
72
73 Request::RequestType type = request->type();
74
75 if (type == Request::MODIFY_REQUEST) {
76 ModifyGCUCmd* modifyCmd = new ModifyGCUCmd(host_);
77 return modifyCmd;
78
79 } else if (type == Request::DELETE_REQUEST) {
80 DeleteGCUCmd* deleteCmd = new DeleteGCUCmd(host_);
81 return deleteCmd;
82
83 } else if (type == Request::COPY_REQUEST) {
84 CopyComponent* copyCmd = new CopyComponent(host_);
85 return copyCmd;
86
87 } else if (type == Request::STATUS_REQUEST) {
88 ControlUnit* gcu = dynamic_cast<ControlUnit*>(host_->model());
90 format fmt = generator->text(ProDeTextGenerator::STATUS_GCU);
91 fmt % gcu->name();
92 SetStatusTextCmd* statusCmd = new SetStatusTextCmd(fmt.str());
93 return statusCmd;
94
95 } else {
96 return NULL;
97 }
98}
99
100/**
101 * Tells whether this EditPolicy is able to handle a certain type
102 * of Request.
103 *
104 * @param request Request to be asked if it can be handled.
105 * @return True if the Request can be handled, false otherwise.
106 */
107bool
109 Request::RequestType type = request->type();
110 if (type == Request::MODIFY_REQUEST ||
111 type == Request::DELETE_REQUEST ||
112 type == Request::COPY_REQUEST) {
113 return true;
114 } else {
115 return false;
116 }
117}
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)
static ProDeTextGenerator * instance()
@ STATUS_GCU
Status line template for GCUs.
RequestType
Data type for determining the type of a Request.
Definition Request.hh:46
@ STATUS_REQUEST
Status request.
Definition Request.hh:52
@ MODIFY_REQUEST
Modfify request.
Definition Request.hh:48
@ DELETE_REQUEST
Delete request.
Definition Request.hh:49
@ COPY_REQUEST
Copy request.
Definition Request.hh:51
RequestType type() const
virtual TCEString name() const
virtual boost::format text(int textId)