6 #ifndef KNOWROB_PY_WITH_H
7 #define KNOWROB_PY_WITH_H
9 #include <boost/python.hpp>
10 #include <boost/function.hpp>
11 #include <boost/function_types/components.hpp>
12 #include <boost/function_types/function_type.hpp>
13 #include <boost/function_types/result_type.hpp>
20 template<
typename Signature,
typename Guard>
21 class guarded_function {
40 template<
typename A1,
typename A2>
46 template<
typename A1,
typename A2,
typename A3>
49 return fn_(a1, a2, a3);
53 boost::function<Signature> fn_;
57 template<
typename Signature>
58 struct mpl_signature {
59 typedef typename boost::function_types::components<Signature,
60 boost::add_pointer<boost::mpl::placeholders::_> >
::type type;
64 template<
typename Signature>
70 template<
typename Guard,
typename Fn,
typename Policy>
71 boost::python::object
with_aux(Fn fn,
const Policy &policy) {
84 typedef typename boost::function_types::function_type<
85 mpl_signature_type>
::type signature_type;
89 return boost::python::make_function(
91 policy, mpl_signature_type());
95 template<
typename Guard,
typename Fn,
typename Policy>
96 boost::python::object
with(
const Fn &fn,
const Policy &policy) {
97 return with_aux<Guard>(fn, policy);
101 template<
typename Guard,
typename Fn>
102 boost::python::object
with(
const Fn &fn) {
103 return with<Guard>(fn, boost::python::default_call_policies());
result_type operator()(const A1 &a1)
result_type operator()(const A1 &a1, const A2 &a2, const A3 &a3)
result_type operator()(const A1 &a1, const A2 &a2)
boost::function_types::result_type< Signature >::type result_type
FunctionRule & function()
boost::python::object with_aux(Fn fn, const Policy &policy)
boost::python::object with(const Fn &fn, const Policy &policy)
boost::function_types::components< Signature >::type type
boost::function_types::components< Signature, boost::add_pointer< boost::mpl::placeholders::_ > >::type type