OpenASIP 2.2
Loading...
Searching...
No Matches
OperationTriggeredField.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2021 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 OperationTriggeredField.cc
26 *
27 * Implementation of OperationTriggeredField class.
28 *
29 * @author Kari Hepola 2022 (kari.hepola@tuni.fi)
30 * @note rating: red
31 */
32
35#include "ObjectState.hh"
36
37const std::string OperationTriggeredField::OSNAME_FIELD = "ota-field";
38const std::string OperationTriggeredField::OSKEY_PIECE_NAME = "piece";
39const std::string OperationTriggeredField::OSKEY_START_NAME = "start";
40const std::string OperationTriggeredField::OSKEY_WIDTH_NAME = "width";
41
42/**
43 * The constructor.
44 *
45 * Registers the field encoding to the parent
46 * binary encoding automatically.
47 *
48 * @param parent The parent binaryEncoding.
49 */
50
52 OperationTriggeredEncoding& parent, int piece, int start, int width)
53 : piece_(piece), start_(start), width_(width) {
54 parent.addField(*this);
55}
56
57/**
58 * The constructor
59 *
60 * Loads the state of the field encoding from
61 * the given ObjectState tree
62 *
63 * @param state The ObjectState tree
64 * @param parent The parent operation triggered encoding
65 * @exception ObjectStateLoadingException If an error occurs while loading
66 the state.
67 */
68
74
75/**
76 * Returns the piece index that indicates the index of the encoding piece.
77 *
78 * @return The encoding piece index.
79 */
80
81int
83 return piece_;
84}
85
86void
90
91/**
92 * Returns the piece index that indicates the index of the encoding piece.
93 *
94 * @return The encoding piece index.
95 */
96
97int
99 return start_;
100}
101
102void
106
107/**
108 * Always returns 0 because field encoding does not
109 * have any child fields.
110 *
111 * @return 0
112 */
113
114int
116 return 0;
117}
118
119/**
120 * Returns the bit width of the field encoding
121 *
122 * @return The bit width of the field encoding.
123 */
124
125int
127 return width_;
128}
129
130void
134
135/**
136 * Loads the state of the field
137 * encoding from the given ObjectState tree.
138 *
139 * @param state The ObjectState tree.
140 * @exception ObjectStateLoadingException If an error occurs while loading
141 * the state.
142 */
143
144void
146 ObjectState* newState = new ObjectState(*state);
147
148 try {
152
153 } catch (const Exception& exception) {
154 const std::string procName = "OperationTriggeredField::loadState";
156 __FILE__, __LINE__, procName, exception.errorMessage());
157 }
158
159 delete newState;
160}
161
162/**
163 * Saves the state of the field encoding
164 * to an ObjectState tree.
165 *
166 * @return The newly created ObjectState tree.
167 */
168
std::string errorMessage() const
Definition Exception.cc:123
void setAttribute(const std::string &name, const std::string &value)
int intAttribute(const std::string &name) const
void addField(OperationTriggeredField &field)
static const std::string OSKEY_PIECE_NAME
virtual ObjectState * saveState() const
static const std::string OSKEY_START_NAME
static const std::string OSNAME_FIELD
static const std::string OSKEY_WIDTH_NAME
OperationTriggeredField(const ObjectState *state, OperationTriggeredEncoding &parent)
virtual void loadState(const ObjectState *state)