add get result

This commit is contained in:
2025-06-09 14:54:51 +03:00
parent b5ec861332
commit 0215e46e4f
2 changed files with 9 additions and 2 deletions

View File

@@ -50,12 +50,12 @@ namespace example
{ {
VE::event e { test_event::TEST_EVEN_1, std::string("test event 1 message"), "asdf-asdf-asdf" }; VE::event e { test_event::TEST_EVEN_1, std::string("test event 1 message"), "asdf-asdf-asdf" };
EMIT(e); EMIT(e);
auto r = std::any_cast<std::string>(e.m_result); auto r = e.get_result<std::string>();
hack::log()(r); hack::log()(r);
e = { test_event::TEST_EVEN_2, std::string("test event 2 message") }; e = { test_event::TEST_EVEN_2, std::string("test event 2 message") };
EMIT(e); EMIT(e);
r = std::any_cast<std::string>(e.m_result); r = e.get_result<std::string>();
hack::log()(r); hack::log()(r);
} }

View File

@@ -17,5 +17,12 @@ namespace VE
std::string m_id; std::string m_id;
std::string m_event_log_message; std::string m_event_log_message;
std::string m_event_id = hack::security::generate_uuid(); std::string m_event_id = hack::security::generate_uuid();
template<typename T>
T get_result()
{
auto r = std::any_cast<T>(m_result);
return r;
}
}; };
} }