OpenASIP 2.2
Loading...
Searching...
No Matches
DestinationField.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 DestinationField.cc
26 *
27 * Implementation of DestinationField class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
35#include "DestinationField.hh"
36#include "MoveSlot.hh"
37#include "Application.hh"
38#include "ObjectState.hh"
39
40using std::string;
41
42const std::string DestinationField::OSNAME_DESTINATION_FIELD = "dest_field";
43
44/**
45 * The constructor.
46 *
47 * Registers the destination field to the given move slot automatically.
48 *
49 * @param socketIDPos Position of the socket ID within the destination field.
50 * @param parent The parent move slot.
51 * @exception ObjectAlreadyExists If the parent move slot already has a
52 * destination field.
53 * @exception IllegalParameters If the given socket ID position is not the same
54 * with other destination fields.
55 */
57 BinaryEncoding::Position socketIDPos, MoveSlot& parent)
58 : SlotField(socketIDPos, parent) {
60 for (int i = 0; i < bem->moveSlotCount(); i++) {
61 MoveSlot& slot = bem->moveSlot(i);
62 if (slot.hasDestinationField() &&
63 slot.destinationField().componentIDPosition() != socketIDPos) {
64 const string procName = "SourceField::SourceField";
65 throw IllegalParameters(__FILE__, __LINE__, procName);
66 } else {
67 break;
68 }
69 }
70
71 setParent(NULL);
74}
75
76/**
77 * The constructor.
78 *
79 * Loads the state of the object from the given ObjectState tree.
80 *
81 * @param state The ObjectState tree.
82 * @param parent The parent move slot.
83 * @exception ObjectStateLoadingException If an error occurs while loading the
84 * state.
85 * @exception ObjectAlreadyExists If the parent move slot already has a
86 * destination field.
87 */
89 : SlotField(state, parent) {
90 if (state->name() != OSNAME_DESTINATION_FIELD) {
91 const string procName = "DestinationField::DestinationField";
92 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
93 }
94
95 setParent(NULL);
98}
99
100/**
101 * The destructor.
102 */
104 MoveSlot* parent = this->parent();
105 assert(parent != NULL);
106 setParent(NULL);
108}
109
110
111/**
112 * Saves the state of the object to an ObjectState tree.
113 *
114 * @return The newly created ObjectState tree.
115 */
120 return state;
121}
#define assert(condition)
int moveSlotCount() const
MoveSlot & moveSlot(int index) const
static const std::string OSNAME_DESTINATION_FIELD
ObjectState name for destination field.
virtual ObjectState * saveState() const
DestinationField(BinaryEncoding::Position socketIDPos, MoveSlot &parent)
void setParent(InstructionField *parent)
BinaryEncoding * parent() const
Definition MoveSlot.cc:118
DestinationField & destinationField() const
Definition MoveSlot.cc:341
void unsetDestinationField()
Definition MoveSlot.cc:314
void setDestinationField(DestinationField &field)
Definition MoveSlot.cc:296
bool hasDestinationField() const
Definition MoveSlot.cc:327
void setName(const std::string &name)
std::string name() const
MoveSlot * parent() const
Definition SlotField.cc:98
virtual ObjectState * saveState() const
Definition SlotField.cc:388
BinaryEncoding::Position componentIDPosition() const
Definition SlotField.cc:296