Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (2,34 KB) Statistiken
| Zweig: | Revision:
81c23b56 Christian Ehringfeld
/*
6899f814 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/>.
*/
81c23b56 Christian Ehringfeld
586bb527 Christian Ehringfeld
#ifndef ENTITY_H
#define ENTITY_H
81c23b56 Christian Ehringfeld
#include <QtGlobal>
#include <QMap>
aa44e7d1 Christian Ehringfeld
#include <QObject>
813205af Christian Ehringfeld
#include <QMetaProperty>
24c5480c Christian Ehringfeld
#include "relation.h"
7e233492 Christian Ehringfeld
#include <QStringList>
97f9a843 Christian Ehringfeld
#include <QSharedPointer>
2e43da3f Christian Ehringfeld
#include <QStack>
#include <QQueue>
47f9301a Christian Ehringfeld
#include "entityinstancefactory.h"
fc14f551 Christian Ehringfeld
#include "validators/validatorrule.h"
#include "validators/errormsg.h"
6899f814 Christian Ehringfeld
namespace CuteEntityManager {
81c23b56 Christian Ehringfeld
9c2f773f Christian Ehringfeld
/**
ba800d6d Christian Ehringfeld
* You mustn't name any persisted property objectName, because its pre used by Qt and will be ignored by Entity Manager
9c2f773f Christian Ehringfeld
* @brief The Entity class
*/
aa44e7d1 Christian Ehringfeld
class Entity : public QObject {
Q_OBJECT
24c5480c Christian Ehringfeld
Q_PROPERTY(qint64 id READ getId WRITE setId NOTIFY idChanged)
9d05e414 Christian Ehringfeld
586bb527 Christian Ehringfeld
signals:
d933d48e Christian Ehringfeld
void idChanged();
9d05e414 Christian Ehringfeld
426974c6 Christian Ehringfeld
public:
d933d48e Christian Ehringfeld
virtual QString toString() const;
virtual ~Entity();
fc14f551 Christian Ehringfeld
virtual QList<ValidationRule> validationRules() const;
d933d48e Christian Ehringfeld
virtual QString getTablename() const;
virtual const QHash<QString, Relation> getRelations() const;
virtual const QStringList getTransientAttributes() const;
virtual const QStringList getBLOBColumns() const;
virtual InheritanceStrategy getInheritanceStrategy() const;
virtual bool isInheritanceCascaded() const;
24c5480c Christian Ehringfeld
//return value must be the exact name defined in Q_PROPERTY
d933d48e Christian Ehringfeld
virtual QString getPrimaryKey() const;
abb9e8c5 Christian Ehringfeld
d933d48e Christian Ehringfeld
QVariant getProperty(const QString &name) const;
bool setProperty(const QString &name, const QVariant &value);
qint64 getId() const;
void setId(const qint64 &value);
24c5480c Christian Ehringfeld
fc14f551 Christian Ehringfeld
bool hasErrors() const;

QList<ErrorMsg> getErrors() const;
e80feccc Christian Ehringfeld
QString getErrorsAsString() const;
fc14f551 Christian Ehringfeld
void setErrors(const QList<ErrorMsg> &value);

protected:
dfaffebe Christian Ehringfeld
explicit Entity (QObject *parent = 0);
d933d48e Christian Ehringfeld
virtual QString slimToString() const;
fc14f551 Christian Ehringfeld
QList<ErrorMsg> errors;
813205af Christian Ehringfeld
qint64 id;
81c23b56 Christian Ehringfeld
};
}
586bb527 Christian Ehringfeld
#endif // ENTITY_H