PyPhoenixClockBackend
1.2.1
Binding for PhoenixClock library
Toggle main menu visibility
Loading...
Searching...
No Matches
clock_mock_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 CLOCKMOCK_BINDING_H
8
#define CLOCKMOCK_BINDING_H
9
10
#include "PClockMock.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_mock_binding
(nb::module_ &m) {
20
nb::module_ m_clock_mock = m.def_submodule(
"clock_mock"
,
"Clock mock utilities for testing"
);
21
22
nb::class_<PClockMock>(m_clock_mock,
"PClockMock"
)
23
// Constructor
24
.def(nb::init<>())
25
26
// Clock API methods
27
.def(
"now"
, &PClockMock::now,
28
"Get the mocked current time"
)
29
30
.def(
"sleep"
, [](
const
PClockMock &c, time_t ellapsedTime) {
31
c.sleep(ellapsedTime);
32
},
33
"Sleep for the given elapsed time (no real sleep in mock)"
)
34
35
// Mock API methods
36
.def(
"setCurrentTime"
, [](PClockMock &c, time_t currentTime) {
37
c.setCurrentTime(currentTime);
38
},
39
"Set the mocked current time"
)
40
41
.def(
"setMockPrefix"
, [](PClockMock &c,
const
std::string &prefix) {
42
c.setMockPrefix(prefix);
43
},
44
"Set the mock prefix for logging"
)
45
46
.def(
"resetIndex"
, &PClockMock::resetIndex,
47
"Reset the mock index to start from the beginning of the mock data"
)
48
49
.def(
"close"
, &PClockMock::close,
50
"Close the mock and release resources"
);
51
52
// Static methods
53
m_clock_mock.def(
"phoenix_createMockBackend"
, [](PClockMock &c,
const
std::string & prefix) ->
bool
{
54
return
phoenix_createMockBackend(c, prefix);
55
},
56
nb::arg(
"c"
), nb::arg(
"prefix"
) =
""
,
57
"Create the mock backend with the given prefix"
);
58
}
59
60
#endif
// CLOCKMOCK_BINDING_H
make_clock_mock_binding
void make_clock_mock_binding(nb::module_ &m)
Definition
clock_mock_binding.h:19
src
clock_mock_binding.h
Generated by
1.17.0