Removed the way for registration of service implementation through the Qt meta-system

This commit is contained in:
pereverzev_v 2019-12-13 16:58:33 +02:00
parent 3e680d94c9
commit 4bf0060ff1

View file

@ -21,7 +21,6 @@
#define SERVICESRESOLVER_H
#include <QHash>
#include <QMetaType>
#include <QUuid>
#define INTERFACE_ID \
@ -38,25 +37,6 @@ public:
virtual void* getInstance() = 0;
};
template <typename T>
struct MetaTypeBasedFactory : public IServiceFactory
{
MetaTypeBasedFactory(const int implTypeId) : IServiceFactory() {
implementationTypeId = implTypeId;
}
void* getInstance() override {
if (!QMetaType::isRegistered(implementationTypeId)) {
return nullptr;
}
return QMetaType::create(implementationTypeId);
}
private:
int implementationTypeId = 0;
};
template <typename T>
struct FunctorBasedFactory : public IServiceFactory
{
@ -74,17 +54,6 @@ public:
F getInstanceFunc;
};
template <typename I, typename T>
static inline void registerService() {
const int implementationTypeId = qMetaTypeId<T>();
QUuid interfaceId = I::interfaceId();
MetaTypeBasedFactory<T>* srv = new MetaTypeBasedFactory<T>(implementationTypeId);
srvHash()->insert(interfaceId, srv);
}
template <typename I, typename T>
static inline void registerService(T*(*f)()) {