add new event
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <hack/patterns/singleton.hpp>
|
||||
#include <hack/logger/logger.hpp>
|
||||
#include <hack/security/uuid.hpp>
|
||||
#include <hack/exception/exception.hpp>
|
||||
|
||||
#include "event.hpp"
|
||||
|
||||
@@ -13,25 +14,24 @@ namespace VE
|
||||
{
|
||||
void emit(event e)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
try
|
||||
{
|
||||
for(auto& f : m_funcs) f.func(e);
|
||||
}
|
||||
catch(const std::exception& ex)
|
||||
{
|
||||
hack::error()(ex.what());
|
||||
hack::log()("size funcs", m_funcs.size());
|
||||
for(;i < m_funcs.size();++i) m_funcs[i].m_func(e);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
hack::error()("ooops...");
|
||||
hack::error()("call function is error...");
|
||||
hack::exception ex;
|
||||
ex.set_data(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
struct EventHandler
|
||||
{
|
||||
std::function<void(event)> func;
|
||||
void* obj;
|
||||
std::function<void(event)> m_func;
|
||||
void* m_obj;
|
||||
};
|
||||
|
||||
std::vector<EventHandler> m_funcs;
|
||||
@@ -51,7 +51,7 @@ namespace VE
|
||||
m_funcs.erase(
|
||||
std::remove_if(m_funcs.begin(), m_funcs.end(),
|
||||
[obj](const auto& handler) {
|
||||
return handler.obj == obj;
|
||||
return handler.m_obj == obj;
|
||||
}),
|
||||
m_funcs.end()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user