📄 warcpstimestamp.h
字号:
/** */#ifndef WAR_CPS_TIMESTAMP_H#define WAR_CPS_TIMESTAMP_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_TIME_H# include "WarTime.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarCpsTimestamp {public: // LIFECYCLE /** * Default constructor. */ WarCpsTimestamp(war_flen_t stampWhere) : mWhere(stampWhere) {} /** * Copy constructor. * * @param from The value to copy to this object. */ WarCpsTimestamp(const WarCpsTimestamp& from) { operator = (from); } // OPERATORS /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarCpsTimestamp& operator=(const WarCpsTimestamp& from) { mWhen = from.mWhen; mWhere = from.mWhere; return *this; } // OPERATIONS // CALLBACK // ACCESS // INQUIRY const WarTime& GetTime() const { return mWhen; } const war_flen_t& GetBytes() const { return mWhere; } // Get cps. Other is the first sample. // this is the last. int GetCps(const WarCpsTimestamp& other) { double seconds = (mWhen.mTime - other.mWhen.mTime) / 1000.0; double bytes = mWhere - other.mWhere; if ((0 == bytes) || (0 == seconds)) return 0; return (int)(bytes / seconds); } // Other is the first sample. // this is the last. WarTime GetNextCpsTime(const WarCpsTimestamp& other, int cpsLimit) { double cps = GetCps(other); double cps_limit = cpsLimit; double seconds = cps / cps_limit; return WarTime(mWhen.mTime + (war_time_t)((seconds * 1000.0))); } protected:private: WarTime mWhen; war_flen_t mWhere;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_CPS_TIMESTAMP_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -