PyPhoenixClockBackend
1.2.1
Binding for PhoenixClock library
Toggle main menu visibility
Loading...
Searching...
No Matches
timer_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 TIMER_BINDING_H
8
#define TIMER_BINDING_H
9
10
#include "PTimer.h"
11
#include <ctime>
12
#include <nanobind/nanobind.h>
13
#include <nanobind/stl/string.h>
14
#include <nanobind/stl/chrono.h>
15
16
namespace
nb = nanobind;
17
18
inline
void
make_timer_binding
(nb::module_ &m) {
19
nb::module_ m_timer = m.def_submodule(
"timer"
,
"Timer utilities"
);
20
21
nb::class_<PTimer>(m_timer,
"PTimer"
)
22
23
// Attribute
24
.def_prop_rw(
"ellapsedTime"
,
25
[](PTimer &timer) {
return
timer.getEllapsedTime(); },
26
[](PTimer &timer, time_t value) { timer.setEllapsedTime(value); },
27
"Get or set the ellapsed time between timer triggers"
)
28
29
// Constructors
30
.def(nb::init<time_t>(),
31
nb::arg(
"ellapsedTime"
) = 1lu,
32
"Constructor with custom ellapsedTime"
)
33
34
.def(nb::init<const PTimer &>(),
35
nb::arg(
"other"
),
36
"Copy constructor"
)
37
38
// Timer configuration methods
39
.def(
"setStartTime"
, [](PTimer &timer, time_t startTime) {
40
timer.setStartTime(startTime);
41
},
42
"Set the start time for the timer"
)
43
44
// Timer checking methods
45
.def(
"isTime"
, [](PTimer &timer, time_t currentTime) ->
bool
{
46
return
timer.isTime(currentTime);
47
},
48
"Check if the elapsed time has passed since start time"
)
49
50
.def(
"isTimeWithEllapsed"
, [](PTimer &timer, time_t ellapsedTime, time_t currentTime) ->
bool
{
51
return
timer.isTime(ellapsedTime, currentTime);
52
},
53
"Check if time has elapsed and return (bool, elapsed_time_ns) tuple"
54
);
55
}
56
57
#endif
// TIMER_BINDING_H
make_timer_binding
void make_timer_binding(nb::module_ &m)
Definition
timer_binding.h:18
src
timer_binding.h
Generated by
1.17.0