1 #ifndef STARTUPHELPER_H 2 #define STARTUPHELPER_H 5 #include <QApplication> 8 #include "helper/singleton.h" 9 #include "helper/startup_helper_templates.h" 34 static_assert(std::is_base_of<
Singleton<T>, T>::value,
"Class is not derived from AbstractSingleton");
36 addSingletonHelper(T::staticMetaObject);
49 "Class has neither an init() nor a deinit() function");
57 static void ensureCoreGetsLinked();
60 static void addSingletonHelper(
const QMetaObject& metaobj);
61 static void addComponentHelper(
const QMetaObject& metaobj, internal::VoidFnPtr initFunc, internal::VoidFnPtr deinitFunc);
70 #define STARTUP_ADD_SINGLETON(type) \ 71 static void startup_singleton_##type() { \ 72 StartupHelper::addSingleton<type>(); \ 74 Q_COREAPP_STARTUP_FUNCTION(startup_singleton_##type) 80 #define STARTUP_ADD_COMPONENT(type) \ 81 static void startup_component_##type() { \ 82 StartupHelper::addComponent<type>(); \ 84 Q_COREAPP_STARTUP_FUNCTION(startup_component_##type) 88 #endif // STARTUP_HELPER_H static void addSingleton()
Adds a Singleton to the Helper. The Singleton will be constructed after it's dependencies. Dependencies can be marked by adding a Q_CLASSINFO "dependsOn" or "optionallyDependsOn" to the class definition. .
Definition: startup_helper.h:32
The StartupHelper class manages dependencies between global singletons and other components. It ensures that the singletons/components are constructed/deleted in the right order.
Definition: startup_helper.h:19
static void addComponent()
Adds a component to the Helper. The StartupHelper will call init() and deinit() on the component clas...
Definition: startup_helper.h:45
The Singleton Template figures as baseclass for all Singletons. It provides a instance() functions wh...
Definition: singleton.h:54
Definition: startup_helper_templates.h:19
Definition: startup_helper_p.h:91
Definition: startup_helper_templates.h:9