OpenASIP 2.2
Loading...
Searching...
No Matches
Parameter.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2015 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 Parameter.cc
26 *
27 * Implementation of Parameter class.
28 *
29 * Created on: 20.4.2015
30 * @author: Henry Linjamäki (henry.linjamaki-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#include "Parameter.hh"
35
36#include "BaseNetlistBlock.hh"
37
38#include "Conversion.hh"
39
40namespace ProGe {
41
42/**
43 * Empty parameter with undefined members.
44 */
46 : name_(""), type_(""), value_(""), default_(""), package_("") {}
47
48/**
49 * Constructs a parameter with both the assigned and default value having the
50 * same value.
51 *
52 * @param name The name of the parameter
53 * @param type The type of the parameter given as string
54 * @param assignedAndDefaultValue The assigned and default value of the
55 * parameter.
56 */
58 const TCEString& name, const TCEString& type,
59 const TCEString& assignedAndDefaultValue)
60 : Parameter(
61 name, type, assignedAndDefaultValue, assignedAndDefaultValue) {}
62
63/**
64 * Constructs a parameter with separate assigned and default value.
65 *
66 * @param name The name of the parameter
67 * @param type The type of the parameter given as string
68 * @param assignedValue The assigned value of the parameter.
69 * @param defaultValue The default value of the parameter.
70 */
72 const TCEString& name, const TCEString& type,
73 const TCEString& assignedValue, const TCEString& defaultValue)
74 : name_(name),
75 type_(type),
76 value_(assignedValue),
77 default_(defaultValue),
78 package_("") {}
80 const TCEString& name, const TCEString& type, int assignedValue,
81 const TCEString& defaultValue)
82 : name_(name),
83 type_(type),
84 value_(""),
85 default_(defaultValue),
86 package_("") {
87 value_ = Conversion::toString(assignedValue);
88}
89
90/**
91 * @param name The name of the parameter
92 * @param type The type of the parameter given as string
93 * @param nameOfConstant The value of the parameter as name to a constant.
94 * @param defaultValue The default value of the parameter.
95 * @param nameOfPackage The name of a package where the constant is defined.
96 */
98 const TCEString& name, const TCEString& type,
99 const TCEString& nameOfConstant, const TCEString& defaultValue,
100 const TCEString& nameOfPackage)
101 : name_(name),
102 type_(type),
103 value_(nameOfConstant),
104 default_(defaultValue),
105 package_(nameOfPackage) {}
106
108
109void
111 const TCEString& name, const TCEString& type, const TCEString& value) {
112 name_ = name;
113 type_ = type;
114 value_ = value;
115}
116
117void
119 name_ = name;
120}
121
122void
124 type_ = type;
125}
126
127void
129 value_ = value;
130}
131
132const TCEString&
134 return name_;
135}
136
137const TCEString&
139 return type_;
140}
141
142const TCEString&
144 return value_;
145}
146
147const TCEString&
149 return default_;
150}
151
152/**
153 * Return true is the value is a symbol therefore the actual value is defined
154 * elsewhere. Otherwise, the value is literal.
155 */
156bool
158 return !package_.empty(); // note: placeholder
159}
160
161/**
162 * Return true is the value is a symbol to a constant that are stored in
163 * packages.
164 */
165bool
167 return valueIsSymbol() && !package_.empty();
168}
169
170const std::string&
174
175} /* namespace ProGe */
static std::string toString(const T &source)
TCEString value_
Assigned value to the parameter as actual value or as reference to another parameter or name of a con...
Definition Parameter.hh:113
TCEString name_
Name/identifier of the parameter.
Definition Parameter.hh:108
const std::string & packageNameOfConstant() const
Definition Parameter.cc:171
bool valueIsConstant() const
Definition Parameter.cc:166
virtual ~Parameter()
Definition Parameter.cc:107
const TCEString & value() const
Definition Parameter.cc:143
void setName(const TCEString &name)
Definition Parameter.cc:118
TCEString package_
Package reference by name. If non-empty the value_ is treated as name of a constant.
Definition Parameter.hh:118
void setValue(const TCEString &value)
Definition Parameter.cc:128
const TCEString & defaultValue() const
Definition Parameter.cc:148
const TCEString & type() const
Definition Parameter.cc:138
bool valueIsSymbol() const
Definition Parameter.cc:157
TCEString default_
Default value of the parameter if value_ is not set (empty).
Definition Parameter.hh:115
void setType(const TCEString &type)
Definition Parameter.cc:123
const TCEString & name() const
Definition Parameter.cc:133
TCEString type_
Type of the parameter.
Definition Parameter.hh:110
void set(const TCEString &name, const TCEString &type, const TCEString &value)
Definition Parameter.cc:110
Definition FUGen.hh:54