OpenASIP  2.0
ProDeFUEditPolicy.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 ProDeFUEditPolicy.cc
26  *
27  * Definition of ProDeFUEditPolicy 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 <boost/format.hpp>
35 #include "ProDeFUEditPolicy.hh"
36 #include "Request.hh"
37 #include "ComponentCommand.hh"
38 #include "ModifyFUCmd.hh"
39 #include "DeleteFUCmd.hh"
40 #include "CopyComponent.hh"
41 #include "SetStatusTextCmd.hh"
42 #include "FunctionUnit.hh"
43 #include "EditPart.hh"
44 #include "ProDeTextGenerator.hh"
45 
46 using boost::format;
47 using std::string;
48 using namespace TTAMachine;
49 
50 /**
51  * The Constructor.
52  */
54 }
55 
56 /**
57  * The Destructor.
58  */
60 }
61 
62 /**
63  * Returns the Command corresponding to the type of the Request.
64  *
65  * @param request Request to be handled.
66  * @return NULL if the Request cannot be handled.
67  */
70 
71  Request::RequestType type = request->type();
72 
73  if (type == Request::MODIFY_REQUEST) {
74  ModifyFUCmd* modifyCmd = new ModifyFUCmd(host_);
75  return modifyCmd;
76 
77  } else if (type == Request::DELETE_REQUEST) {
78  DeleteFUCmd* deleteCmd = new DeleteFUCmd(host_);
79  return deleteCmd;
80 
81  } else if (type == Request::COPY_REQUEST) {
82  CopyComponent* copyCmd = new CopyComponent(host_);
83  return copyCmd;
84 
85  } else if (type == Request::STATUS_REQUEST) {
86 
88  FunctionUnit* fu = dynamic_cast<FunctionUnit*>(host_->model());
89  format fmt = generator->text(ProDeTextGenerator::STATUS_FUNCTION_UNIT);
90  fmt % fu->name();
91  SetStatusTextCmd* statusCmd = new SetStatusTextCmd(fmt.str());
92  return statusCmd;
93 
94  } else {
95  return NULL;
96  }
97 }
98 
99 /**
100  * Tells whether this EditPolicy is able to handle a certain type
101  * of Request.
102  *
103  * @param request Request to be asked if it can be handled.
104  * @return True if the Request can be handled, false otherwise.
105  */
106 bool
108  Request::RequestType type = request->type();
109  if (type == Request::MODIFY_REQUEST ||
110  type == Request::DELETE_REQUEST ||
111  type == Request::COPY_REQUEST ||
112  type == Request::STATUS_REQUEST) {
113  return true;
114  } else {
115  return false;
116  }
117 }
CopyComponent
Definition: CopyComponent.hh:42
Request::type
RequestType type() const
ProDeFUEditPolicy.hh
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
SetStatusTextCmd
Definition: SetStatusTextCmd.hh:43
ModifyFUCmd
Definition: ModifyFUCmd.hh:43
Request::DELETE_REQUEST
@ DELETE_REQUEST
Delete request.
Definition: Request.hh:49
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
ProDeFUEditPolicy::ProDeFUEditPolicy
ProDeFUEditPolicy()
Definition: ProDeFUEditPolicy.cc:53
ProDeTextGenerator.hh
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
ProDeFUEditPolicy::~ProDeFUEditPolicy
virtual ~ProDeFUEditPolicy()
Definition: ProDeFUEditPolicy.cc:59
Request.hh
Request::COPY_REQUEST
@ COPY_REQUEST
Copy request.
Definition: Request.hh:51
EditPart.hh
CopyComponent.hh
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
DeleteFUCmd
Definition: DeleteFUCmd.hh:42
EditPolicy
Definition: EditPolicy.hh:47
SetStatusTextCmd.hh
EditPart::model
TTAMachine::MachinePart * model() const
Request
Definition: Request.hh:43
ComponentCommand
Definition: ComponentCommand.hh:46
ProDeTextGenerator::STATUS_FUNCTION_UNIT
@ STATUS_FUNCTION_UNIT
Status line template for FUs.
Definition: ProDeTextGenerator.hh:285
ProDeFUEditPolicy::canHandle
virtual bool canHandle(Request *request) const
Definition: ProDeFUEditPolicy.cc:107
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
Request::MODIFY_REQUEST
@ MODIFY_REQUEST
Modfify request.
Definition: Request.hh:48
Request::STATUS_REQUEST
@ STATUS_REQUEST
Status request.
Definition: Request.hh:52
TTAMachine
Definition: Assembler.hh:48
ModifyFUCmd.hh
DeleteFUCmd.hh
ProDeFUEditPolicy::getCommand
virtual ComponentCommand * getCommand(Request *request)
Definition: ProDeFUEditPolicy.cc:69
FunctionUnit.hh
ComponentCommand.hh