Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (2,42 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>
#include <QDebug>
aa44e7d1 Christian Ehringfeld
#include <QObject>
813205af Christian Ehringfeld
#include <QMetaProperty>
24c5480c Christian Ehringfeld
#include "relation.h"
7e233492 Christian Ehringfeld
#include <QStringList>
6899f814 Christian Ehringfeld
namespace CuteEntityManager {
81c23b56 Christian Ehringfeld
9c2f773f Christian Ehringfeld
/**
* You should name any persisted property objectName, because its pre used by Qt and will be ignored by Entity Manager
* @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:
void idChanged();
9d05e414 Christian Ehringfeld
426974c6 Christian Ehringfeld
public:
9d05e414 Christian Ehringfeld
Entity (QObject *parent = 0);
virtual QString toString();
81c23b56 Christian Ehringfeld
virtual ~Entity();
caea9141 Christian Ehringfeld
virtual QString getTablename();
a47954c0 Christian Ehringfeld
/**
* Relation with BELONGS_TO should use qint32 as primary key
* @brief getRelations
* @return
*/
24425325 Christian Ehringfeld
virtual QHash<QString, Relation> getRelations();
813205af Christian Ehringfeld
/**
* The hashmap keys must be equal to the ones which are defined in the hashmap of getRelations()
* The EntityManager will only introspect Entity Objects, non-Entity inherited relations will be processed in a other way
* You must use this method, if you have a n-n Relation with Entity Objects.
* @brief getRelationObjects
* @return
*/
virtual QHash<QString, QSharedPointer<Entity> > getRelationObjects();
7e233492 Christian Ehringfeld
/**
* You should return the names of properties which should not persisted e.g. Properties which are only exposed to qml
* @brief getTransientAttributes
* @return
*/
virtual QStringList getTransientAttributes();
24c5480c Christian Ehringfeld
virtual QStringList getBLOBColumns();
//return value must be the exact name defined in Q_PROPERTY
virtual QString getPrimaryKey();
813205af Christian Ehringfeld
QHash<QString, QMetaProperty> getMetaProperties();
586bb527 Christian Ehringfeld
813205af Christian Ehringfeld
qint64 getId() const;
void setId(const qint64 &value);
24c5480c Christian Ehringfeld
813205af Christian Ehringfeld
protected:
qint64 id;
81c23b56 Christian Ehringfeld
};
}
586bb527 Christian Ehringfeld
#endif // ENTITY_H