PyPhoenixClockBackend  1.0.1
Binding for PhoenixClock library
Loading...
Searching...
No Matches
ClockNs_binding.cpp
Go to the documentation of this file.
1/***************************************
2 Auteur : Thibaut Oprinsen
3 Mail : thibaut.oprinsen@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#include "PClockNs.h"
8
9#include <ctime>
10#include <nanobind/nanobind.h>
11#include <nanobind/stl/string.h>
12#include <nanobind/stl/chrono.h>
13
14namespace nb = nanobind;
15
16NB_MODULE(clockNs, m) {
17 m.doc() = "Nanobind bindings for Gibis classes";
18 nb::class_<PClockNs>(m, "PClockNs")
19 //Constructor
20 .def(nb::init<>())
21
22 //Properties
23 .def_prop_rw("offsetTimeNs",
24 [](PClockNs &c) { return c.getOffsetTimeNs(); },
25 [](PClockNs &c, time_t value) { c.setOffsetTimeNs(value); })
26
27 //Functions
28 .def("getFullTimeNs", &PClockNs::getFullTimeNs,
29 "Get the full time in nanoseconds")
30
31 .def("getDateNs", &PClockNs::getDateNs,
32 "Get the date at nanosecond precision")
33
34 .def("getDateCompactNs", &PClockNs::getDateCompactNs,
35 "Get the date at nanosecond precision in compact format")
36
37 .def("now", &PClockNs::now,
38 "Get the full time in nanoseconds (alias for getFullTimeNs)")
39
40 .def("sleep", [](const PClockNs &c, time_t ellapsedTime) {
41 c.sleep(ellapsedTime);
42 },
43 "Sleep for the given elapsed time in nanoseconds");
44}
NB_MODULE(clockNs, m)