cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
PythonUtils.h File Reference
#include <boost/mpl/vector.hpp>
#include <boost/python.hpp>
+ Include dependency graph for PythonUtils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  cepgen
 Common namespace for this Monte Carlo generator.
 

Macros

#define EXPOSE_FACTORY(obj, key, name, description)
 

Functions

template<class T >
py::list std_vector_to_py_list (const std::vector< T > &vec)
 
template<class T >
std::vector< T > py_tuple_to_std_vector (const py::tuple &tuple)
 
template<class T >
std::vector< T > py_list_to_std_vector (const py::list &list)
 
template<class T >
py::tuple std_vector_to_py_tuple (const std::vector< T > &vec)
 
cepgen::ParametersList py_dict_to_plist (const py::dict &)
 
py::dict plist_to_py_dict (const cepgen::ParametersList &)
 
template<typename T , typename... Args>
py::object adapt_unique (std::unique_ptr< T >(*fn)(Args...))
 
template<typename T , typename C , typename... Args>
py::object adapt_unique (std::unique_ptr< T >(C::*fn)(Args...))
 
template<typename T >
py::object adapt_reference (T *ptr)
 

Macro Definition Documentation

◆ EXPOSE_FACTORY

#define EXPOSE_FACTORY (   obj,
  key,
  name,
  description 
)
Value:
py::class_<obj, boost::noncopyable>(name, description, py::no_init) \
.def("build", adapt_unique(+[](const key& mod) { return obj::get().build(mod); })) \
.def("build", adapt_unique(+[](const key& mod, const py::dict& dict) { \
return obj::get().build(mod, py_dict_to_plist(dict)); \
})) \
.def("build", adapt_unique(+[](const py::dict& dict) { return obj::get().build(py_dict_to_plist(dict)); })) \
.def( \
"describe", \
+[](const key& mod) { \
std::ostringstream os; \
os << obj::get().describeParameters(mod); \
return os.str(); \
}) \
.add_static_property( \
"modules", +[]() { return std_vector_to_py_list(obj::get().modules()); })
cepgen::ParametersList py_dict_to_plist(const py::dict &)
py::object adapt_unique(std::unique_ptr< T >(*fn)(Args...))
Definition PythonUtils.h:80
py::list std_vector_to_py_list(const std::vector< T > &vec)
Definition PythonUtils.h:49

Definition at line 25 of file PythonUtils.h.

Function Documentation

◆ adapt_reference()

template<typename T >
py::object adapt_reference ( T *  ptr)

Definition at line 94 of file PythonUtils.h.

◆ adapt_unique() [1/2]

template<typename T , typename... Args>
py::object adapt_unique ( std::unique_ptr< T >(*)(Args...)  fn)

Definition at line 80 of file PythonUtils.h.

◆ adapt_unique() [2/2]

template<typename T , typename C , typename... Args>
py::object adapt_unique ( std::unique_ptr< T >(C::*)(Args...)  fn)

Definition at line 87 of file PythonUtils.h.

◆ plist_to_py_dict()

py::dict plist_to_py_dict ( const cepgen::ParametersList plist)

Definition at line 71 of file PythonUtils.cpp.

◆ py_dict_to_plist()

cepgen::ParametersList py_dict_to_plist ( const py::dict &  dict)

Definition at line 23 of file PythonUtils.cpp.

◆ py_list_to_std_vector()

template<class T >
std::vector< T > py_list_to_std_vector ( const py::list &  list)

Definition at line 64 of file PythonUtils.h.

◆ py_tuple_to_std_vector()

template<class T >
std::vector< T > py_tuple_to_std_vector ( const py::tuple &  tuple)

Definition at line 56 of file PythonUtils.h.

◆ std_vector_to_py_list()

template<class T >
py::list std_vector_to_py_list ( const std::vector< T > &  vec)

Definition at line 49 of file PythonUtils.h.

◆ std_vector_to_py_tuple()

template<class T >
py::tuple std_vector_to_py_tuple ( const std::vector< T > &  vec)

Definition at line 72 of file PythonUtils.h.