-
Notifications
You must be signed in to change notification settings - Fork 1
/
frame_timer.h
135 lines (108 loc) · 2.07 KB
/
frame_timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* frame_timer.h
*
* Created on: 2011-11-22
* Author: jimm
*/
#ifndef FRAME_TIMER_H_
#define FRAME_TIMER_H_
#include "common/common_object.h"
#include "common/common_complextype.h"
#include "frame_namespace.h"
#include "frame_typedef.h"
#include "frame_errordef.h"
#include "lightframe_impl.h"
FRAME_NAMESPACE_BEGIN
typedef struct tagFrameTimer : public Timer
{
uint32_t nTimerSeq;
ITimerEvent* pEventHandle; //Timer接口指针
TimerProc pTimerProc; //Timer处理函数
} FrameTimer;
class CFrameTimer : public CObject
{
public:
CFrameTimer()
{
}
virtual ~CFrameTimer()
{
}
public:
//初始化定时器对象
virtual int32_t Initialize()
{
memset(&m_stTimer, 0, sizeof(m_stTimer));
return S_OK;
}
//恢复定时器对象
virtual int32_t Resume()
{
return S_OK;
}
//注销定时器对象
virtual int32_t Uninitialize()
{
memset(&m_stTimer, 0, sizeof(m_stTimer));
return S_OK;
}
public:
//设置定时器信息
void SetTimer(const FrameTimer& stTimer)
{
memcpy(&m_stTimer, &stTimer, sizeof(m_stTimer));
}
//获取定时器信息
void GetTimer(FrameTimer& stTimer)
{
memcpy(&stTimer, &m_stTimer, sizeof(m_stTimer));
}
//获取定时器类型
TimerType GetTimerType()
{
return m_stTimer.timerType;
}
//获取定时器标识
int32_t GetTimerID()
{
return m_stTimer.nTimerID;
}
//获取定时器数据
void *GetTimerData()
{
return m_stTimer.pData;
}
//获取定时器结束时间
int64_t GetEndTime()
{
return m_stTimer.nEndTime;
}
uint32_t GetTimerSeq()
{
return m_stTimer.nTimerSeq;
}
//定时器是否循环触发
bool IsLoop()
{
return m_stTimer.bLoop;
}
//获取已触发次数
uint32_t GetFiredCount()
{
return m_stTimer.nFiredCount;
}
//获取触发回调
TimerProc GetEventProc()
{
return m_stTimer.pTimerProc;
}
ITimerEvent* GetEventHandler()
{
return m_stTimer.pEventHandle;
}
protected:
FrameTimer m_stTimer;
};
FRAME_NAMESPACE_END
CCOMPLEXTYPE_SPECIFICALLY(FRAME_NAMESPACE::CFrameTimer)
#endif /* FRAME_TIMER_H_ */