PyPhoenixClockBackend  1.1.0
Binding for PhoenixClock library
Loading...
Searching...
No Matches
clock_mock_binding.h File Reference
#include "PClockMock.h"
#include <ctime>
#include <nanobind/nanobind.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/chrono.h>
+ Include dependency graph for clock_mock_binding.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void make_clock_mock_binding (nb::module_ &m)
 

Function Documentation

◆ make_clock_mock_binding()

void make_clock_mock_binding ( nb::module_ & m)
inline

Definition at line 19 of file clock_mock_binding.h.

19 {
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}

Referenced by NB_MODULE().

+ Here is the caller graph for this function: