export_argument_list.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/code_generation/export_argument_list.hpp>
00034 
00035 
00036 
00037 BEGIN_NAMESPACE_ACADO
00038 
00039 
00040 //
00041 // PUBLIC MEMBER FUNCTIONS:
00042 //
00043 
00044 ExportArgumentList::ExportArgumentList( )
00045 {
00046         doIncludeType( );
00047 }
00048 
00049 
00050 ExportArgumentList::ExportArgumentList( const ExportArgument& _argument1,
00051                                                                                 const ExportArgument& _argument2,
00052                                                                                 const ExportArgument& _argument3,
00053                                                                                 const ExportArgument& _argument4,
00054                                                                                 const ExportArgument& _argument5,
00055                                                                                 const ExportArgument& _argument6,
00056                                                                                 const ExportArgument& _argument7,
00057                                                                                 const ExportArgument& _argument8,
00058                                                                                 const ExportArgument& _argument9
00059                                                                                 )
00060 {
00061         addArgument( _argument1,_argument2,_argument3,
00062                                  _argument4,_argument5,_argument6,
00063                                  _argument7,_argument8,_argument9 );
00064 }
00065 
00066 
00067 ExportArgumentList::ExportArgumentList( const ExportArgumentList& arg )
00068 {
00069         arguments = arg.arguments;
00070         
00071         includeType = arg.includeType;
00072 }
00073 
00074 
00075 ExportArgumentList::~ExportArgumentList( )
00076 {
00077         clear( );
00078 }
00079 
00080 
00081 ExportArgumentList& ExportArgumentList::operator=( const ExportArgumentList& arg )
00082 {
00083         if ( this != &arg )
00084         {
00085                 clear( );
00086 
00087                 arguments = arg.arguments;
00088                 
00089                 includeType = arg.includeType;
00090         }
00091 
00092         return *this;
00093 }
00094 
00095 
00096 
00097 returnValue ExportArgumentList::addArgument(    const ExportArgument& _argument1,
00098                                                                                                 const ExportArgument& _argument2,
00099                                                                                                 const ExportArgument& _argument3,
00100                                                                                                 const ExportArgument& _argument4,
00101                                                                                                 const ExportArgument& _argument5,
00102                                                                                                 const ExportArgument& _argument6,
00103                                                                                                 const ExportArgument& _argument7,
00104                                                                                                 const ExportArgument& _argument8,
00105                                                                                                 const ExportArgument& _argument9
00106                                                                                                 )
00107 {
00108         addSingleArgument( _argument1 );
00109         addSingleArgument( _argument2 );
00110         addSingleArgument( _argument3 );
00111         addSingleArgument( _argument4 );
00112         addSingleArgument( _argument5 );
00113         addSingleArgument( _argument6 );
00114         addSingleArgument( _argument7 );
00115         addSingleArgument( _argument8 );
00116         addSingleArgument( _argument9 );
00117 
00118         return SUCCESSFUL_RETURN;
00119 }
00120 
00121 
00122 uint ExportArgumentList::getNumArguments( ) const
00123 {
00124         return arguments.size();
00125 }
00126 
00127 
00128 
00129 returnValue ExportArgumentList::exportCode(     std::ostream& stream,
00130                                                                                         const std::string& _realString,
00131                                                                                         const std::string& _intString,
00132                                                                                         int _precision
00133                                                                                         ) const
00134 {
00135         bool started = false;
00136         for (unsigned i = 0; i < arguments.size(); ++i)
00137         {
00138                 // Allow only undefined arguments and defined integer scalars
00139                 if (    arguments[ i ].isGiven( ) == true &&
00140                                 (arguments[ i ].getDim() > 1 || arguments[ i ].getType() != INT) &&
00141                                 arguments[ i ].getType() != STATIC_CONST_INT &&
00142                                 arguments[ i ].getType() != STATIC_CONST_REAL
00143                                 )
00144                         continue;
00145 
00146                 if (i > 0 && started == true)
00147                         stream << ", ";
00148 
00149                 if ( includeType == true )
00150                 {
00151                         if ( arguments[ i ].isCalledByValue( ) == true )
00152                                 stream << arguments[ i ].getTypeString(_realString, _intString) << " ";
00153                         else
00154                                 stream << arguments[ i ].getTypeString(_realString, _intString) << "* const ";
00155                 }
00156 
00157                 if ( includeType == false )
00158                         stream << arguments[ i ].getAddressString( );
00159                 else
00160                         stream << arguments[ i ].getAddressString( false );
00161 
00162                 started = true;
00163         }
00164 
00165         return SUCCESSFUL_RETURN;
00166 }
00167 
00168 
00169 
00170 returnValue ExportArgumentList::clear( )
00171 {
00172         doIncludeType( );
00173 
00174         return SUCCESSFUL_RETURN;
00175 }
00176 
00177 
00178 
00179 returnValue ExportArgumentList::doIncludeType( )
00180 {
00181         includeType = true;
00182         return SUCCESSFUL_RETURN;
00183 }
00184 
00185 
00186 returnValue ExportArgumentList::doNotIncludeType( )
00187 {
00188         includeType = false;
00189         return SUCCESSFUL_RETURN;
00190 }
00191 
00192 
00193 
00194 //
00195 // PROTECTED MEMBER FUNCTIONS:
00196 //
00197 
00198 returnValue ExportArgumentList::addSingleArgument(      const ExportArgument& _argument
00199                                                                                                         )
00200 {
00201         if ( _argument.isNull() )
00202                 return SUCCESSFUL_RETURN;
00203         if (_argument.getDim() == 0)
00204                 return SUCCESSFUL_RETURN;
00205 
00206         arguments.push_back( _argument );
00207 
00208         return SUCCESSFUL_RETURN;
00209 }
00210 
00211 const std::vector< ExportArgument >& ExportArgumentList::get() const
00212 {
00213         return arguments;
00214 }
00215 
00216 
00217 CLOSE_NAMESPACE_ACADO
00218 
00219 // end of file.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:09