Commit c8a0421a authored by Julien Wintz's avatar Julien Wintz
Browse files

ObjectFactory: Yet another attempt based on a straight virtual

inheritance.

Does not build.
parent e9f4d2ab
......@@ -69,12 +69,15 @@ public:
// ///////////////////////////////////////////////////////////////////
#define DTK_DECLARE_PLUGIN_FACTORY(type, Export) \
class Export type##PluginFactory : public dtkCorePluginFactoryMeta, public dtkCorePluginFactory<type> \
class Export type##PluginFactory : public dtkCorePluginFactory<type> \
{ \
public: \
void touch(type *t) \
{ \
dtkCorePluginFactoryMeta::touch(QVariant::fromValue(t)); \
QVariant variant(this->type()); \
variant.setValue(t); \
\
emit created(variant); \
} \
}; \
\
......
......@@ -23,7 +23,7 @@
//
// ///////////////////////////////////////////////////////////////////
class DTKCORE_EXPORT dtkCorePluginFactoryMeta : public QObject
class DTKCORE_EXPORT dtkCorePluginFactoryBase : public QObject
{
Q_OBJECT
......@@ -31,9 +31,7 @@ signals:
void created(QVariant);
public:
virtual void touch(QVariant variant) {
emit created(variant);
};
virtual int type(void) = 0;
};
// ///////////////////////////////////////////////////////////////////
......@@ -42,7 +40,7 @@ public:
template <typename T> class dtkCorePluginTuner;
template <typename T> class dtkCorePluginFactory
template <typename T> class dtkCorePluginFactory : public dtkCorePluginFactoryBase
{
public:
dtkCorePluginFactory(void);
......@@ -64,9 +62,10 @@ public:
QStringList keys(void) const;
public:
virtual void touch(T *) {
qFatal("dtkCorePluginFactory<T>::touch(T *): Should never get here!");
};
int type(void) const;
public:
virtual void touch(T *) = 0;
private:
QHash<QString, creator> creators;
......
......@@ -68,6 +68,15 @@ template <typename T> dtkCorePluginTuner<T> *dtkCorePluginFactory<T>::createTune
return this->tuner_creators.value(key)();
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
template <typename T> int dtkCorePluginFactory<T>::type(void) const
{
return qMetaTypeId<T *>(reinterpret_cast<T **>(0));
}
// /////////////////////////////////////////////////////////////////
// Type creator inspection
// /////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment