1 Star 0 Fork 32

changjianqiu/CM-Server

forked from 留天下/CM-Server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
signal.cpp 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
留天下 提交于 2019-02-22 13:22 . net redo done!
#include "signal.h"
#include"Json/reader.h"
#include<iostream>
using namespace std;
Signal::Signal()
{
}
Signal::~Signal()
{
for (auto var : m_slots)
{
delete var;
var = nullptr;
}
}
void Signal::removeSlot(const long long int & slotId)
{
for (auto var : m_slots)
{
if (var->getId() == slotId)
{
m_slots.remove(var);
delete var;
var = nullptr;
}
}
}
Slot * Signal::add(const EventHandler & handler)
{
Slot* slot = new Slot(this, handler);
m_slots.push_back(slot);
return slot;
}
Slot * Signal::addOnce(const EventHandler & handler)
{
Slot* slot = new Slot(this, handler, true);
m_slots.push_back(slot);
return slot;
}
Slot * Signal::add(const std::function<void(Json::Value&)>& func)
{
Slot* slot = new Slot(this, func);
m_slots.push_back(slot);
return slot;
}
Slot * Signal::addOnce(const std::function<void(Json::Value&)>& func)
{
Slot* slot = new Slot(this, func, true);
m_slots.push_back(slot);
return slot;
}
void Signal::dispatch(Json::Value& message)
{
cout<<"Signal::dispatch"<<message.toStyledString()<<endl;
for (auto var : m_slots)
{
var->dispatch(message);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/jianxiaohanqiu/CM-Server.git
git@gitee.com:jianxiaohanqiu/CM-Server.git
jianxiaohanqiu
CM-Server
CM-Server
master

搜索帮助