8 #ifndef META_OCEAN_MATH_RATE_CALCUALTOR_H
9 #define META_OCEAN_MATH_RATE_CALCUALTOR_H
69 inline void setWindow(
const double window);
75 inline double window()
const;
99 lastRequestTimestamp_(false)
106 ocean_assert(
window > 0.0);
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a calculate for rates like frame rates.
Definition: RateCalculator.h:25
double window() const
Returns the window of this rate calculator.
Definition: RateCalculator.h:113
RateCalculator(const double window=1.0)
Creates a new rate calculator object.
Definition: RateCalculator.h:97
void setWindow(const double window)
Updates the window of this rate calculator.
Definition: RateCalculator.h:104
double window_
The size of the sliding window, in seconds, with range (0, infinity).
Definition: RateCalculator.h:85
std::map< Timestamp, double > TimestampMap
Definition of an ordered map mapping timestamps to quantities.
Definition: RateCalculator.h:31
void clear()
Clears the rate calculator e.g., to start with a completely new measurement.
Definition: RateCalculator.h:120
bool rateEveryNSeconds(const Timestamp &rateTimestamp, double &rate, const double interval=1.0, const Timestamp &requestTimestamp=Timestamp(false))
Returns the current rate only every n-th second.
Lock lock_
The lock of this object.
Definition: RateCalculator.h:94
void addOccurance(const Timestamp ×tamp, const double quantity=1.0)
Adds another occurrence (e.g., a new frame has been processed).
double rate(const Timestamp ×tamp) const
Returns the current rate.
TimestampMap timestampMap_
The map mapping timestamps to quantities.
Definition: RateCalculator.h:88
Timestamp lastRequestTimestamp_
The timestamp at which the rate has been sucessfully requested the last time when calling rateEveryNS...
Definition: RateCalculator.h:91
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class implements a timestamp.
Definition: Timestamp.h:36
Timestamp & toInvalid()
Sets the timestamp to invalid.
Definition: Timestamp.h:276
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15