My Project
Public Member Functions | List of all members
ParaEngine::CValueTracker< T > Class Template Reference

a class for tracking the history of values. More...

#include <ValueTracker.h>

Public Member Functions

void Reset ()
 make the tracker empty
 
int GetSize ()
 Get how many items to be kept in the tracker.
 
void SetSize (int nSize)
 set how many items to be kept in the tracker
 
void Push (int time, const T &value)
 push a new item to the tracker. More...
 
void Update (int time, const T &value)
 update the current (latest) value More...
 
int GetTime (int nPos=0)
 get the time in history. More...
 
const T & GetValue (int nPos=0)
 get the value in history. More...
 
bool GetValue (T &value, int nPos)
 get the value in history. More...
 
BOOL CompareWith (const T &right)
 return true if the last value. More...
 
bool IsConstant ()
 return whether all values in the tracker are the same. More...
 

Detailed Description

template<class T>
class ParaEngine::CValueTracker< T >

a class for tracking the history of values.

It is used for network values such as player positions, etc. It keeps a history of most recent (time, value) pairs.

Member Function Documentation

§ CompareWith()

template<class T>
BOOL ParaEngine::CValueTracker< T >::CompareWith ( const T &  right)
inline

return true if the last value.

i.e. GetValue(0) is the same as the passed value if the last value is empty, it will always return false.

Parameters
rightwith which to compare
Returns

§ GetTime()

template<class T>
int ParaEngine::CValueTracker< T >::GetTime ( int  nPos = 0)
inline

get the time in history.

Parameters
nPos0 means current one, -1 means last one. 1 means first one

§ GetValue() [1/2]

template<class T>
const T& ParaEngine::CValueTracker< T >::GetValue ( int  nPos = 0)
inline

get the value in history.

Parameters
nPos0 means current one, -1 means last one. 1 means first one

§ GetValue() [2/2]

template<class T>
bool ParaEngine::CValueTracker< T >::GetValue ( T &  value,
int  nPos 
)
inline

get the value in history.

Parameters
value[out] if there is a value at the time, it will be returned in this struct.
nPos0 means current one, -1 means last one. 1 means first one
Returns
: true if a value is returned, or false if there is no value at the position.

§ IsConstant()

template<class T>
bool ParaEngine::CValueTracker< T >::IsConstant ( )
inline

return whether all values in the tracker are the same.

Note
: if any slot of the tracker is empty, this function will return false.

§ Push()

template<class T>
void ParaEngine::CValueTracker< T >::Push ( int  time,
const T &  value 
)
inline

push a new item to the tracker.

Parameters
time
value

§ Update()

template<class T>
void ParaEngine::CValueTracker< T >::Update ( int  time,
const T &  value 
)
inline

update the current (latest) value

Parameters
time
value

The documentation for this class was generated from the following file: