Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96561325
python_functor.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Dec 28, 03:23
Size
4 KB
Mime Type
text/x-c++
Expires
Mon, Dec 30, 03:23 (2 d)
Engine
blob
Format
Raw Data
Handle
23155576
Attached To
rAKA akantu
python_functor.hh
View Options
/**
* @file python_functor.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Nov 15 2015
*
* @brief Python Functor interface
*
* @section LICENSE
*
* Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_PYTHON_FUNCTOR_HH__
#define __AKANTU_PYTHON_FUNCTOR_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include <Python.h>
/* -------------------------------------------------------------------------- */
__BEGIN_AKANTU__
/* -------------------------------------------------------------------------- */
class
PythonFunctor
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
PythonFunctor
(
PyObject
*
obj
);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
protected
:
/// call the python functor
PyObject
*
callFunctor
(
PyObject
*
functor
,
PyObject
*
args
,
PyObject
*
kwargs
)
const
;
/// call the python functor from variadic types
template
<
typename
return_type
,
typename
...
Params
>
return_type
callFunctor
(
const
std
::
string
&
functor_name
,
Params
&
...
parameters
)
const
;
/// empty function to cose the recursive template loop
inline
void
packArguments
(
std
::
vector
<
PyObject
*>
&
pArgs
)
const
;
/// get the python function object
inline
PyObject
*
getPythonFunction
(
const
std
::
string
&
functor_name
)
const
;
/// variadic template for unknown number of arguments to unpack
template
<
typename
T
,
typename
...
Args
>
inline
void
packArguments
(
std
::
vector
<
PyObject
*>
&
pArgs
,
T
&
p
,
Args
&
...
params
)
const
;
/// convert an akantu object to python
template
<
typename
T
>
inline
PyObject
*
convertToPython
(
const
T
&
akantu_obj
)
const
;
/// convert a stl vector to python
template
<
typename
T
>
inline
PyObject
*
convertToPython
(
const
std
::
vector
<
T
>
&
akantu_obj
)
const
;
/// convert an akantu vector to python
template
<
typename
T
>
inline
PyObject
*
convertToPython
(
const
Vector
<
T
>
&
akantu_obj
)
const
;
/// convert a akantu matrix to python
template
<
typename
T
>
inline
PyObject
*
convertToPython
(
const
Matrix
<
T
>
&
akantu_obj
)
const
;
/// convert a python object to an akantu object
template
<
typename
return_type
>
inline
return_type
convertToAkantu
(
PyObject
*
python_obj
)
const
;
/// convert a python object to an akantu object
template
<
typename
T
>
inline
std
::
vector
<
T
>
convertListToAkantu
(
PyObject
*
python_obj
)
const
;
/// returns the numpy data type code
template
<
typename
T
>
inline
int
getPythonDataTypeCode
()
const
;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
PyObject
*
python_obj
;
};
/* -------------------------------------------------------------------------- */
__END_AKANTU__
/* -------------------------------------------------------------------------- */
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include "python_functor_inline_impl.cc"
/* -------------------------------------------------------------------------- */
#endif
/* __AKANTU_PYTHON_FUNCTOR_HH__ */
Event Timeline
Log In to Comment