2#include "entt/core/fwd.hpp"
3#include "entt/meta/meta.hpp"
8#include <entt/meta/resolve.hpp>
9#include <entt/meta/utility.hpp>
10#include <entt/core/hashed_string.hpp>
12using namespace std::chrono_literals;
20 std::cout <<
"service::" << __func__ <<
" module " << desc.lib_name << std::endl;
24 using namespace entt::literals;
26 auto type = entt::resolve(entt::hashed_string{
module.desc.type_name.c_str()});
28 if(!
type.invoke(
"create"_hs, {}, entt::forward_as_meta(ctx_), entt::forward_as_meta(parser_)).cast<
bool>())
33 modules_.emplace_back(std::move(module));
40 std::cout <<
"service::" << __func__ <<
" module " << module.
desc.
lib_name << std::endl;
42 using namespace entt::literals;
44 auto type = entt::resolve(entt::hashed_string{
module.desc.type_name.c_str()});
46 if(!
type.invoke(
"deinit"_hs, {}).cast<
bool>())
51 if(!
type.invoke(
"destroy"_hs, {}).cast<
bool>())
62 for(
const auto& desc : descs)
83 for(
auto it = std::rbegin(modules_); it != std::rend(modules_); ++it)
100 for(
const auto& module : modules_)
102 using namespace entt::literals;
104 auto type = entt::resolve(entt::hashed_string{
module.desc.type_name.c_str()});
106 if(!
type.invoke(
"init"_hs, {}, entt::forward_as_meta(parser_)).cast<
bool>())
120 bool processed =
false;
121 for(
const auto& module : modules_)
123 using namespace entt::literals;
125 auto type = entt::resolve(entt::hashed_string{
module.desc.type_name.c_str()});
127 if(!
type.invoke(
"interrupt"_hs, {}).cast<
bool>())
142 for(
const auto& module : modules_)
144 using namespace entt::literals;
146 auto type = entt::resolve(entt::hashed_string{
module.desc.type_name.c_str()});
148 auto proc_result =
type.invoke(
"process"_hs, {}).cast<int>();
155 processed = std::max(processed, proc_result);
168 std::vector<module_desc> modules{{
name,
name}};
175 if(!app.
load(modules))
void * load(bx::FileReaderI *_reader, bx::AllocatorI *_allocator, const char *_filePath, uint32_t *_size)
auto service_main(const char *name, int argc, char *argv[]) -> int
#define SERVICE_RESULT_EXIT
#define SERVICE_RESULT_RUN
auto get_cmd_line_parser() -> cmd_line::parser &
service(int argc, char *argv[])
auto load(const module_desc &desc) -> bool
auto unload(const module_data &module) -> bool