10 #ifndef SRC_INCLUDE_CLOCK_H_    11 #define SRC_INCLUDE_CLOCK_H_   103   Clock(
const double time, 
const double dt)
   106       throw std::range_error(
"No negative time increment allowed");
   123       throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
   136       throw std::range_error(
"No negative time increment allowed");
   160       throw std::range_error(
"Negative interval makes no sense for clock");
   186       return convert(current / int_interval * int_interval);
   188     return convert((current / int_interval + 1) * int_interval);
   204           (current / int_interval + 1) * int_interval - current;
   216   void reset(
const double reset_time) {
   218       logger<LogArea::Clock>().debug(
"Resetting clock from", 
current_time(),
   219                                      " fm/c to ", reset_time, 
" fm/c");
   233     if (
counter_ >= std::numeric_limits<Representation>::max() - 1) {
   234       throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
   247   template <
typename T>
   248   typename std::enable_if<std::is_floating_point<T>::value, 
Clock&>::type
   250     if (big_timestep < 0.) {
   251       throw std::range_error(
"The clock cannot be turned back.");
   265     if (
counter_ >= std::numeric_limits<Representation>::max() -
   266                         advance_several_timesteps) {
   267       throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
   269     counter_ += advance_several_timesteps;
   320 #endif  // SRC_INCLUDE_CLOCK_H_ void reset(const double reset_time)
Resets the time to a pre-defined value reset_time. 
bool operator<(double time) const
Compares the time of the clock against a fixed time. 
Clock & operator+=(Representation advance_several_timesteps)
advances the clock by an arbitrary number of ticks. 
double timestep_duration() const
Representation counter_
Clock tick. 
Representation timestep_duration_
The time step size  in $10^{-3}$ fm. 
static double convert(Representation x)
Convert an internal int value x into the double representation. 
bool operator<(const Clock &rhs) const
Compares the times between two clocks. 
Clock(const double time, const double dt)
Initialize with base time and time step size. 
static Representation convert(double x)
Convert a double x into the internal int representation. 
Representation reset_time_
The time of last reset (when counter_ was set to 0). 
bool operator>(double time) const
Compares the time of the clock against a fixed time. 
std::enable_if< std::is_floating_point< T >::value, Clock & >::type operator+=(T big_timestep)
Advances the clock by an arbitrary timestep (multiple of 0.000001 fm/c). 
static constexpr double resolution
Defines the resolution of the clock (i.e. 
Clock & operator++()
Advances the clock by one tick ( ). 
static constexpr double to_double
A multiplier transfering the internal integer to the real time. 
std::int64_t Representation
The type used for counting ticks/time. 
Clock tracks the time in the simulation. 
double next_multiple(const double interval) const
Returns the next multiple of a given interval. 
Clock()=default
default initializer: Timestep size is set to 0! 
#define unlikely(x)
Tell the branch predictor that this expression is likely false. 
void end_tick_on_multiple(const double interval)
Set the time step such that it ends on the next multiple of the interval. 
double current_time() const
bool multiple_is_in_next_tick(const double interval) const
Checks if a multiple of a given interval is reached within the next tick. 
void set_timestep_duration(const double dt)
Sets the time step size (and resets the counter). 
static constexpr double from_double
A multiplier transfering the real time to the internal integer.