Skip to content

Commit eda59a2

Browse files
committed
fix cpp version
1 parent e5e7cfd commit eda59a2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

examples/cpp-dummy/micro_cpp_dummy.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ py::list MicroSimulation::get_state() const
5959
return state_python;
6060
}
6161

62+
// This function needs to return the global id received during construction
63+
int MicroSimulation::get_global_id() const
64+
{
65+
return _sim_id;
66+
}
67+
6268
PYBIND11_MODULE(micro_dummy, m) {
6369
// optional docstring
6470
m.doc() = "pybind11 micro dummy plugin";
@@ -68,6 +74,7 @@ PYBIND11_MODULE(micro_dummy, m) {
6874
.def("solve", &MicroSimulation::solve)
6975
.def("get_state", &MicroSimulation::get_state)
7076
.def("set_state", &MicroSimulation::set_state)
77+
.def("_sim_id", &MicroSimulation::get_global_id)
7178
// Pickling support does not work currently, as there is no way to pass the simulation ID to the new instance ms.
7279
.def(py::pickle( // https://pybind11.readthedocs.io/en/latest/advanced/classes.html#pickling-support
7380
[](const MicroSimulation &ms) { // __getstate__

examples/cpp-dummy/micro_cpp_dummy.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class MicroSimulation
2020

2121
void set_state(py::list state);
2222
py::list get_state() const;
23+
int get_global_id() const;
2324

2425
private:
2526
int _sim_id;

0 commit comments

Comments
 (0)