6 #ifndef DISMEC_SRC_UTILS_BINDING_H
7 #define DISMEC_SRC_UTILS_BINDING_H
9 #include "pybind11/pybind11.h"
10 #include "pybind11/eigen.h"
11 #include "pybind11/stl.h"
12 #include "pybind11/stl/filesystem.h"
35 PyWrapper(U&& source, std::enable_if_t<std::is_convertible_v<U&, T&>>* a =
nullptr) :
36 m_Data(std::make_shared<U>(std::forward<U>(source))) {
52 throw std::runtime_error(
"Trying to access empty object");
55 [[nodiscard]]
const T&
access()
const {
59 throw std::runtime_error(
"Trying to access empty object");
62 [[nodiscard]]
const std::shared_ptr<T>&
ptr()
const {
66 [[nodiscard]] std::shared_ptr<T>&
ptr() {
74 template<class T, class = typename std::enable_if<!std::is_lvalue_reference<T>::value>::type>
76 return std::make_shared<T>(source);
79 namespace py = pybind11;
81 using PyDataSet = std::shared_ptr<dismec::DatasetBase>;
std::shared_ptr< T > wrap_shared(T &&source)
std::shared_ptr< dismec::DatasetBase > PyDataSet
std::shared_ptr< dismec::WeightingScheme > PyWeighting
Utility class used to wrap all objects we provide to python.
const std::shared_ptr< T > & ptr() const
std::shared_ptr< T > & ptr()
std::shared_ptr< T > m_Data
const T * operator->() const
PyWrapper(U &&source, std::enable_if_t< std::is_convertible_v< U &, T & >> *a=nullptr)
PyWrapper(std::shared_ptr< T > d)