options.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00033 #include <acado/user_interaction/options.hpp>
00034 
00035 
00036 
00037 BEGIN_NAMESPACE_ACADO
00038 
00039 
00040 //
00041 // PUBLIC MEMBER FUNCTIONS:
00042 //
00043 
00044 
00045 Options::Options( )
00046 {
00047         lists.push_back( OptionsList() );
00048 }
00049 
00050 
00051 Options::Options(       const OptionsList& _lists
00052                                         )
00053 {
00054         lists.push_back( _lists );
00055 }
00056 
00057 
00058 Options::~Options( )
00059 {}
00060 
00061 returnValue Options::addOptionsList( )
00062 {
00063         lists.push_back( lists[ 0 ] );
00064         
00065         return SUCCESSFUL_RETURN;
00066 }
00067 
00068 
00069 returnValue Options::get(       OptionsName name,
00070                                                         int& value
00071                                                         ) const
00072 {
00073         return lists[0].get( name,value );
00074 }
00075 
00076 
00077 returnValue Options::get(       OptionsName name,
00078                                                         double& value
00079                                                         ) const
00080 {
00081         return lists[0].get( name,value );
00082 }
00083 
00084 returnValue Options::get(       OptionsName name,
00085                                                         std::string& value
00086                                                         ) const
00087 {
00088         return lists[0].get( name,value );
00089 }
00090 
00091 
00092 returnValue Options::get(       uint idx,
00093                                                         OptionsName name,
00094                                                         int& value
00095                                                         ) const
00096 {
00097         if ( idx >= getNumOptionsLists( ) )
00098                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00099 
00100         return lists[idx].get( name,value );
00101 }
00102 
00103 
00104 returnValue Options::get(       uint idx,
00105                                                         OptionsName name,
00106                                                         double& value
00107                                                         ) const
00108 {
00109         if ( idx >= getNumOptionsLists( ) )
00110                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00111         
00112         return lists[idx].get( name,value );
00113 }
00114 
00115 returnValue Options::get(       uint idx,
00116                                                         OptionsName name,
00117                                                         std::string& value
00118                                                         ) const
00119 {
00120         if ( idx >= getNumOptionsLists( ) )
00121                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00122 
00123         return lists[idx].get( name,value );
00124 }
00125 
00126 returnValue Options::set(       OptionsName name,
00127                                                         int value
00128                                                         )
00129 {
00130         return lists[0].set( name,value );
00131 }
00132 
00133 
00134 returnValue Options::set(       OptionsName name,
00135                                                         double value
00136                                                         )
00137 {       
00138         return lists[0].set( name,value );
00139 }
00140 
00141 returnValue Options::set(       OptionsName name,
00142                                                         const std::string& value
00143                                                         )
00144 {
00145         return lists[0].set( name,value );
00146 }
00147 
00148 returnValue Options::set(       uint idx,
00149                                                         OptionsName name,
00150                                                         int value
00151                                                         )
00152 {
00153         if ( idx >= getNumOptionsLists( ) )
00154                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00155 
00156         return lists[idx].set( name,value );
00157 }
00158 
00159 
00160 returnValue Options::set(       uint idx,
00161                                                         OptionsName name,
00162                                                         double value
00163                                                         )
00164 {
00165         if ( idx >= getNumOptionsLists( ) )
00166                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00167         
00168         return lists[idx].set( name,value );
00169 }
00170 
00171 returnValue Options::set(       uint idx,
00172                                                         OptionsName name,
00173                                                         const std::string& value
00174                                                         )
00175 {
00176         if ( idx >= getNumOptionsLists( ) )
00177                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00178 
00179         return lists[idx].set( name,value );
00180 }
00181 
00182 
00183 returnValue Options::setOptions(        const Options &arg
00184                                                                         )
00185 {
00186         operator=( arg );
00187         return SUCCESSFUL_RETURN;
00188 }
00189 
00190 
00191 returnValue Options::setOptions(        uint idx,
00192                                                                         const Options &arg
00193                                                                         )
00194 {
00195         if ( ( idx >= getNumOptionsLists( ) ) || ( idx >= arg.getNumOptionsLists( ) ) )
00196                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00197 
00198         lists[ idx ] = arg.lists[ idx ];
00199 
00200         return SUCCESSFUL_RETURN;
00201 }
00202 
00203 
00204 Options Options::getOptions(    uint idx
00205                                                                 ) const
00206 {
00207         if ( idx >= getNumOptionsLists( ) )
00208         {
00209                 ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00210                 return Options();
00211         }
00212 
00213         return Options( lists[idx] );
00214 }
00215 
00216 
00217 returnValue Options::printOptionsList( ) const
00218 {
00219         returnValue returnvalue;
00220         
00221         for( uint i=0; i<getNumOptionsLists( ); ++i )
00222         {
00223                 returnvalue = lists[i].printOptionsList( );
00224                 if ( returnvalue != SUCCESSFUL_RETURN )
00225                         return returnvalue;
00226         }
00227         
00228         return SUCCESSFUL_RETURN;
00229 }
00230 
00231 
00232 returnValue Options::printOptionsList(  uint idx
00233                                                                                 ) const
00234 {
00235         if ( idx >= getNumOptionsLists( ) )
00236                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00237 
00238         return lists[idx].printOptionsList( );
00239 }
00240 
00241 
00242 //
00243 // PROTECTED MEMBER FUNCTIONS:
00244 //
00245 
00246 returnValue Options::setupOptions( )
00247 {
00248         return SUCCESSFUL_RETURN;
00249 }
00250 
00251 BooleanType Options::haveOptionsChanged( ) const
00252 {
00253         for( uint i=0; i<getNumOptionsLists( ); ++i )
00254         {
00255                 if ( lists[i].haveOptionsChanged( ) == BT_TRUE )
00256                         return BT_TRUE;
00257         }
00258         
00259         return BT_FALSE;
00260 }
00261 
00262 
00263 BooleanType Options::haveOptionsChanged(        uint idx
00264                                                                                         ) const
00265 {
00266         if ( idx >= getNumOptionsLists( ) )
00267         {
00268                 ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00269                 return BT_FALSE;
00270         }
00271 
00272         return lists[idx].haveOptionsChanged( );
00273 }
00274 
00275 
00276 returnValue Options::declareOptionsUnchanged( )
00277 {
00278         returnValue returnvalue;
00279         
00280         for( uint i=0; i<getNumOptionsLists( ); ++i )
00281         {
00282                 returnvalue = lists[i].declareOptionsUnchanged( );
00283                 if ( returnvalue != SUCCESSFUL_RETURN )
00284                         return returnvalue;
00285         }
00286         
00287         return SUCCESSFUL_RETURN;
00288 }
00289 
00290 
00291 returnValue Options::declareOptionsUnchanged(   uint idx
00292                                                                                                 )
00293 {
00294         if ( idx >= getNumOptionsLists( ) )
00295                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00296 
00297         return lists[idx].declareOptionsUnchanged( );
00298 }
00299 
00300 
00301 returnValue Options::addOption( OptionsName name,
00302                                                                 int value
00303                                                                 )
00304 {
00305         returnValue returnvalue;
00306         
00307         for( uint i=0; i<getNumOptionsLists( ); ++i )
00308         {
00309                 returnvalue = lists[i].add( name,value );
00310                 if ( returnvalue != SUCCESSFUL_RETURN )
00311                         return returnvalue;
00312         }
00313         
00314         return SUCCESSFUL_RETURN;
00315 }
00316 
00317 
00318 returnValue Options::addOption( OptionsName name,
00319                                                                 double value
00320                                                                 )
00321 {
00322         returnValue returnvalue;
00323         
00324         for( uint i=0; i<getNumOptionsLists( ); ++i )
00325         {
00326                 returnvalue = lists[i].add( name,value );
00327                 if ( returnvalue != SUCCESSFUL_RETURN )
00328                         return returnvalue;
00329         }
00330         
00331         return SUCCESSFUL_RETURN;
00332 }
00333 
00334 returnValue Options::addOption( OptionsName name,
00335                                                                 const std::string& value
00336                                                                 )
00337 {
00338         returnValue returnvalue;
00339 
00340         for( uint i=0; i<getNumOptionsLists( ); ++i )
00341         {
00342                 returnvalue = lists[i].add( name,value );
00343                 if ( returnvalue != SUCCESSFUL_RETURN )
00344                         return returnvalue;
00345         }
00346 
00347         return SUCCESSFUL_RETURN;
00348 }
00349 
00350 
00351 
00352 returnValue Options::addOption( uint idx,
00353                                                                 OptionsName name,
00354                                                                 int value
00355                                                                 )
00356 {
00357         if ( idx >= getNumOptionsLists( ) )
00358                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00359 
00360         return lists[idx].add( name,value );
00361 }
00362 
00363 
00364 returnValue Options::addOption( uint idx,
00365                                                                 OptionsName name,
00366                                                                 double value
00367                                                                 )
00368 {
00369         if ( idx >= getNumOptionsLists( ) )
00370                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00371 
00372         return lists[idx].add( name,value );
00373 }
00374 
00375 returnValue Options::addOption( uint idx,
00376                                                                 OptionsName name,
00377                                                                 const std::string& value
00378                                                                 )
00379 {
00380         if ( idx >= getNumOptionsLists( ) )
00381                 return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
00382 
00383         return lists[idx].add( name,value );
00384 }
00385 
00386 uint Options::getNumOptionsLists() const
00387 {
00388         return lists.size();
00389 }
00390 
00391 CLOSE_NAMESPACE_ACADO
00392 
00393 
00394 /*
00395  *      end of file
00396  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:15