16 #include <pybind11/pybind11.h>
17 #include <pybind11/stl.h>
26 namespace py = pybind11;
28 template<
class TContainerType >
38 py::class_<TContainerType, typename TContainerType::Pointer >(
m,ContainerName.c_str())
40 .def(
"__len__", [](TContainerType&
self){
return self.size();} )
41 .def(
"__setitem__", [](TContainerType&
self,
unsigned int i,
typename TContainerType::value_type& value){
self[
i] = value;} )
42 .def(
"__getitem__", [](TContainerType&
self,
unsigned int i){
return self(
i);} )
43 .def(
"__iter__", [](TContainerType&
self){
return py::make_iterator(
self.begin(),
self.
end());}, py::keep_alive<0,1>())
44 .def(
"append", [](TContainerType&
self,
typename TContainerType::value_type& value){
self.push_back(value);} )
49 template<
class TContainerType >
59 py::class_<TContainerType, typename TContainerType::Pointer >(
m,ContainerName.c_str())
61 .def(
"__len__", [](TContainerType&
self){
return self.size();} )
62 .def(
"__contains__", [](TContainerType&
self,
const typename TContainerType::value_type& value){
return (
self.find(value.Id()) !=
self.end());} )
63 .def(
"__contains__", [](TContainerType&
self,
unsigned int i){
return (
self.find(
i) !=
self.
end());} )
64 .def(
"__setitem__", [](TContainerType&
self,
unsigned int i,
typename TContainerType::value_type& value){
self[
i] = value;} )
65 .def(
"__getitem__", [](TContainerType&
self,
unsigned int i){
return self(
i);} )
66 .def(
"__iter__", [](TContainerType&
self){
return py::make_iterator(
self.begin(),
self.
end());}, py::keep_alive<0,1>())
67 .def(
"clear", [](TContainerType&
self){
self.clear();} )
72 template<
class TContainerType >
82 py::class_<TContainerType, typename TContainerType::Pointer >(
m,ContainerName.c_str())
84 .def(
"__len__", [](TContainerType&
self){
return self.size();} )
85 .def(
"__setitem__", [](TContainerType&
self,
unsigned int i,
typename TContainerType::value_type& value){
self[
i] = value;} )
86 .def(
"__getitem__", [](TContainerType&
self,
unsigned int i){
return self(
i);} )
87 .def(
"__iter__", [](TContainerType&
self){
return py::make_iterator(
self.begin(),
self.
end());}, py::keep_alive<0,1>())
88 .def(
"append", [](TContainerType&
self,
typename TContainerType::value_type::Pointer pValue) {
self.push_back(pValue); })
93 template<
class TContainerType >
103 py::class_<TContainerType, typename TContainerType::Pointer >(
m,ContainerName.c_str())
105 .def(
"__len__", [](TContainerType&
self){
return self.size();} )
106 .def(
"__contains__", [](TContainerType&
self,
const typename TContainerType::value_type& value){
return (
self.find(value.Id()) !=
self.end());} )
107 .def(
"__contains__", [](TContainerType&
self,
unsigned int i){
return (
self.find(
i) !=
self.
end());} )
108 .def(
"__setitem__", [](TContainerType&
self,
typename TContainerType::value_type& value){
self[value.Id()] = value;} )
109 .def(
"__setitem__", [](TContainerType&
self,
typename TContainerType::pointer& pvalue){
self(pvalue->Id()) = pvalue;} )
110 .def(
"__getitem__", [](TContainerType&
self,
unsigned int i){
return self(
i);} )
111 .def(
"__iter__", [](TContainerType&
self){
return py::make_iterator(
self.ptr_begin(),
self.ptr_end());}, py::keep_alive<0,1>())
112 .def(
"append", [](TContainerType&
self,
typename TContainerType::pointer value){
self.push_back(value);} )
113 .def(
"clear", [](TContainerType&
self){
self.clear();} )
Definition: containers_interface.h:30
virtual ~ContainerInterface()
Definition: containers_interface.h:34
void CreateInterface(pybind11::module &m, std::string ContainerName)
Definition: containers_interface.h:36
ContainerInterface()
Definition: containers_interface.h:33
Definition: containers_interface.h:51
virtual ~MapInterface()
Definition: containers_interface.h:55
MapInterface()
Definition: containers_interface.h:54
void CreateInterface(pybind11::module &m, std::string ContainerName)
Definition: containers_interface.h:57
Definition: containers_interface.h:74
virtual ~PointerVectorPythonInterface()
Definition: containers_interface.h:78
PointerVectorPythonInterface()
Definition: containers_interface.h:77
void CreateInterface(pybind11::module &m, std::string ContainerName)
Definition: containers_interface.h:80
Definition: containers_interface.h:95
virtual ~PointerVectorSetPythonInterface()
Definition: containers_interface.h:99
PointerVectorSetPythonInterface()
Definition: containers_interface.h:98
void CreateInterface(pybind11::module &m, std::string ContainerName)
Definition: containers_interface.h:101
end
Definition: DEM_benchmarks.py:180
static void module(const array_1d< double, 3 > &Vector, double &distance)
Definition: GeometryFunctions.h:127
Definition: add_distributed_sparse_matrices_to_python.cpp:28
int m
Definition: run_marine_rain_substepping.py:8
integer i
Definition: TensorModule.f:17