PyPhoenixClockBackend
1.2.1
Binding for PhoenixClock library
Toggle main menu visibility
Loading...
Searching...
No Matches
clock_ns_binding.h
Go to the documentation of this file.
1
/***************************************
2
Auteur : Thibaut Oprinsen
3
Mail : thibaut.oprinsen@lapp.in2p3.fr
4
Licence : LGPL-3.0-only
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
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
nb::class_<PClockNs>(m_clock_ns,
"PClockNs"
)
23
//Constructor
24
.def(nb::init<>())
25
26
//Properties
27
.def_prop_rw(
"offsetTimeNs"
,
28
[](PClockNs &c) {
return
c.getOffsetTimeNs(); },
29
[](PClockNs &c, time_t value) { c.setOffsetTimeNs(value); })
30
31
//Functions
32
.def(
"getFullTimeNs"
, &PClockNs::getFullTimeNs,
33
"Get the full time in nanoseconds"
)
34
35
.def(
"getDateNs"
, &PClockNs::getDateNs,
36
"Get the date at nanosecond precision"
)
37
38
.def(
"getDateCompactNs"
, &PClockNs::getDateCompactNs,
39
"Get the date at nanosecond precision in compact format"
)
40
41
.def(
"now"
, &PClockNs::now,
42
"Get the full time in nanoseconds (alias for getFullTimeNs)"
)
43
44
.def(
"sleep"
, [](
const
PClockNs &c, time_t ellapsedTime) {
45
c.sleep(ellapsedTime);
46
},
47
"Sleep for the given elapsed time in nanoseconds"
48
);
49
}
50
51
52
#endif
// CLOCKNS_BINDING_H
make_clock_ns_binding
void make_clock_ns_binding(nb::module_ &m)
Definition
clock_ns_binding.h:19
src
clock_ns_binding.h
Generated by
1.17.0