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