forked from aldebaran/libqi-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyclock.cpp
More file actions
46 lines (36 loc) · 977 Bytes
/
pyclock.cpp
File metadata and controls
46 lines (36 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
** Copyright (C) 2020 SoftBank Robotics Europe
** See COPYING for the license
*/
#include <qipython/pyclock.hpp>
#include <qipython/common.hpp>
#include <qipython/pyguard.hpp>
#include <qi/clock.hpp>
#include <pybind11/pybind11.h>
namespace py = pybind11;
namespace qi
{
namespace py
{
namespace
{
template<typename Clock>
typename Clock::rep now()
{
return Clock::now().time_since_epoch().count();
}
} // namespace
void exportClock(::py::module& m)
{
using namespace ::py;
using namespace ::py::literals;
GILAcquire lock;
m.def("clockNow", &now<Clock>,
doc(":returns: current timestamp on qi::Clock, as a number of nanoseconds"));
m.def("steadyClockNow", &now<SteadyClock>,
doc(":returns: current timestamp on qi::SteadyClock, as a number of nanoseconds"));
m.def("systemClockNow", &now<SystemClock>,
doc(":returns: current timestamp on qi::SystemClock, as a number of nanoseconds"));
}
} // namespace py
} // namespace qi