MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit 0d139261 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Add mechanism to ease the conception of plugin for templated classes.

parent 0c0ac27d
......@@ -26,6 +26,8 @@ set(${PROJECT_NAME}_HEADERS
dtkCorePluginFactory
dtkCorePluginFactory.h
dtkCorePluginFactory.tpp
dtkCorePluginFactoryTemplate
dtkCorePluginFactoryTemplate.h
dtkCorePluginManager
dtkCorePluginManager.h
dtkCorePluginManager.tpp
......
......@@ -2,6 +2,7 @@
#include "dtkCorePlugin.h"
#include "dtkCorePluginFactory.h"
#include "dtkCorePluginFactory.tpp"
#include "dtkCorePluginFactoryTemplate.h"
#include "dtkCorePluginManager.h"
#include "dtkCorePluginManager.tpp"
#include "dtkArrayData.h"
......
......@@ -31,7 +31,7 @@ template <typename T> dtkCorePluginFactory<T>::~dtkCorePluginFactory(void)
template <typename T> void dtkCorePluginFactory<T>::record(const QString& key, creator func)
{
if (this->creators.contains(key)) {
qDebug() << "Factory already contains key" << key << ". Nothing is done";
qDebug() << Q_FUNC_INFO << "Factory already contains key" << key << ". Nothing is done";
return;
}
......
#include "dtkCorePluginFactoryTemplate.h"
\ No newline at end of file
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtCore>
#include <typeinfo>
// ///////////////////////////////////////////////////////////////////
// dtkCorePluginFactoryTemplate
// ///////////////////////////////////////////////////////////////////
class dtkCorePluginFactoryTemplate : public QObject
{
public:
dtkCorePluginFactoryTemplate(void) : QObject() {;}
~dtkCorePluginFactoryTemplate(void) {;}
public:
template <typename FactoryType> FactoryType *pluginFactory(void);
private:
QMap<QString, void *> m_factories;
};
// ///////////////////////////////////////////////////////////////////
template <typename FactoryType> inline FactoryType *dtkCorePluginFactoryTemplate::pluginFactory(void)
{
QString factoryTypeName = QString(typeid(FactoryType).name());
if (!m_factories.contains(factoryTypeName)) {
FactoryType *factory = new FactoryType;
m_factories.insert(factoryTypeName, factory);
}
return static_cast<FactoryType *>(m_factories[factoryTypeName]);
}
//
// dtkCorePluginFactoryTemplate.h ends here
......@@ -144,7 +144,6 @@ template <typename T> void dtkCorePluginManager<T>::load(const QString& path)
T *plugin = qobject_cast<T *>(loader->instance());
if(!plugin) {
qDebug() << loader->errorString();
delete loader;
return;
}
......@@ -167,7 +166,7 @@ template <typename T> void dtkCorePluginManager<T>::unload(const QString& path)
d->loaders.remove(path);
delete loader;
} else {
qDebug() << loader->errorString();
qDebug() << Q_FUNC_INFO << loader->errorString();
}
}
......
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