Browse Source

update

storage-in-realtime
zhaohe 12 months ago
parent
commit
a3650dd3a1
  1. 18
      appsrc/baseservice/front_msg_processer/front_msg_processer.hpp
  2. 4
      appsrc/service/app_core.cpp

18
appsrc/baseservice/front_msg_processer/front_msg_processer.hpp

@ -110,7 +110,7 @@ class FrontMsgProcesser {
// ref https://blog.csdn.net/Veritaz/article/details/113820764
//
template <typename R, typename... Args>
void regProcesser(const string& className, const string fnName, vector<string> params, MsgProcesserFn_t fn) {
void regProcesser(function<R(Args...)> __fn, const string& className, const string fnName, vector<string> params, MsgProcesserFn_t fn) {
vector<string> paramsTypeInfo;
string ret = getTypeName<R>(className, fnName);
(paramsTypeInfo.push_back(getTypeName<Args>(className, fnName)), ...);
@ -153,17 +153,17 @@ static inline T jsonGet(json j) {
#define REGFNV_EACH_EXPTR1(_1, _2, _3, _4, _5, index, varName) params[#varName]
#define REGFNV_EACH_EXPTR2(_1, _2, _3, _4, _5, index, varName) #varName
#define REG_FN(fn, type, ...) \
FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \
#define REG_FN(fn, type, ...) { function<type> __fun; \
FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \
json& params = cxt->params; \
cxt->content = fn(MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \
});
});}
#define REG_FN_VOID(fn, type) FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { cxt->content = fn(); });
#define REG_FN_VOID(fn, type) { function<type> __fun; FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { cxt->content = fn(); });}
#define REG_EXTFN(fn, type, ...) \
FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \
#define REG_EXTFN(fn, type, ...) { function<type> __fun; \
FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \
json& params = cxt->params; \
fn(cxt, MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \
});
#define REG_EXTFN_VOID(fn, type) FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { fn(cxt); });
}); }
#define REG_EXTFN_VOID(fn, type) { function<type> __fun; FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { fn(cxt); }); }

4
appsrc/service/app_core.cpp

@ -133,7 +133,9 @@ void AppCore::initialize() {
}
});
REG_EXTFN_VOID(getState, void(void));
// REG_EXTFN_VOID(getState, void(void));
REG_EXTFN(promptConfirm, void(string), promptId);
REG_EXTFN_VOID(promptGetAll, void(void));
REG_EXTFN_VOID(promptGetNext, void(void));

Loading…
Cancel
Save