Commit dbb3e7fe authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Introduce templated core factory.

parent 54303850
......@@ -3,9 +3,9 @@
## Author: Julien Wintz
## Created: Fri Feb 8 16:49:52 2013 (+0100)
## Version:
## Last-Updated: Tue Feb 26 14:58:04 2013 (+0100)
## By: Julien Wintz
## Update #: 15
## Last-Updated: 2013 Thu Feb 28 14:27:21 (+0100)
## By: Thibaud Kloczko
## Update #: 17
######################################################################
##
### Change Log:
......@@ -19,6 +19,8 @@ project(dtkCore)
## #################################################################
set(${PROJECT_NAME}_HEADERS
dtkCorePluginFactory.h
dtkCorePluginFactory.tpp
dtkCorePluginManager.h
dtkCoreSettings.h)
......
#include "dtkCorePluginFactory.h"
/* dtkCorePluginFactory.h ---
*
* Author: Thibaud Kloczko
* Created: 2013 Thu Feb 28 14:13:28 (+0100)
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#pragma once
#include <QtCore>
//template <typename T> class dtkCorePluginFactoryPrivate;
template <typename T> class dtkCorePluginFactory : public QObject
{
public:
typedef T *(*creator) (void);
public:
dtkCorePluginFactory(void);
~dtkCorePluginFactory(void);
public:
T *create(const QString& key);
public:
QStringList keys(void);
public:
void record(QString key, creator func);
private:
QHash<QString, creator> creators;
//dtkCorePluginFactoryPrivate<T> *d;
};
#include "dtkCorePluginFactory.tpp"
/* dtkCorePluginFactory.tpp ---
*
* Author: Julien Wintz
* Created: Fri Feb 8 16:20:47 2013 (+0100)
* Version:
* Last-Updated: 2013 Thu Feb 28 14:47:18 (+0100)
* By: Thibaud Kloczko
* Update #: 54
*/
/* Change Log:
*
*/
#pragma once
// template <typename X> class dtkCorePluginFactoryPrivate
// {
// public:
// dtkCorePluginFactory<X>::creator toto;
// QHash<QString, dtkCorePluginFactory<X>::creator> creators;
// };
template <typename T> dtkCorePluginFactory<T>::dtkCorePluginFactory(void)
{
}
template <typename T> dtkCorePluginFactory<T>::~dtkCorePluginFactory(void)
{
}
template <typename T> T *dtkCorePluginFactory<T>::create(const QString& key)
{
Q_ASSERT(this->creators.contains(key));
return this->creators.value(key)();
}
template <typename T> QStringList dtkCorePluginFactory<T>::keys(void)
{
return this->creators.keys();
}
template <typename T> void dtkCorePluginFactory<T>::record(QString key, creator func)
{
this->creators.insert(key, func);
}
......@@ -3,15 +3,17 @@
* Author: Julien Wintz
* Created: Fri Feb 8 16:20:47 2013 (+0100)
* Version:
* Last-Updated: 2013 Tue Feb 12 14:24:43 (+0100)
* Last-Updated: 2013 Thu Feb 28 14:30:28 (+0100)
* By: Thibaud Kloczko
* Update #: 27
* Update #: 28
*/
/* Change Log:
*
*/
#if 0
#include "dtkDistributedCommunicator.h"
#include "dtkDistributedCommunicatorPluginFactory.h"
......@@ -49,3 +51,6 @@ void dtkDistributedCommunicatorPluginFactory::record(QString key, creator func)
{
d->creators.insert(key, func);
}
#endif
......@@ -3,9 +3,9 @@
* Author: Julien Wintz
* Created: Fri Feb 8 16:17:21 2013 (+0100)
* Version:
* Last-Updated: 2013 Tue Feb 12 14:23:41 (+0100)
* Last-Updated: 2013 Thu Feb 28 14:43:48 (+0100)
* By: Thibaud Kloczko
* Update #: 39
* Update #: 49
*/
/* Change Log:
......@@ -14,6 +14,14 @@
#pragma once
#include <dtkCore/dtkCorePluginFactory.h>
#include "dtkDistributedCommunicator.h"
class dtkDistributedCommunicatorPluginFactory : public dtkCorePluginFactory<dtkDistributedCommunicator> {};
#if 0
#include <QtCore>
class dtkDistributedCommunicator;
......@@ -42,3 +50,5 @@ public:
private:
dtkDistributedCommunicatorPluginFactoryPrivate *d;
};
#endif
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