options.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
34 
35 
36 
38 
39 
40 //
41 // PUBLIC MEMBER FUNCTIONS:
42 //
43 
44 
46 {
47  lists.push_back( OptionsList() );
48 }
49 
50 
52  )
53 {
54  lists.push_back( _lists );
55 }
56 
57 
59 {}
60 
62 {
63  lists.push_back( lists[ 0 ] );
64 
65  return SUCCESSFUL_RETURN;
66 }
67 
68 
70  int& value
71  ) const
72 {
73  return lists[0].get( name,value );
74 }
75 
76 
78  double& value
79  ) const
80 {
81  return lists[0].get( name,value );
82 }
83 
85  std::string& value
86  ) const
87 {
88  return lists[0].get( name,value );
89 }
90 
91 
94  int& value
95  ) const
96 {
97  if ( idx >= getNumOptionsLists( ) )
99 
100  return lists[idx].get( name,value );
101 }
102 
103 
106  double& value
107  ) const
108 {
109  if ( idx >= getNumOptionsLists( ) )
111 
112  return lists[idx].get( name,value );
113 }
114 
117  std::string& value
118  ) const
119 {
120  if ( idx >= getNumOptionsLists( ) )
122 
123  return lists[idx].get( name,value );
124 }
125 
127  int value
128  )
129 {
130  return lists[0].set( name,value );
131 }
132 
133 
135  double value
136  )
137 {
138  return lists[0].set( name,value );
139 }
140 
142  const std::string& value
143  )
144 {
145  return lists[0].set( name,value );
146 }
147 
150  int value
151  )
152 {
153  if ( idx >= getNumOptionsLists( ) )
155 
156  return lists[idx].set( name,value );
157 }
158 
159 
162  double value
163  )
164 {
165  if ( idx >= getNumOptionsLists( ) )
167 
168  return lists[idx].set( name,value );
169 }
170 
173  const std::string& value
174  )
175 {
176  if ( idx >= getNumOptionsLists( ) )
178 
179  return lists[idx].set( name,value );
180 }
181 
182 
184  )
185 {
186  operator=( arg );
187  return SUCCESSFUL_RETURN;
188 }
189 
190 
192  const Options &arg
193  )
194 {
195  if ( ( idx >= getNumOptionsLists( ) ) || ( idx >= arg.getNumOptionsLists( ) ) )
197 
198  lists[ idx ] = arg.lists[ idx ];
199 
200  return SUCCESSFUL_RETURN;
201 }
202 
203 
205  ) const
206 {
207  if ( idx >= getNumOptionsLists( ) )
208  {
210  return Options();
211  }
212 
213  return Options( lists[idx] );
214 }
215 
216 
218 {
219  returnValue returnvalue;
220 
221  for( uint i=0; i<getNumOptionsLists( ); ++i )
222  {
223  returnvalue = lists[i].printOptionsList( );
224  if ( returnvalue != SUCCESSFUL_RETURN )
225  return returnvalue;
226  }
227 
228  return SUCCESSFUL_RETURN;
229 }
230 
231 
233  ) const
234 {
235  if ( idx >= getNumOptionsLists( ) )
237 
238  return lists[idx].printOptionsList( );
239 }
240 
241 
242 //
243 // PROTECTED MEMBER FUNCTIONS:
244 //
245 
247 {
248  return SUCCESSFUL_RETURN;
249 }
250 
252 {
253  for( uint i=0; i<getNumOptionsLists( ); ++i )
254  {
255  if ( lists[i].haveOptionsChanged( ) == BT_TRUE )
256  return BT_TRUE;
257  }
258 
259  return BT_FALSE;
260 }
261 
262 
264  ) const
265 {
266  if ( idx >= getNumOptionsLists( ) )
267  {
269  return BT_FALSE;
270  }
271 
272  return lists[idx].haveOptionsChanged( );
273 }
274 
275 
277 {
278  returnValue returnvalue;
279 
280  for( uint i=0; i<getNumOptionsLists( ); ++i )
281  {
282  returnvalue = lists[i].declareOptionsUnchanged( );
283  if ( returnvalue != SUCCESSFUL_RETURN )
284  return returnvalue;
285  }
286 
287  return SUCCESSFUL_RETURN;
288 }
289 
290 
292  )
293 {
294  if ( idx >= getNumOptionsLists( ) )
296 
297  return lists[idx].declareOptionsUnchanged( );
298 }
299 
300 
302  int value
303  )
304 {
305  returnValue returnvalue;
306 
307  for( uint i=0; i<getNumOptionsLists( ); ++i )
308  {
309  returnvalue = lists[i].add( name,value );
310  if ( returnvalue != SUCCESSFUL_RETURN )
311  return returnvalue;
312  }
313 
314  return SUCCESSFUL_RETURN;
315 }
316 
317 
319  double value
320  )
321 {
322  returnValue returnvalue;
323 
324  for( uint i=0; i<getNumOptionsLists( ); ++i )
325  {
326  returnvalue = lists[i].add( name,value );
327  if ( returnvalue != SUCCESSFUL_RETURN )
328  return returnvalue;
329  }
330 
331  return SUCCESSFUL_RETURN;
332 }
333 
335  const std::string& value
336  )
337 {
338  returnValue returnvalue;
339 
340  for( uint i=0; i<getNumOptionsLists( ); ++i )
341  {
342  returnvalue = lists[i].add( name,value );
343  if ( returnvalue != SUCCESSFUL_RETURN )
344  return returnvalue;
345  }
346 
347  return SUCCESSFUL_RETURN;
348 }
349 
350 
351 
354  int value
355  )
356 {
357  if ( idx >= getNumOptionsLists( ) )
359 
360  return lists[idx].add( name,value );
361 }
362 
363 
366  double value
367  )
368 {
369  if ( idx >= getNumOptionsLists( ) )
371 
372  return lists[idx].add( name,value );
373 }
374 
377  const std::string& value
378  )
379 {
380  if ( idx >= getNumOptionsLists( ) )
382 
383  return lists[idx].add( name,value );
384 }
385 
387 {
388  return lists.size();
389 }
390 
392 
393 
394 /*
395  * end of file
396  */
BooleanType haveOptionsChanged() const
Definition: options.cpp:251
Options getOptions(uint idx) const
Definition: options.cpp:204
Options()
Definition: options.cpp:45
virtual ~Options()
Definition: options.cpp:58
returnValue setOptions(const Options &arg)
Definition: options.cpp:183
returnValue get(OptionsName name, int &value) const
Definition: options.cpp:69
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
#define CLOSE_NAMESPACE_ACADO
returnValue addOptionsList()
Definition: options.cpp:61
std::vector< OptionsList > lists
Definition: options.hpp:476
returnValue set(OptionsName name, int value)
Definition: options.cpp:126
Provides a generic way to set and pass user-specified options.
Definition: options.hpp:65
Options & operator=(const Options &rhs)
Provides a generic list of options (for internal use).
returnValue declareOptionsUnchanged()
Definition: options.cpp:276
returnValue printOptionsList() const
Definition: options.cpp:217
#define BT_TRUE
Definition: acado_types.hpp:47
uint getNumOptionsLists() const
Definition: options.cpp:386
#define BEGIN_NAMESPACE_ACADO
#define BT_FALSE
Definition: acado_types.hpp:49
returnValue addOption(OptionsName name, int value)
Definition: options.cpp:301
OptionsName
virtual returnValue setupOptions()
Definition: options.cpp:246
#define ACADOERROR(retval)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:55