#ifndef CSCI_BASE_CONTROLLER_H #define CSCI_BASE_CONTROLLER_H #include "controller.h" #include "../../handler/controller_handler.h" template class BaseController : public Controller { private: class Allocator{ public: Allocator() { registerClass(); } [[nodiscard]] const QString &className() const { static QString class_name = ControllerHandler::getClassname(typeid(T).name()); return class_name; } template typename std::enable_if::value, void>::type registerClass() { ControllerHandler::registerCtl(className(), []() -> BaseController * { return new T(); }); } template typename std::enable_if::value, void>::type registerClass() { } }; public: const QString className() const override { return allocator.className(); } private: static Allocator allocator; public: static QString getClassName() { return allocator.className(); } }; template typename BaseController::Allocator BaseController::allocator; #endif //CSCI_BASE_CONTROLLER_H