TonicTones
|
00001 // ToneMappingOperatorManager.cpp 00002 // 00003 // Copyright 2010 Jérémy Laumon <jeremy.laumon@gmail.com> 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00018 // MA 02110-1301, USA. 00019 00020 00021 #include <ToneMappingOperatorManager.h> 00022 00033 ToneMappingOperatorPtr ToneMappingOperatorManager::getActiveOperator() 00034 { 00035 return activeOperator; 00036 } 00037 00041 void ToneMappingOperatorManager::setActiveOperator(const QString& operatorName) 00042 { 00043 if(!operators.contains(operatorName)) 00044 { 00045 activeOperator = ToneMappingOperatorPtr(NULL); 00046 } 00047 else 00048 { 00049 activeOperator = operators[operatorName]->createOperator(); 00050 } 00051 } 00052 00056 QStringList ToneMappingOperatorManager::registerOperators(const QString &directory) 00057 { 00058 QDir operatorsDir(qApp->applicationDirPath()); 00059 operatorsDir.cd(directory); 00060 00061 QStringList operatorList; 00062 00063 if (operatorsDir.exists()) 00064 { 00065 foreach (QString fileName, operatorsDir.entryList(QDir::Files)) 00066 { 00067 qDebug("Opening %s...", fileName.toStdString().c_str()); 00068 QObject *plugin = QPluginLoader(operatorsDir.absoluteFilePath(fileName)).instance(); 00069 ToneMappingOperatorFactory *operatorFactory = qobject_cast<ToneMappingOperatorFactory *>(plugin); 00070 if (operatorFactory) 00071 { 00072 operators.insert(operatorFactory->operatorName(), operatorFactory); 00073 operatorList << operatorFactory->operatorName(); 00074 qDebug("\tLoaded: %s.", operatorFactory->operatorName().toStdString().c_str()); 00075 } 00076 } 00077 } 00078 00079 return operatorList; 00080 } 00081 00085 bool ToneMappingOperatorManager::empty() 00086 { 00087 return operators.empty(); 00088 }