OpenASIP  2.0
CopyComponent.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 CopyComponent.cc
26  *
27  * Definition of CopyComponent class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004
30  * @author Pekka Jääskeläinen 2010 (pjaaskel-no.spam-cs.tut.fi)
31  */
32 
33 #include "Application.hh"
34 #include "CopyComponent.hh"
35 #include "FunctionUnit.hh"
36 #include "EditPart.hh"
37 #include "ProDeClipboard.hh"
38 
39 using namespace TTAMachine;
40 
41 /**
42  * The Constructor.
43  *
44  * @param editPart Function unit to delete.
45  */
46 CopyComponent::CopyComponent(EditPart* editPart): editPart_(editPart) {
47 }
48 
49 
50 /**
51  * The Destructor.
52  */
54 }
55 
56 
57 /**
58  * Executes the command.
59  *
60  * @return true, if the command was succesfully executed, false otherwise.
61  */
62 bool
64  Component* component = dynamic_cast<Component*>(editPart_->model());
65  assert (component != NULL);
67  clipboard->setContents(component->saveState(), component->machine());
68  return true;
69 }
70 
71 
72 /**
73  * Undoing this command is not possible, returns always false.
74  *
75  * @return Always false.
76  */
77 bool
79  return false;
80 }
81 
TTAMachine::Component::saveState
virtual ObjectState * saveState() const
Definition: MachinePart.cc:189
CopyComponent::Do
bool Do()
Definition: CopyComponent.cc:63
assert
#define assert(condition)
Definition: Application.hh:86
CopyComponent::Undo
bool Undo()
Definition: CopyComponent.cc:78
EditPart.hh
CopyComponent.hh
Application.hh
TTAMachine::Component
Definition: MachinePart.hh:90
EditPart
Definition: EditPart.hh:60
EditPart::model
TTAMachine::MachinePart * model() const
ProDeClipboard::setContents
void setContents(ObjectState *contents, const TTAMachine::Machine *sourceMachine)
Definition: ProDeClipboard.cc:88
ProDeClipboard
Definition: ProDeClipboard.hh:47
TTAMachine::Component::machine
virtual Machine * machine() const
CopyComponent::~CopyComponent
~CopyComponent()
Definition: CopyComponent.cc:53
TTAMachine
Definition: Assembler.hh:48
ProDeClipboard.hh
CopyComponent::editPart_
EditPart * editPart_
Component to copy.
Definition: CopyComponent.hh:52
CopyComponent::CopyComponent
CopyComponent(EditPart *editPart)
Definition: CopyComponent.cc:46
FunctionUnit.hh
ProDeClipboard::instance
static ProDeClipboard * instance()
Definition: ProDeClipboard.cc:62