Commit 5ecef5d1 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Add support for tuner into factory.

Fix also bad tuner destructor.
parent 7306c2b9
......@@ -16,6 +16,8 @@
#include <QtCore>
template < typename T > class dtkCorePluginTuner;
// ///////////////////////////////////////////////////////////////////
// dtkCorePluginFactory
// ///////////////////////////////////////////////////////////////////
......@@ -28,18 +30,22 @@ public:
public:
typedef T *(*creator) ();
typedef dtkCorePluginTuner<T> *(*tunerCreator) ();
public:
void record(const QString& key, creator func);
void recordTuner(const QString& key, tunerCreator func);
public:
T *create(const QString& key) const;
dtkCorePluginTuner<T> *createTuner(const QString& key) const;
public:
QStringList keys(void) const;
private:
QHash<QString, creator> creators;
QHash<QString, tunerCreator> tuner_creators;
};
// ///////////////////////////////////////////////////////////////////
......
......@@ -38,6 +38,16 @@ template <typename T> void dtkCorePluginFactory<T>::record(const QString& key, c
this->creators.insert(key, func);
}
template <typename T> void dtkCorePluginFactory<T>::recordTuner(const QString& key, tunerCreator func)
{
if (this->tuner_creators.contains(key)) {
qDebug() << Q_FUNC_INFO << "Factory already contains key" << key << ". Nothing is done";
return;
}
this->tuner_creators.insert(key, func);
}
// /////////////////////////////////////////////////////////////////
// Type creator invokation
// /////////////////////////////////////////////////////////////////
......@@ -50,6 +60,14 @@ template <typename T> T *dtkCorePluginFactory<T>::create(const QString& key) con
return this->creators.value(key)();
}
template <typename T> dtkCorePluginTuner<T> *dtkCorePluginFactory<T>::createTuner(const QString& key) const
{
if(!this->tuner_creators.contains(key))
return NULL;
return this->tuner_creators.value(key)();
}
// /////////////////////////////////////////////////////////////////
// Type creator inspection
// /////////////////////////////////////////////////////////////////
......
......@@ -24,7 +24,7 @@ template < typename T > class dtkCorePluginTuner
{
public:
dtkCorePluginTuner(void);
virtual ~dtkCorePluginTuner(void) {}
virtual ~dtkCorePluginTuner(void);
void setObject(T *object);
void setMap(const QVariantHash& map);
......
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