#pragma once #include "dispatch.h" #include "cmds_basic.h" namespace cmds { template struct T; template struct T { template func> struct Cmd { private: QString _name_value; dispatch::Dispatch* core = dispatch::Dispatch::unique(); public: Cmd(const QString& name) : _name_value(name) { auto g_inst = Inlet::CmdsImpl<(void*) func, Ret, Args...>::unique(); core->registerCmd(g_inst->address(), g_inst); core->setCmdAlias(g_inst->address(), name); } Ret operator()(Args... args) { Inlet::CmdsImpl<(void*) func, Ret, Args...> new_inst(args...); core->runWith(&new_inst); return new_inst.result(); } }; template func> struct Event { private: QString _name_value; dispatch::Dispatch* core = dispatch::Dispatch::unique(); public: Event(const QString& name) : _name_value(name) { auto g_inst = Inlet::EventsImpl<(void*)func, Ret, Args...>::unique(); core->registerEvent(g_inst->address(), g_inst); core->setEventAlias(g_inst->address(), name); } void operator()(Args... args) { Inlet::EventsImpl<(void*) func, Ret, Args...> new_inst(args...); core->notifyWith(&new_inst); } }; }; }