Skip to content

Commit

Permalink
Allow clock type to change using a macro (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston authored Dec 8, 2020
1 parent 8b66438 commit 698174e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,25 @@

namespace NUClear {

#ifndef NUCLEAR_CLOCK_TYPE
# define NUCLEAR_CLOCK_TYPE std::chrono::steady_clock
#endif // NUCLEAR_CLOCK_TYPE

/// @brief The base clock that is used when defining the NUClear clock
using base_clock = NUCLEAR_CLOCK_TYPE;

#ifndef NUCLEAR_CUSTOM_CLOCK

/// @brief The clock that is used throughout the entire nuclear system
using clock = std::chrono::steady_clock;
using clock = base_clock;

#else

struct clock {
using rep = std::chrono::steady_clock::rep;
using period = std::chrono::steady_clock::period;
using duration = std::chrono::steady_clock::duration;
using time_point = std::chrono::steady_clock::time_point;
using rep = base_clock::rep;
using period = base_clock::period;
using duration = base_clock::duration;
using time_point = base_clock::time_point;
static constexpr bool is_steady = false;

static time_point now();
Expand Down

0 comments on commit 698174e

Please sign in to comment.