#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(); Inlet::CmdsImpl<(void*) func, Ret, Args...> _g_inst; public: Cmd(const QString& name) : _name_value(name) { 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(); Inlet::EventsImpl<(void*) func, Ret, Args...> _g_inst; public: Event(const QString& name) : _name_value(name) { 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); } }; }; }