From: Martin Quinson Date: Thu, 3 Jan 2019 10:34:53 +0000 (+0100) Subject: py: Try to add properties to the Host class X-Git-Tag: v3_22~713 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2e12d9e96a253599c90799b5537c7a0f1a07f6e0?ds=inline py: Try to add properties to the Host class --- diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index e77d5d98cc..38b0287738 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -105,8 +105,15 @@ PYBIND11_MODULE(simgrid, m) ; /* Class Host */ - py::class_>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host `").def( - "by_name", &Host::by_name, "Retrieve a host from its name, or die"); + auto get_name = [](const Host* self) { + return self->get_name(); + }; + py::class_>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host `") + .def("by_name", &Host::by_name, "Retrieve a host from its name, or die") + .def("get_name", &Host::get_name, "Retrieve the name of this host") + .def_property_readonly("name", get_name, "Retrieve the name of this host") + .def_property_readonly("speed", &Host::get_speed, + "Get the peak computing speed in flops/s at the current pstate, taking the external load into account, see :cpp:func:`simgrid::s4u::Host::get_speed()`"); /* Class Mailbox */ py::class_>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox `")