LT_Object.h
См. документацию.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00023
00024 #ifndef Object_LT_H_
00025 #define Object_LT_H_
00026
00027 #include <list>
00028 #include "UniSetTypes.h"
00029 #include "MessageType.h"
00030 #include "PassiveTimer.h"
00031 #include "Exceptions.h"
00032
00033
00034 class UniSetObject;
00035
00096 class LT_Object
00097 {
00098 public:
00099 LT_Object();
00100 virtual ~LT_Object();
00101
00102
00111 timeout_t askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, clock_t ticks=-1,
00112 UniSetTypes::Message::Priority p=UniSetTypes::Message::High );
00113
00114
00121 timeout_t checkTimers( UniSetObject* obj );
00122
00124
00125
00126 protected:
00127
00129 struct TimerInfo
00130 {
00131 TimerInfo():id(0), curTimeMS(0), priority(UniSetTypes::Message::High){};
00132 TimerInfo(UniSetTypes::TimerId id, timeout_t timeMS, short cnt, UniSetTypes::Message::Priority p):
00133 id(id),
00134 curTimeMS(timeMS),
00135 priority(p),
00136 curTick(cnt-1)
00137 {
00138 tmr.setTiming(timeMS);
00139 };
00140
00141 inline void reset()
00142 {
00143 curTimeMS = tmr.getInterval();
00144 tmr.reset();
00145 }
00146
00147 UniSetTypes::TimerId id;
00148 timeout_t curTimeMS;
00149 UniSetTypes::Message::Priority priority;
00155 clock_t curTick;
00156
00157
00158 bool operator < ( const TimerInfo& ti ) const
00159 {
00160 return curTimeMS > ti.curTimeMS;
00161 }
00162
00163 PassiveTimer tmr;
00164 };
00165
00166 class Timer_eq: public std::unary_function<TimerInfo, bool>
00167 {
00168 public:
00169 Timer_eq(UniSetTypes::TimerId t):tid(t){}
00170
00171 inline bool operator()(const TimerInfo& ti) const
00172 {
00173 return ( ti.id == tid );
00174 }
00175
00176 protected:
00177 UniSetTypes::TimerId tid;
00178 };
00179
00180 typedef std::list<TimerInfo> TimersList;
00181
00182 private:
00183 TimersList tlst;
00185 UniSetTypes::uniset_mutex lstMutex;
00186 timeout_t sleepTime;
00187 PassiveTimer tmLast;
00188 };
00189
00190 #endif