cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches

Smart pointer to a Python object and its dereferencing operator. More...

#include <CepGenAddOns/PythonWrapper/ObjectPtr.h>

+ Inheritance diagram for ObjectPtr:
+ Collaboration diagram for ObjectPtr:

Public Member Functions

 ObjectPtr (PyObject *, bool wrap_only=false)
 
template<typename T >
bool is () const
 Check if a Python object holds a given C++ type.
 
template<typename T >
value () const
 Cast a Python object into a C++ type.
 
template<typename T >
bool isVector () const
 Check if a Python object is compatible with a vector of uniform objects.
 
template<typename T >
std::vector< T > vector () const
 Retrieve a vector of objects, either from a Python list or tuple.
 
template<typename... Args>
ObjectPtr operator() (Args &&... args)
 Call a python function with an uncounted set of arguments.
 
ObjectPtr call (const ObjectPtr &) const
 Call a python function with a tuple of arguments.
 
ObjectPtr attribute (const std::string &) const
 Retrieve the attribute from a python object.
 
template<>
bool is () const
 
template<>
bool is () const
 
template<>
bool is () const
 
template<>
bool is () const
 
template<>
bool is () const
 
template<>
bool is () const
 
template<>
bool value () const
 
template<>
int value () const
 
template<>
unsigned long value () const
 
template<>
long long value () const
 
template<>
double value () const
 
template<>
Limits value () const
 
template<>
ParametersList value () const
 
template<>
ObjectPtr tupleFromVector (const std::vector< PyObject * > &vec)
 

Static Public Member Functions

static ObjectPtr wrap (PyObject *)
 Wrap a PyObject without cleaning at the destructor.
 
static ObjectPtr importModule (const std::string &)
 Import a Python module in a new reference-counted Python object.
 
static ObjectPtr defineModule (const std::string &, const std::string &)
 Define a Python module from a Python code in a new reference-counted Python object.
 
template<typename T >
static ObjectPtr make (const T &)
 Build a new Python object from a C++ one.
 
template<typename T >
static ObjectPtr make (const std::vector< T > &vec)
 Build a new Python list from a C++ STL vector.
 
template<typename T >
static ObjectPtr tupleFromVector (const std::vector< T > &)
 Build a Python tuple from a (uniform) vector of objects.
 
template<typename... Args>
static ObjectPtr tuple (const std::tuple< Args... > &c_tuple)
 Build a Python tuple from a C++ tuple.
 
template<>
ObjectPtr make (PyObject *const &obj)
 
template<>
ObjectPtr make (const int &val)
 
template<>
ObjectPtr make (const bool &val)
 
template<>
ObjectPtr make (const double &val)
 
template<>
ObjectPtr make (const Limits &val)
 
template<>
ObjectPtr make (const ParametersList &plist)
 

Friends

std::ostream & operator<< (std::ostream &, const ObjectPtr &)
 

Detailed Description

Definition at line 36 of file ObjectPtr.h.

Constructor & Destructor Documentation

◆ ObjectPtr()

ObjectPtr ( PyObject *  obj,
bool  wrap_only = false 
)
explicit

Definition at line 42 of file ObjectPtr.cpp.

Member Function Documentation

◆ attribute()

ObjectPtr attribute ( const std::string &  attr) const

Definition at line 368 of file ObjectPtr.cpp.

◆ call()

ObjectPtr call ( const ObjectPtr args) const

Definition at line 364 of file ObjectPtr.cpp.

◆ defineModule()

ObjectPtr defineModule ( const std::string &  mod_name,
const std::string &  code 
)
static

Definition at line 378 of file ObjectPtr.cpp.

◆ importModule()

ObjectPtr importModule ( const std::string &  mod_name)
static

Definition at line 374 of file ObjectPtr.cpp.

◆ is() [1/7]

template<>
bool is ( ) const

Definition at line 51 of file ObjectPtr.cpp.

◆ is() [2/7]

template<>
bool is ( ) const

Definition at line 61 of file ObjectPtr.cpp.

◆ is() [3/7]

template<>
bool is ( ) const

Definition at line 67 of file ObjectPtr.cpp.

◆ is() [4/7]

template<>
bool is ( ) const

Definition at line 77 of file ObjectPtr.cpp.

◆ is() [5/7]

template<>
bool is ( ) const

Definition at line 93 of file ObjectPtr.cpp.

◆ is() [6/7]

template<>
bool is ( ) const

Definition at line 102 of file ObjectPtr.cpp.

◆ is() [7/7]

template<typename T >
bool is ( ) const

◆ isVector()

template<typename T >
bool isVector

Definition at line 108 of file ObjectPtr.cpp.

◆ make() [1/8]

template<>
ObjectPtr make ( const bool &  val)
static

Definition at line 276 of file ObjectPtr.cpp.

◆ make() [2/8]

template<>
ObjectPtr make ( const double &  val)
static

Definition at line 281 of file ObjectPtr.cpp.

◆ make() [3/8]

template<>
ObjectPtr make ( const int &  val)
static

Definition at line 267 of file ObjectPtr.cpp.

◆ make() [4/8]

template<>
ObjectPtr make ( const Limits val)
static

Definition at line 295 of file ObjectPtr.cpp.

◆ make() [5/8]

template<>
ObjectPtr make ( const ParametersList plist)
static

Definition at line 300 of file ObjectPtr.cpp.

◆ make() [6/8]

template<typename T >
static ObjectPtr make ( const std::vector< T > &  vec)
static

Definition at line 52 of file ObjectPtr.h.

◆ make() [7/8]

template<typename T >
static ObjectPtr make ( const T &  )
static

◆ make() [8/8]

template<>
ObjectPtr make ( PyObject *const &  obj)
static

Definition at line 262 of file ObjectPtr.cpp.

◆ operator()()

template<typename... Args>
ObjectPtr operator() ( Args &&...  args)

Definition at line 93 of file ObjectPtr.h.

◆ tuple()

template<typename... Args>
static ObjectPtr tuple ( const std::tuple< Args... > &  c_tuple)
static

Definition at line 77 of file ObjectPtr.h.

◆ tupleFromVector() [1/2]

template<>
ObjectPtr tupleFromVector ( const std::vector< PyObject * > &  vec)

Definition at line 344 of file ObjectPtr.cpp.

◆ tupleFromVector() [2/2]

template<typename T >
ObjectPtr tupleFromVector ( const std::vector< T > &  vec)
static

Definition at line 336 of file ObjectPtr.cpp.

◆ value() [1/8]

template<>
bool value ( ) const

Definition at line 149 of file ObjectPtr.cpp.

◆ value() [2/8]

template<>
int value ( ) const

Definition at line 155 of file ObjectPtr.cpp.

◆ value() [3/8]

template<>
unsigned long value ( ) const

Definition at line 166 of file ObjectPtr.cpp.

◆ value() [4/8]

template<>
long long value ( ) const

Definition at line 178 of file ObjectPtr.cpp.

◆ value() [5/8]

template<>
double value ( ) const

Definition at line 185 of file ObjectPtr.cpp.

◆ value() [6/8]

template<>
Limits value ( ) const

Definition at line 206 of file ObjectPtr.cpp.

◆ value() [7/8]

template<>
ParametersList value ( ) const

Definition at line 216 of file ObjectPtr.cpp.

◆ value() [8/8]

template<typename T >
T value ( ) const

◆ vector()

template<typename T >
std::vector< T > vector

Definition at line 130 of file ObjectPtr.cpp.

◆ wrap()

ObjectPtr wrap ( PyObject *  obj)
static

Definition at line 45 of file ObjectPtr.cpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const ObjectPtr ptr 
)
friend

Definition at line 357 of file ObjectPtr.cpp.