AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
timer.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef AJA_TIMER_H
9 #define AJA_TIMER_H
10 
11 #include <ostream>
12 #include "ajabase/common/public.h"
13 
15 {
19 };
20 
26 {
27  public:
29  virtual ~AJATimer() {}
30 
34  void Start (void);
35 
39  void Stop (void);
40 
44  void Reset (void);
45 
54  uint32_t ElapsedTime (void) const;
55 
64  inline double ETSecs (void) const {return double(ElapsedTime()) * PrecisionSecs(Precision());}
65 
74  inline bool Timeout (const uint32_t interval) const {return (ElapsedTime() >= interval);}
75 
81  inline bool IsRunning (void) const {return mRun;}
82 
88  inline AJATimerPrecision Precision (void) const {return mPrecision;}
89 
90 
97  std::ostream & Print (std::ostream & oss) const;
98 
99 
107  static std::string PrecisionName (const AJATimerPrecision precision, const bool longName = true);
108 
115  static double PrecisionSecs (const AJATimerPrecision precision);
116 
117  private:
118  uint64_t mStartTime;
119  uint64_t mStopTime;
120  bool mRun;
121  AJATimerPrecision mPrecision;
122 
123  #if defined(DOCTEST_LIBRARY_INCLUDED)
124  public: inline void SetStopTime (const uint64_t inIncr) {mStartTime = 0; mStopTime = inIncr;};
125  #endif
126 }; // AJATimer
127 
128 AJA_EXPORT inline std::ostream & operator << (std::ostream & oss, const AJATimer & inObj) {return inObj.Print(oss);}
129 
130 #endif // AJA_TIMER_H
AJATimer::IsRunning
bool IsRunning(void) const
Definition: timer.h:81
AJA_EXPORT
#define AJA_EXPORT
Definition: export.h:34
AJATimerPrecision
AJATimerPrecision
Definition: timer.h:14
AJATimer::Timeout
bool Timeout(const uint32_t interval) const
Definition: timer.h:74
public.h
Master header for the ajabase library.
AJATimer::Print
std::ostream & Print(std::ostream &oss) const
Definition: timer.cpp:75
AJATimer::~AJATimer
virtual ~AJATimer()
Definition: timer.h:29
AJATimer
Definition: timer.h:25
AJATimer::ETSecs
double ETSecs(void) const
Definition: timer.h:64
AJATimerPrecisionMicroseconds
@ AJATimerPrecisionMicroseconds
Definition: timer.h:17
AJATimerPrecisionNanoseconds
@ AJATimerPrecisionNanoseconds
Definition: timer.h:18
operator<<
AJA_EXPORT std::ostream & operator<<(std::ostream &oss, const AJATimer &inObj)
Definition: timer.h:128
AJATimer::Precision
AJATimerPrecision Precision(void) const
Definition: timer.h:88
AJATimerPrecisionMilliseconds
@ AJATimerPrecisionMilliseconds
Definition: timer.h:16