GCC Code Coverage Report


Directory: src/
File: ClockNs_binding.cpp
Date: 2026-02-24 19:19:46
Exec Total Coverage
Lines: 13 15 86.7%
Functions: 5 6 83.3%
Branches: 3 11 27.3%

Line Branch Exec Source
1 /***************************************
2 Auteur : Thibaut Oprinsen
3 Mail : thibaut.oprinsen@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "PClockNs.h"
8
9 #include <ctime>
10 #include <nanobind/nanobind.h>
11 #include <nanobind/stl/string.h>
12 #include <nanobind/stl/chrono.h>
13
14 namespace nb = nanobind;
15
16
1/7
✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→12) not taken.
✗ Branch 2 (16→17) not taken.
✗ Branch 3 (16→18) not taken.
✗ Branch 4 (16→23) not taken.
✗ Branch 5 (25→26) not taken.
✗ Branch 6 (25→27) not taken.
4 NB_MODULE(clockNs, m) {
17
2/4
✓ Branch 0 (2→3) taken 1 times.
✗ Branch 1 (2→174) not taken.
✓ Branch 2 (3→4) taken 1 times.
✗ Branch 3 (3→172) not taken.
1 m.doc() = "Nanobind bindings for Gibis classes";
18 1 nb::class_<PClockNs>(m, "PClockNs")
19 //Constructor
20 1 .def(nb::init<>())
21
22 //Properties
23 1 .def_prop_rw("offsetTimeNs",
24 4 [](PClockNs &c) { return c.getOffsetTimeNs(); },
25 4 [](PClockNs &c, time_t value) { c.setOffsetTimeNs(value); })
26
27 //Functions
28 1 .def("getFullTimeNs", &PClockNs::getFullTimeNs,
29 "Get the full time in nanoseconds")
30
31 1 .def("getDateNs", &PClockNs::getDateNs,
32 "Get the date at nanosecond precision")
33
34 1 .def("getDateCompactNs", &PClockNs::getDateCompactNs,
35 "Get the date at nanosecond precision in compact format")
36
37 2 .def("now", &PClockNs::now,
38 "Get the full time in nanoseconds (alias for getFullTimeNs)")
39
40 1 .def("sleep", [](const PClockNs &c, time_t ellapsedTime) {
41 c.sleep(ellapsedTime);
42 },
43 "Sleep for the given elapsed time in nanoseconds");
44 1 }
45