19 Star 44 Fork 32

留天下 / CM-Server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
event.h 1012 Bytes
一键复制 编辑 原始数据 按行查看 历史
留天下 提交于 2019-02-22 13:22 . net redo done!
#ifndef EVENT_H
#define EVENT_H
#include"object.h"
#include"slotlistener.h"
#include"Json/value.h"
#include<iostream>
#include<functional>
#define SEL_EVENTFUNC(func) static_cast<SEL_EventFunc>(&func)
typedef void (Object::*SEL_EventFunc)(Json::Value&);
typedef struct _Event{
Object* handler;
SEL_EventFunc func;
}EventHandler;
class Slot
{
public:
Slot(SlotListener* listener, const EventHandler& evh, const bool& once = false);
Slot(SlotListener* listener,const std::function<void(Json::Value&)>& func, const bool& once = false);
virtual ~Slot() {}
virtual void dispatch(Json::Value& message);
bool operator==(const Slot& slot);
long long int getId() const;
void remove();
private:
long long int id;
bool flag = 0;
EventHandler evh;
std::function<void(Json::Value&)> func;
bool once;
SlotListener* listener;
static long long int count;
};
EventHandler handler(Object* obj, SEL_EventFunc func);
#endif // EVENT_H
C++
1
https://gitee.com/lsylovews/CM-Server.git
git@gitee.com:lsylovews/CM-Server.git
lsylovews
CM-Server
CM-Server
master

搜索帮助