QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
qqmlserviceregistry.h
1 #ifndef QTMVVM_QQMLSERVICEREGISTRY_H
2 #define QTMVVM_QQMLSERVICEREGISTRY_H
3 
4 #include <QtCore/QObject>
5 
6 #include <QtMvvmCore/ServiceRegistry>
7 
8 #include <QtQml/QQmlEngine>
9 #include <QtQml/QQmlComponent>
10 
11 #ifdef DOXYGEN_RUN
13 
22 #else
23 namespace QtMvvm {
24 
25 class QQmlServiceRegistry : public QObject
26 #endif
27 {
28  Q_OBJECT
29 
30 public:
37  };
38  Q_ENUM(DestructionScope)
39 
40 
41  explicit QQmlServiceRegistry(QQmlEngine *parent = nullptr);
42 
44  Q_INVOKABLE bool isRegistered(const QString &iid) const;
45 
47  Q_INVOKABLE void registerObject(QObject *service, QtMvvm::QQmlServiceRegistry::DestructionScope scope = DestroyOnAppQuit, bool weak = false);
62  Q_INVOKABLE void registerObject(const QString &iid, const QJSValue &function, bool weak = false);
79  Q_INVOKABLE void registerObject(const QUrl &componentUrl, bool weak = false);
80 
82  Q_INVOKABLE void registerPlugin(const QString &iid,
83  QString pluginType = {},
84  QString pluginKey = {},
86  bool weak = false);
87 
89  Q_INVOKABLE QObject *service(const QString &iid);
90 
91 private:
92  QQmlEngine *_engine;
93 };
94 
95 }
96 
97 #endif // QTMVVM_QQMLSERVICEREGISTRY_H
Destroy as soon as the QCoreApplication gets destroyed (typically end of main)
Q_INVOKABLE QObject * service(const QString &iid)
Returns the service for the given iid.
The QML import for the QtMvvmCore QML module.
Definition: qqmlcoreapp.h:9
Destroy when the QCoreApplication::aboutToQuit signal is emitted.
A QML singleton to access some QtMvvm::ServiceRegistry functionality.
DestructionScope
A singleton to prepare services for dependency injection and to access them.
Q_INVOKABLE void registerObject(QObject *service, QtMvvm::QQmlServiceRegistry::DestructionScope scope=DestroyOnAppQuit, bool weak=false)
Register a service via an already existing instance.
Destroy together with the service registry instance (static memory, unspecified order!) ...
Q_INVOKABLE bool isRegistered(const QString &iid) const
Checks if a given interface or service is already registered.
The primary namespace of the QtMvvm library.
Q_INVOKABLE void registerPlugin(const QString &iid, QString pluginType={}, QString pluginKey={}, DestructionScope scope=DestroyOnAppDestroy, bool weak=false)
Register a service by an iid via specifing a plugin to be loaded.