| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef CLOCKNS_BINDING_H | ||
| 8 | #define CLOCKNS_BINDING_H | ||
| 9 | |||
| 10 | #include "PClockNs.h" | ||
| 11 | |||
| 12 | #include <ctime> | ||
| 13 | #include <nanobind/nanobind.h> | ||
| 14 | #include <nanobind/stl/string.h> | ||
| 15 | #include <nanobind/stl/chrono.h> | ||
| 16 | |||
| 17 | namespace nb = nanobind; | ||
| 18 | |||
| 19 | 3 | inline void make_clock_ns_binding(nb::module_ &m) { | |
| 20 | nb::module_ m_clock_ns = m.def_submodule("clock_ns", "Clock utilities with nanosecond precision"); | ||
| 21 | |||
| 22 | 3 | nb::class_<PClockNs>(m_clock_ns, "PClockNs") | |
| 23 | //Constructor | ||
| 24 | 3 | .def(nb::init<>()) | |
| 25 | |||
| 26 | //Properties | ||
| 27 | 3 | .def_prop_rw("offsetTimeNs", | |
| 28 | 3 | [](PClockNs &c) { return c.getOffsetTimeNs(); }, | |
| 29 | 3 | [](PClockNs &c, time_t value) { c.setOffsetTimeNs(value); }) | |
| 30 | |||
| 31 | //Functions | ||
| 32 | 3 | .def("getFullTimeNs", &PClockNs::getFullTimeNs, | |
| 33 | "Get the full time in nanoseconds") | ||
| 34 | |||
| 35 | 3 | .def("getDateNs", &PClockNs::getDateNs, | |
| 36 | "Get the date at nanosecond precision") | ||
| 37 | |||
| 38 | 3 | .def("getDateCompactNs", &PClockNs::getDateCompactNs, | |
| 39 | "Get the date at nanosecond precision in compact format") | ||
| 40 | |||
| 41 | 6 | .def("now", &PClockNs::now, | |
| 42 | "Get the full time in nanoseconds (alias for getFullTimeNs)") | ||
| 43 | |||
| 44 | 3 | .def("sleep", [](const PClockNs &c, time_t ellapsedTime) { | |
| 45 | ✗ | c.sleep(ellapsedTime); | |
| 46 | ✗ | }, | |
| 47 | "Sleep for the given elapsed time in nanoseconds" | ||
| 48 | ); | ||
| 49 | 3 | } | |
| 50 | |||
| 51 | |||
| 52 | #endif // CLOCKNS_BINDING_H | ||
| 53 |