Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (2,49 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
aa44e7d1 Christian Ehringfeld
#include <QObject>
57d6da31 Christian Ehringfeld
#include <QSharedPointer>
7e233492 Christian Ehringfeld
#include <QStringList>
402ef73e Christian Ehringfeld
#include "relation.h"
fc14f551 Christian Ehringfeld
#include "validators/validatorrule.h"
#include "validators/errormsg.h"
6899f814 Christian Ehringfeld
namespace CuteEntityManager {
81c23b56 Christian Ehringfeld
9c2f773f Christian Ehringfeld
/**
e332a521 Christian Ehringfeld
* You must not 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
*/
402ef73e Christian Ehringfeld
class ValidationRule;
class ErrorMsg;
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
612083d3 Christian Ehringfeld
signals:
d933d48e Christian Ehringfeld
void idChanged();
9d05e414 Christian Ehringfeld
612083d3 Christian Ehringfeld
public:
d933d48e Christian Ehringfeld
virtual QString toString() const;
402ef73e Christian Ehringfeld
/**
* @brief copy
* depends on Q_PROPERTIES
* Copies them with exceptions of primary key(mostly "id") and objectName
* @return
*/
virtual Entity* copy() const;
d933d48e Christian Ehringfeld
virtual ~Entity();
fc14f551 Christian Ehringfeld
virtual QList<ValidationRule> validationRules() const;
d933d48e Christian Ehringfeld
virtual QString getTablename() const;
23337ecc Christian Ehringfeld
virtual QString getClassname() const;
d933d48e Christian Ehringfeld
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);

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