PyPhoenixClockBackend
1.2.1
Binding for PhoenixClock library
Toggle main menu visibility
Loading...
Searching...
No Matches
clock_mock_file_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 CLOCKMOCKFILE_BINDING_H
8
#define CLOCKMOCKFILE_BINDING_H
9
10
#include "PClockMockFile.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_file_binding
(nb::module_ &m) {
20
nb::module_ m_clock_mock_file = m.def_submodule(
"clock_mock_file"
,
"Clock mock file utilities for testing"
);
21
22
nb::class_<PClockMockFile>(m_clock_mock_file,
"PClockMockFile"
)
23
24
// Constructor
25
.def(nb::init<>())
26
27
// Clock API methods
28
.def(
"now"
, &PClockMockFile::now,
29
"Get the mocked current time"
)
30
31
.def(
"sleep"
, [](
const
PClockMockFile &c, time_t ellapsedTime) {
32
c.sleep(ellapsedTime);
33
},
34
"Sleep for the given elapsed time (no real sleep in mock)"
)
35
36
// Mock API methods
37
.def(
"setCurrentTime"
, [](PClockMockFile &c, time_t currentTime) {
38
c.setCurrentTime(currentTime);
39
},
40
"Set the mocked current time"
)
41
42
.def(
"setMockPrefix"
, [](PClockMockFile &c,
const
std::string &prefix) {
43
c.setMockPrefix(prefix);
44
},
45
"Set the mock prefix for logging"
)
46
47
.def(
"close"
, &PClockMockFile::close,
48
"Close the mock file and release resources"
);
49
50
// Static methods
51
m_clock_mock_file.def(
"phoenix_createMockBackend"
, [](PClockMockFile &c,
const
std::string & prefix) ->
bool
{
52
return
phoenix_createMockBackend(c, prefix);
53
},
54
"Create the mock backend with the given prefix"
);
55
56
m_clock_mock_file.def(
"phoenix_createClockMock"
, [](
const
std::string & prefix,
size_t
nbTime, time_t firstTime, time_t timeIncrement) ->
bool
{
57
return
phoenix_createClockMock(prefix, nbTime, firstTime, timeIncrement);
58
},
59
nb::arg(
"prefix"
), nb::arg(
"nbTime"
), nb::arg(
"firstTime"
) = 0l, nb::arg(
"timeIncrement"
) = 1l,
60
"Create a clock mock with the given prefix, number of time points, first time and time increment"
);
61
62
m_clock_mock_file.def(
"phoenix_fillClockMock"
, [](PClockMockFile &mock,
size_t
nbTime, time_t firstTime, time_t timeIncrement) {
63
phoenix_fillClockMock<PClockMockFile>(mock, nbTime, firstTime, timeIncrement);
64
},
65
"Fill the given clock mock with time values"
);
66
}
67
68
69
#endif
// CLOCKMOCKFILE_BINDING_H
70
71
make_clock_mock_file_binding
void make_clock_mock_file_binding(nb::module_ &m)
Definition
clock_mock_file_binding.h:19
src
clock_mock_file_binding.h
Generated by
1.17.0