add event to emnit
This commit is contained in:
@@ -31,7 +31,7 @@ namespace VE
|
||||
|
||||
public:
|
||||
template <typename TYPE, typename DATA>
|
||||
static void EMIT(TYPE t, DATA d, int id = -1, std::string msg = "")
|
||||
static void EMIT(TYPE t, DATA d, std::string id = hack::security::generate_uuid(), std::string msg = "")
|
||||
{
|
||||
event e{ t, d, id};
|
||||
if (msg != "") e.m_event_log_message = msg;
|
||||
@@ -51,27 +51,4 @@ namespace VE
|
||||
private:
|
||||
std::string m_key;
|
||||
};
|
||||
|
||||
// template <typename T>
|
||||
// void CONNECT(T* obj)
|
||||
// {
|
||||
// event_manager::instance().connect(obj, &T::on_event);
|
||||
// }
|
||||
//
|
||||
// template <typename T>
|
||||
// void DISCONNECT(T* obj)
|
||||
// {
|
||||
// event_manager::instance().disconnect(obj, &T::on_event);
|
||||
// }
|
||||
|
||||
// template <typename TYPE, typename DATA>
|
||||
// void EMIT(TYPE t, DATA d, int id = -1)
|
||||
// {
|
||||
// event_manager::instance().emit(event{ t, d, id});
|
||||
// }
|
||||
//
|
||||
// inline void EMIT(event e)
|
||||
// {
|
||||
// event_manager::instance().emit(e);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -60,86 +60,3 @@ namespace VE
|
||||
std::map<std::string, event_fn<event>> m_funcs;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// #pragma once
|
||||
//
|
||||
// #include <functional>
|
||||
// #include <hack/patterns/singleton.hpp>
|
||||
// #include <hack/logger/logger.hpp>
|
||||
// #include <hack/security/uuid.hpp>
|
||||
// #include <hack/exception/exception.hpp>
|
||||
//
|
||||
// #include "event.hpp"
|
||||
//
|
||||
// namespace VE
|
||||
// {
|
||||
// struct event_manager : public hack::patterns::singleton<event_manager>
|
||||
// {
|
||||
// void emit(event e)
|
||||
// {
|
||||
// if (m_funcs.size() == 0)
|
||||
// {
|
||||
// hack::warn()("funs is empty");
|
||||
// return;
|
||||
// }
|
||||
// else if (!e.m_msg.empty())
|
||||
// {
|
||||
// hack::warn()("EMIT MSG:", e.m_msg, m_funcs.size());
|
||||
// }
|
||||
//
|
||||
// std::size_t i = 0;
|
||||
// try
|
||||
// {
|
||||
// for(;i < m_funcs.size();++i) m_funcs[i].m_func(e);
|
||||
// }
|
||||
// catch(std::exception& ext)
|
||||
// {
|
||||
// hack::error()("call function is error:", ext.what());
|
||||
// hack::exception ex;
|
||||
// ex.system_error(ext);
|
||||
// ex.set_data(e);
|
||||
// throw ex;
|
||||
// }
|
||||
// catch(...)
|
||||
// {
|
||||
// hack::error()("call function is error:", "oopps...");
|
||||
// hack::exception ex;
|
||||
// ex.set_data(e);
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// template<typename T>
|
||||
// void connect(T* obj, void (T::*method)(event))
|
||||
// {
|
||||
// m_funcs.push_back({
|
||||
// std::bind(method, obj, std::placeholders::_1),
|
||||
// static_cast<void*>(obj)
|
||||
// });
|
||||
// hack::warn()("connect (size)", m_funcs.size());
|
||||
// }
|
||||
//
|
||||
// template<typename T>
|
||||
// void disconnect(T* obj, void (T::*method)(event))
|
||||
// {
|
||||
// m_funcs.erase(
|
||||
// std::remove_if(m_funcs.begin(), m_funcs.end(),
|
||||
// [obj](const auto& handler) {
|
||||
// return handler.m_obj == obj;
|
||||
// }),
|
||||
// m_funcs.end()
|
||||
// );
|
||||
// hack::warn()("disconnect (size)", m_funcs.size());
|
||||
// }
|
||||
//
|
||||
// struct EventHandler
|
||||
// {
|
||||
// std::function<void(event)> m_func;
|
||||
// void* m_obj;
|
||||
// };
|
||||
//
|
||||
// std::vector<EventHandler> m_funcs;
|
||||
//
|
||||
// };
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user