warcpstimestamp.h
来自「ftpserver very good sample」· C头文件 代码 · 共 136 行
H
136 行
/** */#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 + =
减小字号Ctrl + -
显示快捷键?