1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/lsylovews-CM-Server

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
event.cpp 1.2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
六十音 Отправлено 03.03.2019 17:47 552bfa7
#include "event.h"
#include<iostream>
using namespace std;
using namespace Json;
long long int Slot::count = 0;
Slot::Slot(SlotListener* listener,const EventHandler& evh,const bool& once)
{
this->listener = listener;
this->flag=false;
this->evh = evh;
this->once = once;
this->id = count++;
}
Slot::Slot(SlotListener* listener, const std::function<void(Json::Value&)>& func, const bool& once) {
this->listener = listener;
this->flag = true;
this->func = func;
this->once = once;
this->id = count++;
}
void Slot::dispatch(Json::Value& message)
{
cout<<"Slot::dispatch"<<message.toStyledString()<<endl;
if (flag)
{
func(message);
}
else
{
cout<<"Slot::dispatch 2"<<message.toStyledString()<<endl;
(evh.handler->*evh.func)(message);
}
if (once)
this->remove();
}
bool Slot::operator==(const Slot & slot)
{
return this->id == slot.id;
}
long long int Slot::getId() const
{
return this->id;
}
void Slot::remove()
{
this->listener->removeSlot(this->getId());
}
EventHandler handler(Object* CCObject,SEL_EventFunc func)
{
EventHandler evh;
evh.handler = CCObject;
evh.func = func;
return evh;
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/lsylovews-CM-Server.git
git@api.gitlife.ru:oschina-mirror/lsylovews-CM-Server.git
oschina-mirror
lsylovews-CM-Server
lsylovews-CM-Server
master