Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain De Laage De Bellefaye
LO21-projet
Commits
2f35040f
Verified
Commit
2f35040f
authored
Jun 11, 2021
by
Romain De Laage De Bellefaye
🌳
Browse files
Compilation errors
parent
a698a567
Changes
2
Hide whitespace changes
Inline
Side-by-side
includes/autosql.h
View file @
2f35040f
...
...
@@ -39,7 +39,7 @@ class Database {
void
initEnsEtat
(
Automate
&
a
)
const
;
void
saveAutomaton
(
const
Automate
&
a
)
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
initSingletonAutomate
(
const
QString
&
modele
)
const
;
};
...
...
src/autosql.cpp
View file @
2f35040f
...
...
@@ -174,7 +174,8 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
regle
->
setr
(
query
.
value
(
"rayon"
).
toInt
());
return
regle
;
}
else
if
(
type
==
2
)
{
}
else
if
(
type
==
2
)
{
if
(
query
.
isNull
(
"rayon"
))
throw
"Error: r can't be undefined here"
;
...
...
@@ -182,30 +183,31 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
regle
->
setr
(
query
.
value
(
"rayon"
).
toInt
());
return
regle
;
}
else
if
(
type
!=
3
)
{
query
.
prepare
(
"SELECT x, y FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
if
(
!
query
.
first
())
throw
"There must be at least one coord in this rule"
;
RegleVoisinageArbitraire
*
regle
=
new
RegleVoisinageArbitraire
;
Coordonnees
coord
;
do
{
coord
.
x
=
query
.
value
(
0
).
toUInt
();
coord
.
y
=
query
.
value
(
1
).
toUInt
();
regle
->
coordonnees
.
push_back
(
coord
);
}
while
(
query
.
next
());
query
.
prepare
(
"SELECT COUNT(*) FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
regle
->
setNbVoisins
(
query
.
value
(
0
).
toUInt
());
return
regle
;
}
}
else
if
(
type
!=
3
)
{
query
.
prepare
(
"SELECT x, y FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
if
(
!
query
.
first
())
throw
"There must be at least one coord in this rule"
;
RegleVoisinageArbitraire
*
regle
=
new
RegleVoisinageArbitraire
;
Coordonnees
coord
;
do
{
coord
.
x
=
query
.
value
(
0
).
toUInt
();
coord
.
y
=
query
.
value
(
1
).
toUInt
();
regle
->
coordonnees
.
push_back
(
coord
);
}
while
(
query
.
next
());
query
.
prepare
(
"SELECT COUNT(*) FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
regle
->
setNbVoisins
(
query
.
value
(
0
).
toUInt
());
return
regle
;
}
}
/// 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
query
.
bindValue
(
":rayon"
,
r
.
getr
());
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
++
)
{
query
.
prepare
(
"INSERT INTO coord_voisinage VALUES (:nom, :x, :y)"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment