-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzinxtimer.h
78 lines (56 loc) · 2.27 KB
/
zinxtimer.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
#pragma once
#include<zinx.h>
#include<iostream>
#include<vector>
using namespace std;
class zinxtimerchannel:public Ichannel
{
private:
int tfd = -1;
public:
virtual bool Init();
/*读取数据, 开发者应该根据目标文件不同,重写这个函数,以实现将fd中的数据读取到参数_string中
该函数会在数据源所对应的文件有数据到达时被调用*/
virtual bool ReadFd(std::string &_input);
/*写出数据, 开发者应该将数据写出的操作通过重写该函数实现
该函数会在调用zinxkernel::sendout函数后被调用(通常不是直接调用而是通过多路复用的反压机制调用)*/
virtual bool WriteFd(std::string &_output);
/*通道去初始化,开发者应该在该函数回收相关资源
该函数会在通道对象从zinxkernel中摘除时调用*/
virtual void Fini();
/*获取文件描述符函数, 开发者应该在该函数返回当前关心的文件,
一般地,开发者应该在派生类中定义属性用来记录数据来记录当前IO所用的文件,在此函数中只是返回该属性*/
virtual int GetFd();
virtual std::string GetChannelInfo();
virtual AZinxHandler *GetInputNextStage(BytesMsg &_oInput);
};
class helloworld : public AZinxHandler
{
public:
virtual IZinxMsg *InternelHandle(IZinxMsg &_oInput);
/*获取下一个处理环节函数,开发者重写该函数,可以指定当前处理环节结束后下一个环节是什么,通过参数信息对象,可以针对不同情况进行分别处理*/
virtual AZinxHandler *GetNextHandler(IZinxMsg &_oNextMsg);
};
class timerProc{
public:
virtual void Proc() = 0;
virtual int getTimerSeconds() = 0;
int count = -1;
};
class timermanager:public AZinxHandler{
private:
std::vector<list<timerProc*>> tpl;
int m_currenindex;
static timermanager m;
public:
timermanager();
virtual IZinxMsg *InternelHandle(IZinxMsg &_oInput);
/*获取下一个处理环节函数,开发者重写该函数,可以指定当前处理环节结束后下一个环节是什么,通过参数信息对象,可以针对不同情况进行分别处理*/
virtual AZinxHandler *GetNextHandler(IZinxMsg &_oNextMsg);
void addTimerProc(timerProc *t);
void delTimerProc(timerProc *t);
static timermanager &getInstance()
{
return m;
}
};