Herunterladen als
root/src/entityinstancefactory.h @ 696666eb
c22391b2 | Christian Ehringfeld | /*
|
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|||
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program is distributed in the hope that it will be useful, but
|
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
f4e3904b | Christian Ehringfeld | #ifndef ENTITYINSTANCEFACTORY_H
|
|
#define ENTITYINSTANCEFACTORY_H
|
|||
#include <QString>
|
|||
#include <QVariant>
|
|||
#include <QHash>
|
|||
namespace CuteEntityManager {
|
|||
class Entity;
|
|||
class EntityInstanceFactory {
|
|||
public:
|
|||
static Entity *createInstance(const char *className);
|
|||
d568923d | Christian Ehringfeld | static Entity *createInstance(const QString &className);
|
|
bb5e9339 | SebastianDiel | static Entity *createInstance(int metaTypeId);
|
|
e0e1ead8 | Christian Ehringfeld | static Entity *createInstance(const char *className,
|
|
const QHash<QString, QVariant> &attributes);
|
|||
47f9301a | Christian Ehringfeld | static Entity *setAttributes(Entity *e,
|
|
const QHash<QString, QVariant> &attributes,
|
|||
a205e8a9 | Christian Ehringfeld | QHash<QString, QMetaProperty> metaprops);
|
|
47f9301a | Christian Ehringfeld | static Entity *setAttributes(Entity *e,
|
|
const QHash<QString, QVariant> &attributes);
|
|||
2d9fab10 | Christian Ehringfeld | static const QString extractEntityType(const QString &s);
|
|
a1389432 | Christian Ehringfeld | static Entity *newSuperClassInstance(const Entity *e);
|
|
a205e8a9 | Christian Ehringfeld | ||
template<typename T>
|
|||
static Entity *createInstance() {
|
|||
return EntityInstanceFactory::createInstance(qMetaTypeId<T>());
|
|||
}
|
|||
f4e3904b | Christian Ehringfeld | protected:
|
|
EntityInstanceFactory();
|
|||
};
|
|||
}
|
|||
#endif // ENTITYINSTANCEFACTORY_H
|