// Version: $Id$ // // // Commentary: // // // Change Log: // // // Code: #pragma once // /////////////////////////////////////////////////////////////////// // dtkCorePluginFactoryBase implementation // /////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////// // dtkCorePluginFactory implementation // /////////////////////////////////////////////////////////////////// template dtkCorePluginFactory::dtkCorePluginFactory(void) { } template dtkCorePluginFactory::~dtkCorePluginFactory(void) { } // ///////////////////////////////////////////////////////////////// // Type creator registration // ///////////////////////////////////////////////////////////////// template void dtkCorePluginFactory::record(const QString& key, creator func) { if (this->creators.contains(key)) { qDebug() << Q_FUNC_INFO << "Factory already contains key" << key << ". Nothing is done"; return; } this->creators.insert(key, func); } template void dtkCorePluginFactory::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 // ///////////////////////////////////////////////////////////////// template T *dtkCorePluginFactory::create(const QString& key) const { if (!this->creators.contains(key)) return NULL; T *obj = this->creators.value(key)(); if (obj) this->dtkCorePluginFactoryBase::touch(qMetaTypeId(), obj); return obj; } template dtkCorePluginTuner *dtkCorePluginFactory::createTuner(const QString& key) const { if (!this->tuner_creators.contains(key)) return NULL; return this->tuner_creators.value(key)(); } // ///////////////////////////////////////////////////////////////// // Type creator inspection // ///////////////////////////////////////////////////////////////// template QStringList dtkCorePluginFactory::keys(void) const { return this->creators.keys(); } // // dtkCorePluginFactory_t.h ends here