00001 /*************************************************************************** 00002 * file klffactory.h 00003 * This file is part of the KLatexFormula Project. 00004 * Copyright (C) 2011 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$ */ 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 00091 class KLF_EXPORT KLFFactoryManager 00092 { 00093 public: 00095 KLFFactoryManager(); 00097 virtual ~KLFFactoryManager(); 00098 00101 KLFFactoryBase * findFactoryFor(const QString& objType); 00102 00105 QStringList allSupportedTypes(); 00107 inline QList<KLFFactoryBase*> registeredFactories() { return pRegisteredFactories; } 00108 00109 private: 00111 QList<KLFFactoryBase*> pRegisteredFactories; 00112 00114 void registerFactory(KLFFactoryBase *factory); 00116 void unRegisterFactory(KLFFactoryBase *factory); 00117 00118 friend class KLFFactoryBase; 00119 }; 00120 00121 00122 00123 00124 #endif