Herunterladen als
root/example/main.cpp @ 6d91d381
81c23b56 | Christian Ehringfeld | #include <QCoreApplication>
|
|
#include <typeinfo>
|
|||
#include <QDir>
|
|||
#include <QDebug>
|
|||
9d05e414 | Christian Ehringfeld | #include "models/artikel.h"
|
|
#include "models/person.h"
|
|||
#include <typeinfo>
|
|||
#include <QMetaMethod>
|
|||
#include <QMetaProperty>
|
|||
#include "models/group.h"
|
|||
bb5e9339 | SebastianDiel | #include "../src/entity.h"
|
|
#include "../src/entitymanager.h"
|
|||
2d9fab10 | Christian Ehringfeld | #include "../src/relation.h"
|
|
9d05e414 | Christian Ehringfeld | #include <QGenericReturnArgument>
|
|
2d9fab10 | Christian Ehringfeld | #include "entityinstancefactory.h"
|
|
ba6f6521 | Christian Ehringfeld | #include <exception>
|
|
#include "models/pupil.h"
|
|||
81c23b56 | Christian Ehringfeld | /**
|
|
* create,remove und merge funktionieren
|
|||
*/
|
|||
2d9fab10 | Christian Ehringfeld | using namespace CuteEntityManager;
|
|
9d05e414 | Christian Ehringfeld | int main(int argc, char *argv[]) {
|
|
6d91d381 | Christian Ehringfeld | Q_UNUSED(argc) Q_UNUSED(argv)
|
|
696666eb | Christian Ehringfeld | CuteEntityManager::EntityManager *e = new
|
|
CuteEntityManager::EntityManager("QSQLITE",
|
|||
QDir::currentPath() + "/db.sqlite");
|
|||
QSharedPointer<Artikel> a = QSharedPointer<Artikel>(new Artikel(20.0,
|
|||
"Müsli"));
|
|||
auto ep = a.dynamicCast<CuteEntityManager::Entity>();
|
|||
qDebug() << "Tabelle artikel erstellt:" << e->createTable(ep);
|
|||
e->create(ep);
|
|||
6d91d381 | Christian Ehringfeld | auto artikel = e->findById<Artikel *>(1);
|
|
2d9fab10 | Christian Ehringfeld | // QSharedPointer<CuteEntityManager::Entity> p = QSharedPointer<CuteEntityManager::Entity>(new Person("Max", "Mustermann", Person::MALE, "", "", "",
|
|
// QDate::currentDate()));
|
|||
// auto pptr = p.dynamicCast<CuteEntityManager::Entity>();
|
|||
// e->createTable(pptr);
|
|||
// e->create(pptr);
|
|||
//e->createTable(grp.dynamicCast<CuteEntityManager::Entity>());
|
|||
586bb527 | Christian Ehringfeld | ||
ba6f6521 | Christian Ehringfeld | // QTime t;
|
|
// t.start();
|
|||
// e->createTable(QSharedPointer<Artikel>(new Artikel()));
|
|||
// for (int var = 0; var < 10; ++var) {
|
|||
// QSharedPointer<Entity> a = QSharedPointer<Artikel>(new Artikel(var,QString("a")+QString::number(var)));
|
|||
// e->save(a);
|
|||
// }
|
|||
// qDebug() << "Dauer:" << t.elapsed();
|
|||
6d91d381 | Christian Ehringfeld | //QSharedPointer<Artikel> aPtr = QSharedPointer<Artikel>(entity);
|
|
ba6f6521 | Christian Ehringfeld | Pupil *p = new Pupil();
|
|
1a3b37ba | Christian Ehringfeld | // auto iterator = hash.constBegin();
|
|
// while(iterator != hash.constEnd()) {
|
|||
// qDebug() << iterator.key() << " Value:" << iterator.value().read(p);
|
|||
// iterator++;
|
|||
// }
|
|||
ba6f6521 | Christian Ehringfeld | ||
81c23b56 | Christian Ehringfeld | return 0;
|
|
}
|