export_function.hpp
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 
27 
35 #ifndef ACADO_TOOLKIT_EXPORT_FUNCTION_HPP
36 #define ACADO_TOOLKIT_EXPORT_FUNCTION_HPP
37 
44 
45 #include <memory>
46 
48 
49 
59 {
60 public:
75  ExportFunction( const std::string& _name = "defaultFunctionName",
76  const ExportArgument& _argument1 = emptyConstExportArgument,
77  const ExportArgument& _argument2 = emptyConstExportArgument,
78  const ExportArgument& _argument3 = emptyConstExportArgument,
79  const ExportArgument& _argument4 = emptyConstExportArgument,
80  const ExportArgument& _argument5 = emptyConstExportArgument,
81  const ExportArgument& _argument6 = emptyConstExportArgument,
82  const ExportArgument& _argument7 = emptyConstExportArgument,
83  const ExportArgument& _argument8 = emptyConstExportArgument,
84  const ExportArgument& _argument9 = emptyConstExportArgument
85  );
86 
89  virtual ~ExportFunction( );
90 
95  virtual ExportStatement* clone( ) const;
96 
112  returnValue init( const std::string& _name = "defaultFunctionName",
113  const ExportArgument& _argument1 = emptyConstExportArgument,
114  const ExportArgument& _argument2 = emptyConstExportArgument,
115  const ExportArgument& _argument3 = emptyConstExportArgument,
116  const ExportArgument& _argument4 = emptyConstExportArgument,
117  const ExportArgument& _argument5 = emptyConstExportArgument,
118  const ExportArgument& _argument6 = emptyConstExportArgument,
119  const ExportArgument& _argument7 = emptyConstExportArgument,
120  const ExportArgument& _argument8 = emptyConstExportArgument,
121  const ExportArgument& _argument9 = emptyConstExportArgument
122  );
123 
139  ExportFunction& setup( const std::string& _name = "defaultFunctionName",
140  const ExportArgument& _argument1 = emptyConstExportArgument,
141  const ExportArgument& _argument2 = emptyConstExportArgument,
142  const ExportArgument& _argument3 = emptyConstExportArgument,
143  const ExportArgument& _argument4 = emptyConstExportArgument,
144  const ExportArgument& _argument5 = emptyConstExportArgument,
145  const ExportArgument& _argument6 = emptyConstExportArgument,
146  const ExportArgument& _argument7 = emptyConstExportArgument,
147  const ExportArgument& _argument8 = emptyConstExportArgument,
148  const ExportArgument& _argument9 = emptyConstExportArgument
149  );
150 
151 
167  returnValue addArgument( const ExportArgument& _argument1,
168  const ExportArgument& _argument2 = emptyConstExportArgument,
169  const ExportArgument& _argument3 = emptyConstExportArgument,
170  const ExportArgument& _argument4 = emptyConstExportArgument,
171  const ExportArgument& _argument5 = emptyConstExportArgument,
172  const ExportArgument& _argument6 = emptyConstExportArgument,
173  const ExportArgument& _argument7 = emptyConstExportArgument,
174  const ExportArgument& _argument8 = emptyConstExportArgument,
175  const ExportArgument& _argument9 = emptyConstExportArgument
176  );
177 
185  ExportFunction& setReturnValue( const ExportVariable& _functionReturnValue,
186  bool _returnAsPointer = false
187  );
188 
189 
191  ExportFunction& setName(const std::string& _name);
192 
194  std::string getName( ) const;
195 
206  virtual returnValue exportDataDeclaration( std::ostream& stream,
207  const std::string& _realString = "real_t",
208  const std::string& _intString = "int",
209  int _precision = 16
210  ) const;
211 
222  virtual returnValue exportForwardDeclaration( std::ostream& stream,
223  const std::string& _realString = "real_t",
224  const std::string& _intString = "int",
225  int _precision = 16
226  ) const;
227 
238  virtual returnValue exportCode( std::ostream& stream,
239  const std::string& _realString = "real_t",
240  const std::string& _intString = "int",
241  int _precision = 16
242  ) const;
243 
249  virtual bool isDefined( ) const;
250 
252  unsigned getNumArguments( ) const;
253 
255  ExportFunction& addIndex( const ExportIndex& _index );
256 
258  ExportFunction& addVariable( const ExportVariable& _var );
259 
261  virtual ExportFunction& acquire( ExportIndex& obj );
262 
264  virtual ExportFunction& release( const ExportIndex& obj );
265 
267  virtual ExportFunction& doc( const std::string& _doc );
268 
270  virtual ExportFunction& setPrivate( bool _set = true );
271 
273  virtual bool isPrivate() const;
274 
275 protected:
280  returnValue clear( );
281 
283  std::string name;
285  std::string description;
286 
296  std::vector< ExportVariable > localVariables;
299 };
300 
302 
303 #endif // ACADO_TOOLKIT_EXPORT_FUNCTION_HPP
virtual returnValue exportCode(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
returnValue addArgument(const ExportArgument &_argument1, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
ExportFunction(const std::string &_name="defaultFunctionName", const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
unsigned getNumArguments() const
ExportFunction & setName(const std::string &_name)
returnValue init(const std::string &_name="defaultFunctionName", const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
virtual returnValue exportForwardDeclaration(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
Allows to pass back messages to the calling function.
virtual ~ExportFunction()
#define CLOSE_NAMESPACE_ACADO
virtual bool isPrivate() const
Defines a scalar-valued index variable to be used for exporting code.
ExportVariable retVal
Defines a matrix-valued variable that can be passed as argument to exported functions.
ExportFunction & setup(const std::string &_name="defaultFunctionName", const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
virtual ExportFunction & doc(const std::string &_doc)
virtual bool isDefined() const
Allows to store a list of calling arguments of an ExportFunction.
virtual ExportStatement * clone() const
virtual ExportFunction & setPrivate(bool _set=true)
virtual returnValue exportDataDeclaration(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
Base class for all kind of statements to be exported by the code generation tool. ...
Allows to export code of an arbitrary function.
static const ExportArgument emptyConstExportArgument
ExportFunction & setReturnValue(const ExportVariable &_functionReturnValue, bool _returnAsPointer=false)
virtual ExportFunction & acquire(ExportIndex &obj)
ExportFunction & addVariable(const ExportVariable &_var)
std::string getName() const
virtual ExportFunction & release(const ExportIndex &obj)
std::string description
#define BEGIN_NAMESPACE_ACADO
std::vector< ExportVariable > localVariables
returnValue clear()
std::shared_ptr< MemoryAllocator > MemoryAllocatorPtr
Allows to export code for a block of statements.
ExportFunction & addIndex(const ExportIndex &_index)
ExportArgumentList functionArguments
Defines a matrix-valued variable to be used for exporting code.
MemoryAllocatorPtr memAllocator


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