Commit 560af391 authored by Leon Do Castelo's avatar Leon Do Castelo
Browse files

push tables grilles (reseaux, cellules, ensembleetat, etats)

parent 59fb90b7
......@@ -13,8 +13,11 @@ Database::Database(std::string path): db(QSqlDatabase::addDatabase("QSQLITE")) {
db.exec("CREATE TABLE IF NOT EXISTS regles_transition (id VARCHAR(30) REFERENCES automate(nom) NOT NULL, min1 INTEGER, min2 INTEGER, min3 INTEGER, min4 INTEGER, min5 INTEGER, min6 INTEGER, min7 INTEGER, min8 INTEGER, max1 INTEGER, max2 INTEGER, max3 INTEGER, max4 INTEGER, max5 INTEGER, max6 INTEGER, max7 INTEGER, max8 INTEGER, courant INTEGER, destination INTEGER NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS regles_voisinage (id VARCHAR(30) PRIMARY KEY REFERENCES automates(nom), type INTEGER NOT NULL, rayon INTEGER)");
db.exec("CREATE TABLE IF NOT EXISTS coord_voisinage (id VARCHAR(30) REFERENCES automates(nom) NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS reseaux (id INTEGER PRIMARY KEY, nom VARCHAR(30) NOT NULL, h INTEGER NOT NULL, l INTEGER NOT NULL, automate VARCHAR(30) REFERENCES automates(nom) NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS EnsembleEtats (id INTEGER PRIMARY KEY, reseau INTEGER REFERENCES reseau(id) NOT NULL,UNIQUE(reseau))");
db.exec("CREATE TABLE IF NOT EXISTS Etats (ensemble INTEGER REFERENCES EnsembleEtats(id) NOT NULL, indice INTEGER NOT NULL, label VARCHAR NOT NULL, r INTEGER NOT NULL, g INTEGER NOT NULL, b INTEGER NOT NULL, CHECK(indice>=0), CHECK(r>=0), CHECK(r<=255), CHECK(g>=0), CHECK(g<=255), CHECK(b>=0), CHECK(b<=255), PRIMARY KEY (ensemble, indice))");
db.exec("CREATE TABLE IF NOT EXISTS Cellules (reseau INTEGER REFERENCES reseau(id) NOT NULL, ensemble INTEGER REFERENCES EnsembleEtats(id) NOT NULL, etat INTEGER REFERENCES Etats(indice) NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL);");
}
db.exec("CREATE TABLE IF NOT EXISTS reseaux (id INTEGER PRIMARY KEY, nom VARCHAR(30), h INTEGER, l INTEGER, nbEtats INTEGER, reseau JSON)");
std::vector<QString> Database::getAutomates() const {
QSqlQuery query = db.exec("SELECT nom FROM automates");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment