Verified Commit 2f35040f authored by Romain De Laage De Bellefaye's avatar Romain De Laage De Bellefaye 🌳
Browse files

Compilation errors

parent a698a567
...@@ -39,7 +39,7 @@ class Database { ...@@ -39,7 +39,7 @@ class Database {
void initEnsEtat(Automate& a) const; void initEnsEtat(Automate& a) const;
void saveAutomaton(const Automate& a) const; void saveAutomaton(const Automate& a) const;
void saveFunction(const QString& name, const Fonction& f) const; void saveFunction(const QString& name, const Fonction& f) const;
void saveVoisinage(const QString& name, RegleVoisinage& r) const; void saveVoisinage(const QString& name, const RegleVoisinage& r) const;
void saveEnsemble(Automate& a) const; void saveEnsemble(Automate& a) const;
void initSingletonAutomate(const QString& modele) const; void initSingletonAutomate(const QString& modele) const;
}; };
......
...@@ -174,7 +174,8 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const { ...@@ -174,7 +174,8 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
regle->setr(query.value("rayon").toInt()); regle->setr(query.value("rayon").toInt());
return regle; return regle;
} else if(type == 2) { }
else if(type == 2) {
if(query.isNull("rayon")) if(query.isNull("rayon"))
throw "Error: r can't be undefined here"; throw "Error: r can't be undefined here";
...@@ -182,30 +183,31 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const { ...@@ -182,30 +183,31 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
regle->setr(query.value("rayon").toInt()); regle->setr(query.value("rayon").toInt());
return regle; return regle;
} else if(type != 3) { }
query.prepare("SELECT x, y FROM coord_voisinage WHERE id = :id"); else if(type != 3) {
query.bindValue(":id", name); query.prepare("SELECT x, y FROM coord_voisinage WHERE id = :id");
query.exec(); query.bindValue(":id", name);
query.exec();
if(!query.first())
throw "There must be at least one coord in this rule"; if(!query.first())
throw "There must be at least one coord in this rule";
RegleVoisinageArbitraire *regle = new RegleVoisinageArbitraire;
Coordonnees coord; RegleVoisinageArbitraire *regle = new RegleVoisinageArbitraire;
do { Coordonnees coord;
coord.x = query.value(0).toUInt(); do {
coord.y = query.value(1).toUInt(); coord.x = query.value(0).toUInt();
regle->coordonnees.push_back(coord); coord.y = query.value(1).toUInt();
} while(query.next()); regle->coordonnees.push_back(coord);
} while(query.next());
query.prepare("SELECT COUNT(*) FROM coord_voisinage WHERE id = :id");
query.bindValue(":id", name); query.prepare("SELECT COUNT(*) FROM coord_voisinage WHERE id = :id");
query.exec(); query.bindValue(":id", name);
query.exec();
regle->setNbVoisins(query.value(0).toUInt());
regle->setNbVoisins(query.value(0).toUInt());
return regle;
} return regle;
}
} }
/// Retourne un descriptif des réseaux ("id", "nom", "id", "nom", etc.) liés à un automate /// Retourne un descriptif des réseaux ("id", "nom", "id", "nom", etc.) liés à un automate
...@@ -412,7 +414,7 @@ void Database::saveVoisinage(const QString& name, const RegleVoisinage& r) const ...@@ -412,7 +414,7 @@ void Database::saveVoisinage(const QString& name, const RegleVoisinage& r) const
query.bindValue(":rayon", r.getr()); query.bindValue(":rayon", r.getr());
query.exec(); query.exec();
RegleVoisinageArbitraire& new_r = dynamic_cast<RegleVoisinageArbitraire&>(r); const RegleVoisinageArbitraire& new_r = dynamic_cast<const RegleVoisinageArbitraire&>(r);
for(size_t i = 0 ; i<new_r.coordonnees.size() ; i++) for(size_t i = 0 ; i<new_r.coordonnees.size() ; i++)
{ {
query.prepare("INSERT INTO coord_voisinage VALUES (:nom, :x, :y)"); query.prepare("INSERT INTO coord_voisinage VALUES (:nom, :x, :y)");
......
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