Warning, file /multimedia/amarok/src/playlistgenerator/ConstraintFactory.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /**************************************************************************************** 0002 * Copyright (c) 2008-2010 Soren Harward <stharward@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef APG_CONSTRAINT_FACTORY 0018 #define APG_CONSTRAINT_FACTORY 0019 0020 #include <QDomElement> 0021 #include <QHash> 0022 #include <QPair> 0023 #include <QString> 0024 #include <QStringList> 0025 0026 #include <climits> 0027 0028 class Constraint; 0029 class ConstraintNode; 0030 0031 class ConstraintFactoryEntry { 0032 public: 0033 friend class ConstraintFactory; 0034 ConstraintFactoryEntry(const QString&, 0035 const QString&, 0036 const QString&, 0037 Constraint* (*xmlf)(QDomElement&, ConstraintNode*), 0038 Constraint* (*nf)(ConstraintNode*)); 0039 0040 private: 0041 const QString m_name; 0042 const QString m_i18nName; 0043 const QString m_description; 0044 Constraint* (*m_createFromXmlFunc)(QDomElement&, ConstraintNode*); 0045 Constraint* (*m_createNewFunc)(ConstraintNode*); 0046 }; 0047 0048 class ConstraintFactory { 0049 public: 0050 static ConstraintFactory* instance(); 0051 static void destroy(); 0052 ~ConstraintFactory(); 0053 0054 // row is set to INT_MAX so that children are appended by default 0055 ConstraintNode* createConstraint(QDomElement&, ConstraintNode*, int row=INT_MAX) const; 0056 ConstraintNode* createConstraint(const QString&, ConstraintNode*, int row=INT_MAX) const; 0057 ConstraintNode* createConstraint(const int, ConstraintNode*, int row=INT_MAX) const; 0058 0059 ConstraintNode* createGroup(QDomElement&, ConstraintNode*, int row=INT_MAX) const; 0060 ConstraintNode* createGroup(ConstraintNode*, int row=INT_MAX) const; 0061 0062 const QStringList names() const; 0063 const QStringList i18nNames() const; 0064 QList< QPair<int, QString> > registeredConstraints() const; 0065 const QString untranslateName( const QString& ) const; 0066 0067 private: 0068 ConstraintFactory(); 0069 0070 static ConstraintFactory* s_self; 0071 QHash<int, ConstraintFactoryEntry*> m_registryIds; 0072 QHash<QString, ConstraintFactoryEntry*> m_registryNames; 0073 QHash<QString, QString> m_registryUntranslateNames; 0074 }; 0075 0076 #endif // APG_CONSTRAINT_FACTORY