aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/extensionsystem/iplugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/extensionsystem/iplugin.h')
-rw-r--r--src/libs/extensionsystem/iplugin.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libs/extensionsystem/iplugin.h b/src/libs/extensionsystem/iplugin.h
index 5a8fceb3d6..3e477e42e8 100644
--- a/src/libs/extensionsystem/iplugin.h
+++ b/src/libs/extensionsystem/iplugin.h
@@ -5,6 +5,8 @@
#include "extensionsystem_global.h"
+#include <utils/id.h>
+
#include <QObject>
#include <functional>
@@ -15,6 +17,17 @@ namespace Internal { class IPluginPrivate; }
using TestCreator = std::function<QObject *()>;
+using ObjectCreator = std::function<void *()>;
+using ObjectDestructor = std::function<void(void *)>;
+
+struct EXTENSIONSYSTEM_EXPORT ObjectCreationPolicy
+{
+ // Can be empty if nothing depends on it.
+ Utils::Id id;
+ // Objects with empty dependencies are created as soon as possible.
+ QList<Utils::Id> dependsOn;
+};
+
class EXTENSIONSYSTEM_EXPORT IPlugin : public QObject
{
Q_OBJECT
@@ -39,6 +52,7 @@ public:
// Deprecated in 10.0, use addTest()
virtual QVector<QObject *> createTestObjects() const;
+ virtual void tryCreateObjects();
protected:
virtual void initialize() {}
@@ -47,6 +61,17 @@ protected:
void addTest(Args && ...args) { addTestCreator([args...] { return new Test(args...); }); }
void addTestCreator(const TestCreator &creator);
+ template <typename Type>
+ void addManaged(const ObjectCreationPolicy &policy = {}) {
+ addManagedHelper([]() -> void * { return new Type(); },
+ [](void *p) { delete static_cast<Type *>(p); },
+ policy);
+ }
+
+ void addManagedHelper(const ObjectCreator &creator,
+ const ObjectDestructor &destructor,
+ const ObjectCreationPolicy &policy);
+
signals:
void asynchronousShutdownFinished();