OpenASIP  2.0
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  */
51 class OptionValue {
52 public:
53 
54  OptionValue();
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 
70 private:
71  /// Copying not allowed.
72  OptionValue(const OptionValue&);
73  /// Assignment not allowed.
75 };
76 
77 
78 //////////////////////////////////////////////////////////////////////////////
79 // IntegerOptionValue
80 //////////////////////////////////////////////////////////////////////////////
81 
82 /**
83  * Models an option that has an integer value.
84  */
86 public:
87  IntegerOptionValue(int value);
88  virtual ~IntegerOptionValue();
89  virtual int integerValue(int index = 0) const;
90  virtual void setIntegerValue(int value);
91 
92 private:
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  */
110 public:
111  UnsignedIntegerOptionValue(unsigned value);
112  virtual ~UnsignedIntegerOptionValue();
113  virtual unsigned unsignedIntegerValue(int index = 0) const;
114  virtual void setUnsignedIntegerValue(unsigned value);
115 
116 private:
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  */
134 public:
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 
140 private:
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  */
157 class RealOptionValue : public OptionValue {
158 public:
159  RealOptionValue(double value);
160  virtual ~RealOptionValue();
161 
162  virtual double realValue() const;
163  virtual void setRealValue(double value);
164 
165 private:
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  */
184 class BoolOptionValue : public OptionValue {
185 public:
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 
193 private:
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  */
211 public:
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 
219 private:
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  */
238 public:
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 
246 private:
247  /// Copying not allowed.
249  /// Assignment not allowed.
251 
252  /// The value of option.
253  std::vector<std::string> values_;
254 };
255 
256 #endif
RealOptionValue::RealOptionValue
RealOptionValue(double value)
Definition: OptionValue.cc:309
StringOptionValue::StringOptionValue
StringOptionValue(const std::string value)
Definition: OptionValue.cc:267
IntegerOptionValue
Definition: OptionValue.hh:85
BoolOptionValue::setBoolValue
virtual void setBoolValue(bool value)
Definition: OptionValue.cc:367
Exception.hh
BoolOptionValue::value_
bool value_
The value of option.
Definition: OptionValue.hh:200
UnsignedIntegerOptionValue::setUnsignedIntegerValue
virtual void setUnsignedIntegerValue(unsigned value)
Definition: OptionValue.cc:249
IntegerOptionValue::value_
int value_
The value of option.
Definition: OptionValue.hh:99
IntegerListOptionValue::~IntegerListOptionValue
virtual ~IntegerListOptionValue()
Definition: OptionValue.cc:409
StringOptionValue::setStringValue
virtual void setStringValue(const std::string &value)
Definition: OptionValue.cc:284
OptionValue::setStringValue
virtual void setStringValue(const std::string &)
Definition: OptionValue.cc:66
StringOptionValue::stringValue
virtual std::string stringValue(int index=0) const
Definition: OptionValue.cc:296
StringListOptionValue::values_
std::vector< std::string > values_
The value of option.
Definition: OptionValue.hh:253
UnsignedIntegerOptionValue::operator=
UnsignedIntegerOptionValue & operator=(const UnsignedIntegerOptionValue &)
Assignment not allowed.
UnsignedIntegerOptionValue::value_
unsigned value_
The value of option.
Definition: OptionValue.hh:123
RealOptionValue::realValue
virtual double realValue() const
Definition: OptionValue.cc:337
IntegerOptionValue::setIntegerValue
virtual void setIntegerValue(int value)
Definition: OptionValue.cc:221
OptionValue::setRealValue
virtual void setRealValue(double)
Definition: OptionValue.cc:96
OptionValue::isFlagOff
virtual bool isFlagOff() const
Definition: OptionValue.cc:178
BoolOptionValue::~BoolOptionValue
virtual ~BoolOptionValue()
Definition: OptionValue.cc:357
IntegerOptionValue::~IntegerOptionValue
virtual ~IntegerOptionValue()
Definition: OptionValue.cc:211
RealOptionValue::setRealValue
virtual void setRealValue(double value)
Definition: OptionValue.cc:326
UnsignedIntegerOptionValue::UnsignedIntegerOptionValue
UnsignedIntegerOptionValue(unsigned value)
Definition: OptionValue.cc:241
OptionValue::isFlagOn
virtual bool isFlagOn() const
Definition: OptionValue.cc:166
IntegerListOptionValue::integerValue
virtual int integerValue(int index=0) const
Definition: OptionValue.cc:433
StringListOptionValue::~StringListOptionValue
virtual ~StringListOptionValue()
Definition: OptionValue.cc:467
StringOptionValue::operator=
StringOptionValue & operator=(const StringOptionValue &)
Assignment not allowed.
BoolOptionValue::operator=
BoolOptionValue & operator=(const BoolOptionValue &)
Assignment not allowed.
BoolOptionValue::isFlagOff
virtual bool isFlagOff() const
Definition: OptionValue.cc:389
UnsignedIntegerOptionValue::unsignedIntegerValue
virtual unsigned unsignedIntegerValue(int index=0) const
Definition: OptionValue.cc:254
IntegerListOptionValue::values_
std::vector< int > values_
The value of option.
Definition: OptionValue.hh:226
RealOptionValue
Definition: OptionValue.hh:157
StringListOptionValue::operator=
StringListOptionValue & operator=(const StringListOptionValue &)
Assignment not allowed.
StringOptionValue::~StringOptionValue
virtual ~StringOptionValue()
Definition: OptionValue.cc:274
OptionValue::setIntegerListValue
virtual void setIntegerListValue(std::vector< int > values)
Definition: OptionValue.cc:117
BoolOptionValue::isFlagOn
virtual bool isFlagOn() const
Definition: OptionValue.cc:378
IntegerListOptionValue::listSize
virtual int listSize() const
Definition: OptionValue.cc:447
OptionValue::stringValue
virtual std::string stringValue(int index=0) const
Definition: OptionValue.cc:142
IntegerListOptionValue::operator=
IntegerListOptionValue & operator=(const IntegerListOptionValue &)
Assignment not allowed.
RealOptionValue::~RealOptionValue
virtual ~RealOptionValue()
Definition: OptionValue.cc:316
OptionValue::realValue
virtual double realValue() const
Definition: OptionValue.cc:154
UnsignedIntegerOptionValue::~UnsignedIntegerOptionValue
virtual ~UnsignedIntegerOptionValue()
Definition: OptionValue.cc:245
BoolOptionValue
Definition: OptionValue.hh:184
StringListOptionValue::listSize
virtual int listSize() const
Definition: OptionValue.cc:505
UnsignedIntegerOptionValue
Definition: OptionValue.hh:109
IntegerListOptionValue::setIntegerListValue
virtual void setIntegerListValue(std::vector< int > values)
Definition: OptionValue.cc:419
StringOptionValue
Definition: OptionValue.hh:133
IntegerOptionValue::operator=
IntegerOptionValue & operator=(const IntegerOptionValue &)
Assignment not allowed.
OptionValue::operator=
OptionValue & operator=(const OptionValue &)
Assignment not allowed.
OptionValue::OptionValue
OptionValue()
Definition: OptionValue.cc:51
IntegerOptionValue::IntegerOptionValue
IntegerOptionValue(int value)
Definition: OptionValue.cc:204
RealOptionValue::operator=
RealOptionValue & operator=(const RealOptionValue &)
Assignment not allowed.
OptionValue::setUnsignedIntegerValue
virtual void setUnsignedIntegerValue(unsigned)
Definition: OptionValue.cc:86
StringListOptionValue::StringListOptionValue
StringListOptionValue(std::vector< std::string > values)
Definition: OptionValue.cc:460
StringOptionValue::value_
std::string value_
The value of the option.
Definition: OptionValue.hh:147
OptionValue
Definition: OptionValue.hh:51
IntegerOptionValue::integerValue
virtual int integerValue(int index=0) const
Definition: OptionValue.cc:233
OptionValue::setIntegerValue
virtual void setIntegerValue(int)
Definition: OptionValue.cc:76
OptionValue::~OptionValue
virtual ~OptionValue()
Definition: OptionValue.cc:57
StringListOptionValue
Definition: OptionValue.hh:237
StringListOptionValue::setStringListValue
virtual void setStringListValue(std::vector< std::string > values)
Definition: OptionValue.cc:477
OptionValue::setBoolValue
virtual void setBoolValue(bool)
Definition: OptionValue.cc:106
IntegerListOptionValue
Definition: OptionValue.hh:210
RealOptionValue::value_
double value_
The value of the option.
Definition: OptionValue.hh:172
OptionValue::listSize
virtual int listSize() const
Definition: OptionValue.cc:190
IntegerListOptionValue::IntegerListOptionValue
IntegerListOptionValue(std::vector< int > values)
Definition: OptionValue.cc:402
BoolOptionValue::BoolOptionValue
BoolOptionValue(bool value)
Definition: OptionValue.cc:350
StringListOptionValue::stringValue
virtual std::string stringValue(int index=0) const
Definition: OptionValue.cc:491
OptionValue::integerValue
virtual int integerValue(int index=0) const
Definition: OptionValue.cc:129