You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
|
|
#include "controller_handler.h"
|
|
|
|
|
|
QString ControllerHandler::getClassname(const char *mangled_name) {
|
|
#ifndef _MSC_VER
|
|
std::size_t len = 0;
|
|
int status = 0;
|
|
std::unique_ptr<char, decltype(&std::free)> ptr(
|
|
__cxxabiv1::__cxa_demangle(mangled_name, nullptr, &len, &status),
|
|
&std::free);
|
|
if (status == 0) {
|
|
return { ptr.get() };
|
|
}
|
|
return "";
|
|
#else
|
|
auto pos = strstr(mangled_name, " ");
|
|
if (pos == nullptr)
|
|
return std::string{mangled_name};
|
|
else
|
|
return std::string{pos + 1};
|
|
#endif
|
|
}
|
|
|
|
void ControllerHandler::registerCtl(const QString &key, const ControllerFunc &fun) {
|
|
getControllerFuncMap().insert(key.toUtf8(), fun);
|
|
}
|
|
|
|
ControllerFuncMap &ControllerHandler::getControllerFuncMap() {
|
|
static ControllerFuncMap controllerFuncMap;
|
|
return controllerFuncMap;
|
|
}
|
|
|
|
void ControllerHandler::init() {
|
|
auto funcMap = getControllerFuncMap();
|
|
for (const auto &key: funcMap.keys()){
|
|
auto ins = funcMap.value(key)();
|
|
QObject::connect(KafkaHandler::getIns(), SIGNAL(handle(QString, QString)), ins, SLOT(route(QString,QString)));
|
|
}
|
|
}
|