OpenASIP 2.2
Loading...
Searching...
No Matches
OptionValue.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 OptionValue.cc
26 *
27 * Definitions of OptionValue classes.
28 *
29 * @author Jari Mäntyneva (jari.mantyneva-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <iostream>
34#include <string>
35#include <sstream>
36
37#include "Application.hh"
38#include "OptionValue.hh"
39
40using std::string;
41using std::istringstream;
42using std::endl;
43
44//////////////////////////////////////////////////////////////////////////////
45// OptionValue
46//////////////////////////////////////////////////////////////////////////////
47
48/**
49 * Constructor.
50 */
53
54/**
55 * Destructor.
56 */
59
60/**
61 * This implementation should never be called.
62 *
63 * @exception WrongSubclass Called for a wrong subclass.
64 */
65void
66OptionValue::setStringValue(const std::string&) {
67 throw WrongSubclass(__FILE__, __LINE__, __func__);
68}
69
70/**
71 * This implementation should never be called.
72 *
73 * @exception WrongSubclass Called for a wrong subclass.
74 */
75void
77 throw WrongSubclass(__FILE__, __LINE__, __func__);
78}
79
80/**
81 * This implementation should never be called.
82 *
83 * @exception WrongSubclass Called for a wrong subclass.
84 */
85void
87 throw WrongSubclass(__FILE__, __LINE__, __func__);
88}
89
90/**
91 * This implementation should never be called.
92 *
93 * @exception WrongSubclass Called for a wrong subclass.
94 */
95void
97 throw WrongSubclass(__FILE__, __LINE__, __func__);
98}
99
100/**
101 * This implementation should never be called.
102 *
103 * @exception WrongSubclass Called for a wrong subclass.
104 */
105void
107 throw WrongSubclass(__FILE__, __LINE__, __func__);
108}
109
110/**
111 * This implementation should never be called.
112 *
113 * @return Nothing.
114 * @exception WrongSubclass Called for a wrong subclass.
115 */
116void
118 throw WrongSubclass(__FILE__, __LINE__, __func__);
119}
120
121/**
122 * This implementation should never be called.
123 *
124 * @return Nothing.
125 * @exception WrongSubclass Called for a wrong subclass.
126 * @exception OutOfRange Never thrown by this function.
127 */
128int
130 throw WrongSubclass(__FILE__, __LINE__, __func__);
131 return 0;
132}
133
134/**
135 * This implementation should never be called.
136 *
137 * @return Nothing.
138 * @exception WrongSubclass Called for a wrong subclass.
139 * @exception OutOfRange Never thrown by this function.
140 */
141std::string
143 throw WrongSubclass(__FILE__, __LINE__, __func__);
144 return "";
145}
146
147/**
148 * This implementation should never be called.
149 *
150 * @return Nothing.
151 * @exception WrongSubclass Called for a wrong subclass.
152 */
153double
155 throw WrongSubclass(__FILE__, __LINE__, __func__);
156 return 0;
157}
158
159/**
160 * This implementation should never be called.
161 *
162 * @return Nothing.
163 * @exception WrongSubclass Called for a wrong subclass.
164 */
165bool
167 throw WrongSubclass(__FILE__, __LINE__, __func__);
168 return false;
169}
170
171/**
172 * This implementation should never be called.
173 *
174 * @return Nothing.
175 * @exception WrongSubclass Called for a wrong subclass.
176 */
177bool
179 throw WrongSubclass(__FILE__, __LINE__, __func__);
180 return false;
181}
182
183/**
184 * This implementation should never be called.
185 *
186 * @return Nothing.
187 * @exception WrongSubclass Called for a wrong subclass.
188 */
189int
191 throw WrongSubclass(__FILE__, __LINE__, __func__);
192 return 0;
193}
194
195//////////////////////////////////////////////////////////////////////////////
196// IntegerOptionValue
197//////////////////////////////////////////////////////////////////////////////
198
199/**
200 * Constructor.
201 *
202 * @param value The value of integer option.
203 */
205 value_ = value;
206}
207
208/**
209 * Destructor.
210 */
213
214/**
215 * Sets new value for integer option.
216 *
217 * @param value New value for the integer option.
218 * @exception WrongSubclass Is never thrown by this function.
219 */
220void
222 value_ = value;
223}
224
225/**
226 * Returns the value of integer option.
227 *
228 * @return The value of integer option.
229 * @exception WrongSubclass Is never thrown by this function.
230 * @exception OutOfRange Never thrown by this function.
231 */
232int
234 return value_;
235}
236
237//////////////////////////////////////////////////////////////////////////////
238// UnsignedIntegerOptionValue
239//////////////////////////////////////////////////////////////////////////////
240
244
247
248void
252
253unsigned
257
258//////////////////////////////////////////////////////////////////////////////
259// StringOptionValue
260//////////////////////////////////////////////////////////////////////////////
261
262/**
263 * Constructor.
264 *
265 * @param value The value of string option.
266 */
267StringOptionValue::StringOptionValue(const std::string value) {
268 value_ = value;
269}
270
271/**
272 * Destructor.
273 */
276
277/**
278 * Sets new value for string option.
279 *
280 * @param value New value for the string option.
281 * @exception WrongSubclass Is never thrown by this function.
282 */
283void
284StringOptionValue::setStringValue(const std::string& value) {
285 value_ = value;
286}
287
288/**
289 * Returns the value of string option.
290 *
291 * @return The value of string option.
292 * @exception WrongSubclass Is never thrown by this function.
293 * @exception OutOfRange Never thrown by this function.
294 */
295string
297 return value_;
298}
299
300//////////////////////////////////////////////////////////////////////////////
301// RealOptionValue
302//////////////////////////////////////////////////////////////////////////////
303
304/**
305 * Constructor.
306 *
307 * @param value The value of real option.
308 */
310 value_ = value;
311}
312
313/**
314 * Destructor.
315 */
318
319/**
320 * Sets new value for real option.
321 *
322 * @param value New value for the real option.
323 * @exception WrongSubclass Is never thrown by this function.
324 */
325void
327 value_ = value;
328}
329
330/**
331 * Returns the value of string option.
332 *
333 * @return The value of string option.
334 * @exception WrongSubclass Is never thrown by this function.
335 */
336double
338 return value_;
339}
340
341//////////////////////////////////////////////////////////////////////////////
342// BoolOptionValue
343//////////////////////////////////////////////////////////////////////////////
344
345/**
346 * Constructor.
347 *
348 * @param value The value of boolean option.
349 */
351 value_ = value;
352}
353
354/**
355 * Destructor.
356 */
359
360/**
361 * Sets new value for boolean option.
362 *
363 * @param value New value for the boolean option.
364 * @exception WrongSubclass Is never thrown by this function.
365 */
366void
368 value_ = value;
369}
370
371/**
372 * Returns the value of boolean option.
373 *
374 * @return The value of boolean option.
375 * @exception WrongSubclass Is never thrown by this function.
376 */
377bool
379 return value_;
380}
381
382/**
383 * Returns the negative value of boolean option.
384 *
385 * @return The negative value of boolean option.
386 * @exception WrongSubclass Is never thrown by this function.
387 */
388bool
390 return !value_;
391}
392
393//////////////////////////////////////////////////////////////////////////////
394// IntegerListOptionValue
395//////////////////////////////////////////////////////////////////////////////
396
397/**
398 * Constructor.
399 *
400 * @param value The values of integer list options.
401 */
403 values_ = values;
404}
405
406/**
407 * Destructor.
408 */
411
412/**
413 * Sets new value for integer list option.
414 *
415 * @param value New value for the integer list option.
416 * @exception WrongSubclass Is never thrown by this function.
417 */
418void
420 values_ = values;
421}
422
423/**
424 * Returns the value from the given index of integer list.
425 *
426 * The index must be given between 0 and the size of value vector - 1
427 *
428 * @return The value from the given index of integer list.
429 * @exception WrongSubclass Is never thrown by this function.
430 * @exception OutOfRange If the index is out of the range.
431 */
432int
434 if (index < 0 || static_cast<unsigned>(index) > values_.size() - 1) {
435 string procName = "IntegerListOptionValue::integerValue";
436 throw OutOfRange(__FILE__, __LINE__, procName);
437 }
438 return values_[index];
439}
440
441/**
442 * Returns the size of the integer list.
443 *
444 * @return Size of hte list.
445 */
446int
448 return values_.size();
449}
450
451//////////////////////////////////////////////////////////////////////////////
452// StringListOptionValue
453//////////////////////////////////////////////////////////////////////////////
454
455/**
456 * Constructor.
457 *
458 * @param value The values of string list options.
459 */
461 values_ = values;
462}
463
464/**
465 * Destructor.
466 */
469
470/**
471 * Sets new value for string list option.
472 *
473 * @param value New value for the string list option.
474 * @exception WrongSubclass Is never thrown by this function.
475 */
476void
477StringListOptionValue::setStringListValue(std::vector<string> values) {
478 values_ = values;
479}
480
481/**
482 * Returns the value from the given index of string list.
483 *
484 * The index must be given between 0 and the size of value vector - 1
485 *
486 * @return The value from the given index of string list.
487 * @exception WrongSubclass Is never thrown by this function.
488 * @exception OutOfRange If the index is out of the range.
489 */
490std::string
492 if (index < 0 || static_cast<unsigned>(index) > values_.size() - 1) {
493 string procName = "StringListOptionValue::stringValue";
494 throw OutOfRange(__FILE__, __LINE__, procName);
495 }
496 return values_[index];
497}
498
499/**
500 * Returns the size of the string list.
501 *
502 * @return Size of hte list.
503 */
504int
506 return values_.size();
507}
#define __func__
bool value_
The value of option.
virtual bool isFlagOn() const
virtual ~BoolOptionValue()
virtual void setBoolValue(bool value)
virtual bool isFlagOff() const
BoolOptionValue(bool value)
virtual int listSize() const
virtual ~IntegerListOptionValue()
IntegerListOptionValue(std::vector< int > values)
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)
IntegerOptionValue(int value)
virtual int integerValue(int index=0) const
int value_
The value of option.
virtual ~OptionValue()
virtual void setRealValue(double)
virtual void setUnsignedIntegerValue(unsigned)
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 &)
virtual ~RealOptionValue()
virtual double realValue() const
double value_
The value of the option.
RealOptionValue(double value)
virtual void setRealValue(double value)
virtual int listSize() const
StringListOptionValue(std::vector< std::string > values)
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()
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(const std::string value)
unsigned value_
The value of option.
virtual void setUnsignedIntegerValue(unsigned value)
virtual unsigned unsignedIntegerValue(int index=0) const
UnsignedIntegerOptionValue(unsigned value)