Migration of QtMvvm from github
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.

67 lines
1.4 KiB

7 years ago
#ifndef QTMVVM_SERVICEREGISTRY_P_H
#define QTMVVM_SERVICEREGISTRY_P_H
7 years ago
#include <QtCore/QMutex>
#include <QtCore/QSharedPointer>
7 years ago
7 years ago
#include "qtmvvmcore_global.h"
#include "serviceregistry.h"
namespace QtMvvm {
class ServiceRegistryPrivate
{
public:
7 years ago
class ServiceInfo {
public:
ServiceInfo(bool weak);
7 years ago
virtual ~ServiceInfo();
bool replaceable() const;
QObject *instance(ServiceRegistryPrivate *d, const QByteArray &iid);
7 years ago
protected:
virtual QObject *construct(ServiceRegistryPrivate *d) const = 0;
private:
const bool _weak;
7 years ago
QObject *_instance;
};
class FnServiceInfo : public ServiceInfo {
public:
FnServiceInfo(const std::function<QObject*(QObjectList)> &creator, const QByteArrayList &injectables, bool weak);
7 years ago
protected:
QObject *construct(ServiceRegistryPrivate *d) const final;
private:
std::function<QObject*(QObjectList)> creator;
QByteArrayList injectables;
};
class MetaServiceInfo : public ServiceInfo {
public:
MetaServiceInfo(const QMetaObject *metaObject, bool weak);
7 years ago
protected:
QObject *construct(ServiceRegistryPrivate *d) const final;
private:
const QMetaObject *metaObject;
};
QMutex serviceMutex;
QHash<QByteArray, QSharedPointer<ServiceInfo>> services;
7 years ago
ServiceRegistryPrivate();
bool serviceBlocked(const QByteArray &iid) const;
static QObject *constructInjected(const QMetaObject *metaObject);
QObject *constructInjectedLocked(const QMetaObject *metaObject);
7 years ago
};
}
#endif // QTMVVM_SERVICEREGISTRY_P_H