| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef CLOCKBACKEND_BINDING_H | ||
| 8 | #define CLOCKBACKEND_BINDING_H | ||
| 9 | |||
| 10 | #include "PClockBackend.h" | ||
| 11 | #include <time.h> | ||
| 12 | #include <nanobind/nanobind.h> | ||
| 13 | #include <nanobind/stl/string.h> | ||
| 14 | #include <nanobind/stl/chrono.h> | ||
| 15 | |||
| 16 | namespace nb = nanobind; | ||
| 17 | |||
| 18 | 3 | inline void make_clock_backend_binding(nb::module_ &m) { | |
| 19 | nb::module_ m_clock_backend = m.def_submodule("clock_backend", "Clock backend utilities"); | ||
| 20 | |||
| 21 | 3 | nb::class_<PClockBackend>(m_clock_backend, "PClockBackend") | |
| 22 | |||
| 23 | // Constructor | ||
| 24 | 6 | .def(nb::init<>()) | |
| 25 | |||
| 26 | // Static methods only since PClockBackend is a struct with static methods | ||
| 27 | 6 | .def_static("now", &PClockBackend::now, | |
| 28 | "Get current time with PClockBackend") | ||
| 29 | |||
| 30 | 3 | .def_static("sleep", [](time_t ellapsedTime) { | |
| 31 | ✗ | PClockBackend::sleep(ellapsedTime); | |
| 32 | ✗ | }, | |
| 33 | 3 | nb::arg("ellapsedTime"), | |
| 34 | "Sleep for the given elapsed time" | ||
| 35 | ); | ||
| 36 | 3 | } | |
| 37 | |||
| 38 | |||
| 39 | #endif // CLOCKBACKEND_BINDING_H | ||
| 40 |