OpenASIP 2.2
Loading...
Searching...
No Matches
OptionValue.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2014 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 OptionValue.hh
26 *
27 * Declaration of OptionValue classes.
28 *
29 * @author Jari Mäntyneva (jari.mantyneva-no.spam-tut.fi)
30 * @author Pekka Jääskeläinen 2014
31 * @note rating: red
32 */
33
34#ifndef TTA_OPTION_VALUE_HH
35#define TTA_OPTION_VALUE_HH
36
37#include <string>
38#include <vector>
39#include "Exception.hh"
40
41//////////////////////////////////////////////////////////////////////////////
42// OptionValue
43//////////////////////////////////////////////////////////////////////////////
44
45/**
46 * An abstract base class for modeling all kinds of options.
47 *
48 * Possible option types are bool, real, int, and string. Each
49 * option knows its name and description.
50 */
52public:
53
55 virtual ~OptionValue();
56
57 virtual void setStringValue(const std::string&);
58 virtual void setIntegerValue(int);
59 virtual void setUnsignedIntegerValue(unsigned);
60 virtual void setRealValue(double);
61 virtual void setBoolValue(bool);
62 virtual void setIntegerListValue(std::vector<int> values);
63 virtual std::string stringValue(int index = 0) const;
64 virtual int integerValue(int index = 0) const;
65 virtual double realValue() const;
66 virtual bool isFlagOn() const;
67 virtual bool isFlagOff() const;
68 virtual int listSize() const;
69
70private:
71 /// Copying not allowed.
73 /// Assignment not allowed.
75};
76
77
78//////////////////////////////////////////////////////////////////////////////
79// IntegerOptionValue
80//////////////////////////////////////////////////////////////////////////////
81
82/**
83 * Models an option that has an integer value.
84 */
86public:
87 IntegerOptionValue(int value);
88 virtual ~IntegerOptionValue();
89 virtual int integerValue(int index = 0) const;
90 virtual void setIntegerValue(int value);
91
92private:
93 /// Copying not allowed.
95 /// Assignment not allowed.
97
98 /// The value of option.
99 int value_;
100};
101
102//////////////////////////////////////////////////////////////////////////////
103// UnsignedIntegerOptionValue
104//////////////////////////////////////////////////////////////////////////////
105
106/**
107 * Models an option that has an unsigned integer value.
108 */
110public:
111 UnsignedIntegerOptionValue(unsigned value);
113 virtual unsigned unsignedIntegerValue(int index = 0) const;
114 virtual void setUnsignedIntegerValue(unsigned value);
115
116private:
117 /// Copying not allowed.
119 /// Assignment not allowed.
121
122 /// The value of option.
123 unsigned value_;
124};
125
126//////////////////////////////////////////////////////////////////////////////
127// StringOptionValue
128//////////////////////////////////////////////////////////////////////////////
129
130/**
131 * OptionValue that has a string as a value.
132 */
134public:
135 StringOptionValue(const std::string value);
136 virtual ~StringOptionValue();
137 virtual std::string stringValue(int index = 0) const;
138 virtual void setStringValue(const std::string& value);
139
140private:
141 /// Copying not allowed.
143 /// Assignment not allowed.
145
146 /// The value of the option.
147 std::string value_;
148};
149
150//////////////////////////////////////////////////////////////////////////////
151// RealOptionValue
152//////////////////////////////////////////////////////////////////////////////
153
154/**
155 * OptionValue that has a real value.
156 */
158public:
159 RealOptionValue(double value);
160 virtual ~RealOptionValue();
161
162 virtual double realValue() const;
163 virtual void setRealValue(double value);
164
165private:
166 /// Copying not allowed.
168 /// Assignment not allowed.
170
171 /// The value of the option.
172 double value_;
173};
174
175//////////////////////////////////////////////////////////////////////////////
176// BoolOptionValue
177//////////////////////////////////////////////////////////////////////////////
178
179/**
180 * OptionValue that has a boolean value.
181 *
182 * This option is also called 'flag'.
183 */
185public:
186 BoolOptionValue(bool value);
187 virtual ~BoolOptionValue();
188
189 virtual bool isFlagOn() const;
190 virtual bool isFlagOff() const;
191 virtual void setBoolValue(bool value);
192
193private:
194 /// Copying not allowed.
196 /// Assignment not allowed.
198
199 /// The value of option.
200 bool value_;
201};
202
203//////////////////////////////////////////////////////////////////////////////
204// IntegerListOptionValue
205//////////////////////////////////////////////////////////////////////////////
206
207/**
208 * OptionValue that has list of integers as value.
209 */
211public:
212 IntegerListOptionValue(std::vector<int> values);
213 virtual ~IntegerListOptionValue();
214
215 virtual int integerValue(int index = 0) const;
216 virtual int listSize() const;
217 virtual void setIntegerListValue(std::vector<int> values);
218
219private:
220 /// Copying not allowed.
222 /// Assignment not allowed.
224
225 /// The value of option.
226 std::vector<int> values_;
227};
228
229
230//////////////////////////////////////////////////////////////////////////////
231// StringListOptionValue
232//////////////////////////////////////////////////////////////////////////////
233
234/**
235 * OptionValue that has list of strings as value.
236 */
238public:
239 StringListOptionValue(std::vector<std::string> values);
240 virtual ~StringListOptionValue();
241
242 virtual std::string stringValue(int index = 0) const;
243 virtual int listSize() const;
244 virtual void setStringListValue(std::vector<std::string> values);
245
246private:
247 /// Copying not allowed.
249 /// Assignment not allowed.
251
252 /// The value of option.
253 std::vector<std::string> values_;
254};
255
256#endif
bool value_
The value of option.
virtual bool isFlagOn() const
virtual ~BoolOptionValue()
virtual void setBoolValue(bool value)
virtual bool isFlagOff() const
BoolOptionValue & operator=(const BoolOptionValue &)
Assignment not allowed.
BoolOptionValue(const BoolOptionValue &)
Copying not allowed.
IntegerListOptionValue(const IntegerListOptionValue &)
Copying not allowed.
virtual int listSize() const
IntegerListOptionValue & operator=(const IntegerListOptionValue &)
Assignment not allowed.
virtual ~IntegerListOptionValue()
virtual void setIntegerListValue(std::vector< int > values)
virtual int integerValue(int index=0) const
std::vector< int > values_
The value of option.
virtual ~IntegerOptionValue()
virtual void setIntegerValue(int value)
virtual int integerValue(int index=0) const
int value_
The value of option.
IntegerOptionValue & operator=(const IntegerOptionValue &)
Assignment not allowed.
IntegerOptionValue(const IntegerOptionValue &)
Copying not allowed.
virtual ~OptionValue()
virtual void setRealValue(double)
virtual void setUnsignedIntegerValue(unsigned)
OptionValue & operator=(const OptionValue &)
Assignment not allowed.
OptionValue(const OptionValue &)
Copying not allowed.
virtual double realValue() const
virtual bool isFlagOff() const
virtual void setIntegerValue(int)
virtual void setBoolValue(bool)
virtual std::string stringValue(int index=0) const
virtual bool isFlagOn() const
virtual int listSize() const
virtual void setIntegerListValue(std::vector< int > values)
virtual int integerValue(int index=0) const
virtual void setStringValue(const std::string &)
RealOptionValue & operator=(const RealOptionValue &)
Assignment not allowed.
RealOptionValue(const RealOptionValue &)
Copying not allowed.
virtual ~RealOptionValue()
virtual double realValue() const
double value_
The value of the option.
virtual void setRealValue(double value)
virtual int listSize() const
StringListOptionValue & operator=(const StringListOptionValue &)
Assignment not allowed.
StringListOptionValue(const StringListOptionValue &)
Copying not allowed.
std::vector< std::string > values_
The value of option.
virtual std::string stringValue(int index=0) const
virtual void setStringListValue(std::vector< std::string > values)
virtual ~StringListOptionValue()
StringOptionValue(const StringOptionValue &)
Copying not allowed.
virtual ~StringOptionValue()
virtual void setStringValue(const std::string &value)
std::string value_
The value of the option.
virtual std::string stringValue(int index=0) const
StringOptionValue & operator=(const StringOptionValue &)
Assignment not allowed.
UnsignedIntegerOptionValue(const UnsignedIntegerOptionValue &)
Copying not allowed.
UnsignedIntegerOptionValue & operator=(const UnsignedIntegerOptionValue &)
Assignment not allowed.
unsigned value_
The value of option.
virtual void setUnsignedIntegerValue(unsigned value)
virtual unsigned unsignedIntegerValue(int index=0) const