Commit 23ecfb0c authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Creating the first python interface.

Adding a wrap to a python interface for function.
parent d0b63742
......@@ -32,7 +32,7 @@ class function : public parametrized
/* INTERFACE */
// Overload the function operator
virtual vec operator()(const vec& x) const = 0 ;
virtual vec operator()(const vec& x) const { return this->value(x); } ;
virtual vec value(const vec& x) const = 0 ;
//! \brief Provide a first rough fit of the function.
......
env = Environment()
env.Append(CPPPATH=['../../external/build/include'])
env.Append(CPPPATH=['../', '/usr/include/python2.7'])
env.Append(LIBPATH=['../build', '/usr/lib/x86_64-gnu-linux'])
env.Append(LIBS=['python2.7', 'boost_python-py27', 'core'])
env['SHLIBPREFIX']=''
env.SharedLibrary('alta', ['alta.cpp'])
\ No newline at end of file
import os
import sys
SConscript('SConscript')
// Boost includes
#include <boost/python.hpp>
// ALTA include
#include <core/function.h>
using namespace boost::python;
// Creating a non purely virtual class for the function
struct Function : function, wrapper<function>
{
vec value(const vec& x) const
{
return this->get_override("value")(x);
}
bool load(std::istream& in) {
return this->get_override("load")(in);
}
};
// Exporting the ALTA module
BOOST_PYTHON_MODULE(alta)
{
class_<Function, boost::noncopyable>("function")
.def("value", pure_virtual(&function::value))
;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment