Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00033 #include <acado/code_generation/export_argument_list.hpp>
00034 
00035 
00036 
00037 BEGIN_NAMESPACE_ACADO
00038 
00039 
00040 
00041 
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                 
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 
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