Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (2,66 KB) Statistiken
| Zweig: | Revision:
11f5a3a7 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/>.
*/
93285804 Christian Ehringfeld
#ifndef ENTITYINSPECTOR_H
#define ENTITYINSPECTOR_H
40cf6a8c SebastianDiel
#define DIFFABLEOUTPUT
e332a521 Christian Ehringfeld
#include <QString>
#include <QHash>
#include "entity.h"
#include "entityhelper.h"
#include "entityinstancefactory.h"
#include "logger.h"
93285804 Christian Ehringfeld
e332a521 Christian Ehringfeld
namespace CuteEntityManager {
93285804 Christian Ehringfeld
e332a521 Christian Ehringfeld
/**
* @brief The EntityInspector class
43457c84 Christian Ehringfeld
* This class can check entities for errors.
e332a521 Christian Ehringfeld
*/
class EntityInspector {
public:
6bd57432 Christian Ehringfeld
explicit EntityInspector(const MsgType msgType = MsgType::DEBUG);
e332a521 Christian Ehringfeld
~EntityInspector();
bool checkRegisteredEntities();
bool checkEntity(QString name);
93285804 Christian Ehringfeld
e332a521 Christian Ehringfeld
private:
f12670e9 Christian Ehringfeld
Entity *instantiateEntity(const QString name);
bool verifyRelations(Entity *&entity);
void verifyTransientAttributes(Entity *&entity);
bool checkRelation(const QVariant &entity, const Relation &r,
e332a521 Christian Ehringfeld
const QMetaProperty &property) const;
f12670e9 Christian Ehringfeld
void checkRelationTypos(const QString &name, const Relation &r,
43457c84 Christian Ehringfeld
bool &ok);
void checkRelationMappings(QMetaProperty &property, const Relation &r,
4d57a79b Christian Ehringfeld
bool &ok, Entity *&entity);
f12670e9 Christian Ehringfeld
bool checkPrimaryKey(Entity *&entity);
void verifyBlobAttributes(Entity *&entity);
e332a521 Christian Ehringfeld
void checkMetaProperties(QHash<QString, QMetaProperty> &metaProperties,
f12670e9 Christian Ehringfeld
bool &ok, QHash<QString, Relation> &relations);
ea09b5be Christian Ehringfeld
void checkNotMappedByAttributes(int foundMappedBy, bool &ok,
const QString &propertyName, const QString &foreignEntity);
void checkRelationTypes(const Relation &r, const Relation &foreign, bool &ok);
void logRelationTypeErrorMsg(const QString &type, const Relation &r,
const Relation &foreign);
void analyzeForeignRelations(const Relation &r, const Entity *const entity,
const Entity *const foreignInstance, bool &ok, int &foundMappedBy,
bool &foundForeignMappedRelation, bool &bothSidedMappedBy);
f12670e9 Christian Ehringfeld
void initLogger(const MsgType msgType);
e332a521 Christian Ehringfeld
Logger *logger = nullptr;
93285804 Christian Ehringfeld
};
e332a521 Christian Ehringfeld
}
93285804 Christian Ehringfeld
#endif // ENTITYINSPECTOR_H