OpenASIP 2.2
Loading...
Searching...
No Matches
OperationTriggeredOperand.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 OperationTriggeredOperand.cc
26 *
27 * Implementation of OperationTriggeredOperand class.
28 *
29 * @author Kari Hepola 2021 (kari.hepola@tuni.fi)
30 * @note rating: red
31 */
32
34#include "ObjectState.hh"
36#include "StringTools.hh"
37
38namespace TTAMachine {
39
40const std::string OperationTriggeredOperand::OSNAME_OPERAND = "operand";
41const std::string OperationTriggeredOperand::OSKEY_NAME = "name";
42const std::string OperationTriggeredOperand::OSKEY_TYPE = "type";
43const std::string OperationTriggeredOperand::OSKEY_DIRECTION = "direction";
44
45/**
46 * The constructor.
47 *
48 * Registers the operation code encoding to the parent
49 * binary encoding automatically.
50 *
51 * @param parent The parent OperationTriggeredFormat.
52 */
53
55 const std::string& name, OperationTriggeredFormat& parent)
56 : SubComponent(), name_(name), type_(""), direction_("") {
58 parent.addOperand(*this);
59}
60
61/**
62 * The constructor
63 *
64 * Loads the state of the operation code encoding from
65 * the given ObjectState tree
66 *
67 * @param state The ObjectState tree
68 * @param parent The parent binary encoding map
69 * @exception ObjectStateLoadingException If an error occurs while loading
70 the state.
71 */
72
74 const ObjectState* state, OperationTriggeredFormat& parent)
75 : SubComponent(), name_(""), type_(""), direction_("") {
76 const std::string procName =
77 "OperationTriggeredOperand::OperationTriggeredOperand";
78 // set name
79 try {
81 } catch (const Exception& exception) {
83 __FILE__, __LINE__, procName, exception.errorMessage());
84 }
85 parent.addOperand(*this);
86 loadState(state);
87}
88
89/**
90 * Destructor.
91 */
95
96/**
97 * Returns the name of the operation.
98 *
99 * @return The name of the operation.
100 */
101const std::string&
103 return name_;
104}
105
106/**
107 * Sets the name of the operand.
108 *
109 * @param name The new name.
110 */
111void
112OperationTriggeredOperand::setName(const std::string& name) {
113 std::string lowerName = StringTools::stringToLower(name);
114
115 if (lowerName == this->name()) {
116 return;
117 }
118 name_ = lowerName;
119}
120
121std::string
123 return type_;
124}
125
126void
127OperationTriggeredOperand::setType(const std::string& type) {
128 type_ = type;
129}
130
131std::string
135
136void
137OperationTriggeredOperand::setDirection(const std::string& direction) {
139}
140
141void
143 ObjectState* newState = new ObjectState(*state);
144 try {
147 } catch (const Exception& exception) {
148 const std::string procName = "OperationTriggeredOperand::loadState";
150 __FILE__, __LINE__, procName, exception.errorMessage());
151 }
152
153 delete newState;
154}
155
156/**
157 * Saves the state of the operation code encoding
158 * to an ObjectState tree.
159 *
160 * @return The newly created ObjectState tree.
161 */
162
172} // namespace TTAMachine
std::string errorMessage() const
Definition Exception.cc:123
void setAttribute(const std::string &name, const std::string &value)
std::string stringAttribute(const std::string &name) const
static std::string stringToLower(const std::string &source)
void addOperand(OperationTriggeredOperand &operand)
virtual void loadState(const ObjectState *state)
void setDirection(const std::string &direction)
virtual void setName(const std::string &name)
OperationTriggeredOperand(const std::string &name, OperationTriggeredFormat &parent)