00001 /*************************************************************************** 00002 * file klffactory.h 00003 * This file is part of the KLatexFormula Project. 00004 * Copyright (C) 2010 by Philippe Faist 00005 * philippe.faist at bluewin.ch 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 /* $Id: klffactory.h 442 2010-08-13 17:34:38Z philippe $ */ 00023 00024 #ifndef KLFFACTORY_H 00025 #define KLFFACTORY_H 00026 00027 #include <QString> 00028 #include <QList> 00029 00030 #include <klfdefs.h> 00031 00032 00033 class KLFFactoryManager; 00034 00036 00040 class KLF_EXPORT KLFFactoryBase 00041 { 00042 public: 00043 KLFFactoryBase(KLFFactoryManager *factoryManager); 00044 virtual ~KLFFactoryBase(); 00045 00047 virtual QStringList supportedTypes() const = 0; 00048 00049 private: 00050 KLFFactoryManager *pFactoryManager; 00051 }; 00052 00053 00055 00090 class KLF_EXPORT KLFFactoryManager 00091 { 00092 public: 00094 KLFFactoryManager(); 00096 virtual ~KLFFactoryManager(); 00097 00100 KLFFactoryBase * findFactoryFor(const QString& objType); 00101 00104 QStringList allSupportedTypes(); 00106 inline QList<KLFFactoryBase*> registeredFactories() { return pRegisteredFactories; } 00107 00108 private: 00110 QList<KLFFactoryBase*> pRegisteredFactories; 00111 00113 void registerFactory(KLFFactoryBase *factory); 00115 void unRegisterFactory(KLFFactoryBase *factory); 00116 00117 friend class KLFFactoryBase; 00118 }; 00119 00120 00121 00122 00123 #endif