export_function.hpp
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 
00027 
00035 #ifndef ACADO_TOOLKIT_EXPORT_FUNCTION_HPP
00036 #define ACADO_TOOLKIT_EXPORT_FUNCTION_HPP
00037 
00038 #include <acado/utils/acado_utils.hpp>
00039 #include <acado/code_generation/export_variable.hpp>
00040 #include <acado/code_generation/export_argument_list.hpp>
00041 #include <acado/code_generation/export_statement_block.hpp>
00042 #include <acado/code_generation/export_statement_string.hpp>
00043 #include <acado/code_generation/memory_allocator.hpp>
00044 
00045 #ifdef _WIN32
00046     #include <memory>
00047 #else
00048     #include <tr1/memory>
00049 #endif
00050 
00051 BEGIN_NAMESPACE_ACADO
00052 
00053 
00062 class ExportFunction : public ExportStatementBlock
00063 {
00064 public:
00079         ExportFunction( const std::string& _name = "defaultFunctionName",
00080                                         const ExportArgument& _argument1 = emptyConstExportArgument,
00081                                         const ExportArgument& _argument2 = emptyConstExportArgument,
00082                                         const ExportArgument& _argument3 = emptyConstExportArgument,
00083                                         const ExportArgument& _argument4 = emptyConstExportArgument,
00084                                         const ExportArgument& _argument5 = emptyConstExportArgument,
00085                                         const ExportArgument& _argument6 = emptyConstExportArgument,
00086                                         const ExportArgument& _argument7 = emptyConstExportArgument,
00087                                         const ExportArgument& _argument8 = emptyConstExportArgument,
00088                                         const ExportArgument& _argument9 = emptyConstExportArgument
00089                                         );
00090 
00093         virtual ~ExportFunction( );
00094 
00099         virtual ExportStatement* clone( ) const;
00100 
00116         returnValue init(       const std::string& _name = "defaultFunctionName",
00117                                                 const ExportArgument& _argument1 = emptyConstExportArgument,
00118                                                 const ExportArgument& _argument2 = emptyConstExportArgument,
00119                                                 const ExportArgument& _argument3 = emptyConstExportArgument,
00120                                                 const ExportArgument& _argument4 = emptyConstExportArgument,
00121                                                 const ExportArgument& _argument5 = emptyConstExportArgument,
00122                                                 const ExportArgument& _argument6 = emptyConstExportArgument,
00123                                                 const ExportArgument& _argument7 = emptyConstExportArgument,
00124                                                 const ExportArgument& _argument8 = emptyConstExportArgument,
00125                                                 const ExportArgument& _argument9 = emptyConstExportArgument
00126                                                 );
00127 
00143         ExportFunction& setup(  const std::string& _name = "defaultFunctionName",
00144                                                         const ExportArgument& _argument1 = emptyConstExportArgument,
00145                                                         const ExportArgument& _argument2 = emptyConstExportArgument,
00146                                                         const ExportArgument& _argument3 = emptyConstExportArgument,
00147                                                         const ExportArgument& _argument4 = emptyConstExportArgument,
00148                                                         const ExportArgument& _argument5 = emptyConstExportArgument,
00149                                                         const ExportArgument& _argument6 = emptyConstExportArgument,
00150                                                         const ExportArgument& _argument7 = emptyConstExportArgument,
00151                                                         const ExportArgument& _argument8 = emptyConstExportArgument,
00152                                                         const ExportArgument& _argument9 = emptyConstExportArgument
00153                                                         );
00154 
00155 
00171         returnValue addArgument(        const ExportArgument& _argument1,
00172                                                                 const ExportArgument& _argument2 = emptyConstExportArgument,
00173                                                                 const ExportArgument& _argument3 = emptyConstExportArgument,
00174                                                                 const ExportArgument& _argument4 = emptyConstExportArgument,
00175                                                                 const ExportArgument& _argument5 = emptyConstExportArgument,
00176                                                                 const ExportArgument& _argument6 = emptyConstExportArgument,
00177                                                                 const ExportArgument& _argument7 = emptyConstExportArgument,
00178                                                                 const ExportArgument& _argument8 = emptyConstExportArgument,
00179                                                                 const ExportArgument& _argument9 = emptyConstExportArgument
00180                                                                 );
00181 
00189         ExportFunction& setReturnValue( const ExportVariable& _functionReturnValue,
00190                                                                         bool _returnAsPointer = false
00191                                                                         );
00192 
00193 
00195         ExportFunction& setName(const std::string& _name);
00196 
00198         std::string getName( ) const;
00199 
00210         virtual returnValue exportDataDeclaration(      std::ostream& stream,
00211                                                                                                 const std::string& _realString = "real_t",
00212                                                                                                 const std::string& _intString = "int",
00213                                                                                                 int _precision = 16
00214                                                                                                 ) const;
00215 
00226         virtual returnValue exportForwardDeclaration(   std::ostream& stream,
00227                                                                                                         const std::string& _realString = "real_t",
00228                                                                                                         const std::string& _intString = "int",
00229                                                                                                         int _precision = 16
00230                                                                                                         ) const;
00231 
00242         virtual returnValue exportCode( std::ostream& stream,
00243                                                                         const std::string& _realString = "real_t",
00244                                                                         const std::string& _intString = "int",
00245                                                                         int _precision = 16
00246                                                                         ) const;
00247 
00253         virtual bool isDefined( ) const;
00254 
00256         unsigned getNumArguments( ) const;
00257 
00259         ExportFunction& addIndex( const ExportIndex& _index );
00260 
00262         ExportFunction& addVariable( const ExportVariable& _var );
00263 
00265         virtual ExportFunction& acquire( ExportIndex& obj );
00266 
00268         virtual ExportFunction& release( const ExportIndex& obj );
00269 
00271         virtual ExportFunction& doc( const std::string& _doc );
00272 
00274         virtual ExportFunction& setPrivate(     bool _set = true );
00275 
00277         virtual bool isPrivate() const;
00278 
00279 protected:
00284         returnValue clear( );
00285 
00287         std::string name;
00289         std::string description;
00290 
00292         ExportArgumentList functionArguments;
00294         ExportVariable retVal;
00296         bool returnAsPointer;
00298         MemoryAllocatorPtr memAllocator;
00300         std::vector< ExportVariable > localVariables;
00302         bool flagPrivate;
00303 };
00304 
00305 CLOSE_NAMESPACE_ACADO
00306 
00307 #endif  // ACADO_TOOLKIT_EXPORT_FUNCTION_HPP


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