PyPhoenixClockBackend  1.0.1
Binding for PhoenixClock library
Loading...
Searching...
No Matches
ClockBackend_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 "PClockBackend.h"
8#include <time.h>
9#include <nanobind/nanobind.h>
10#include <nanobind/stl/string.h>
11#include <nanobind/stl/chrono.h>
12
13namespace nb = nanobind;
14
15NB_MODULE(clockSecond, m) {
16 m.doc() = "Nanobind bindings for clock backend class";
17 nb::class_<PClockBackend>(m, "PClockBackend")
18
19 // Constructor
20 .def(nb::init<>())
21
22 // Static methods only since PClockBackend is a struct with static methods
23 .def_static("now", &PClockBackend::now,
24 "Get current time with PClockBackend")
25
26 .def_static("sleep", [](time_t ellapsedTime) {
27 PClockBackend::sleep(ellapsedTime);
28 },
29 nb::arg("ellapsedTime"),
30 "Sleep for the given elapsed time");
31}
NB_MODULE(clockSecond, m)