Skip to content
GitLab
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
8090e919
Verified
Commit
8090e919
authored
Jun 09, 2021
by
Romain De Laage De Bellefaye
🌳
Browse files
Fix a few mistakes to compile
parent
db6249e9
Changes
5
Hide whitespace changes
Inline
Side-by-side
includes/Automate.h
View file @
8090e919
...
...
@@ -25,7 +25,7 @@ class Automate {
std
::
string
author
;
std
::
string
desc
;
Automate
()
:
delai
(
500
),
fonction
(
nullptr
),
regleVoisinage
(
nullptr
),
itBuffer
(
buffer
.
begin
()),
h
(
0
),
l
(
0
),
title
(
""
),
reseauInit
(
Reseau
(
0
,
0
))
{
timer
.
automate
=
this
;
}
Automate
()
:
title
(
""
),
delai
(
500
),
fonction
(
nullptr
),
regleVoisinage
(
nullptr
),
itBuffer
(
buffer
.
begin
()),
h
(
0
),
l
(
0
),
reseauInit
(
Reseau
(
0
,
0
))
,
year
(
2000
),
author
(
"Anonym"
),
desc
(
""
)
{
timer
.
automate
=
this
;
}
Automate
(
const
Automate
&
a
)
=
delete
;
Automate
&
operator
=
(
const
Automate
&
a
)
=
delete
;
class
Timer
:
public
QObject
{
...
...
@@ -69,11 +69,11 @@ class Automate {
/// Définir la fonction de transition de l'automate, le cycle de vie de la focntion est géré par l'utilisateur
void
setFonction
(
Fonction
&
f
)
{
fonction
=
&
f
;
}
/// Récupérer la fonction de transition
const
Fonction
&
getFonction
()
{
return
*
fonction
;
}
const
Fonction
&
getFonction
()
const
{
return
*
fonction
;
}
/// Définir une règle de voisinage, le cycle de vie de la règle est géré par l'utilisateur
void
setRegleVoisinage
(
RegleVoisinage
&
r
)
{
regleVoisinage
=
&
r
;
}
/// Récupérer la règle de voisinage
const
RegleVoisinage
&
getRegleVoisinage
()
{
return
*
regleVoisinage
;
}
const
RegleVoisinage
&
getRegleVoisinage
()
const
{
return
*
regleVoisinage
;
}
/// Définir le délai entre 2 itérations de l'automate en mode Timer
void
setDelai
(
const
unsigned
int
d
)
{
delai
=
d
;
}
...
...
@@ -118,7 +118,7 @@ class Automate {
/// Définir le réseau initial de l'automate
void
setReseauInit
(
Reseau
&
r
)
{
reseauInit
=
r
;
}
/// Récupérer le réseau initial de l'automate
Reseau
&
getReseauInit
()
{
return
reseauInit
;
}
const
Reseau
&
getReseauInit
()
const
{
return
reseauInit
;
}
/// Récupérer le nom de l'automate
std
::
string
getTitle
()
const
{
return
title
;
}
/// Redéfinir le nom de l'automate
...
...
includes/autosql.h
View file @
8090e919
...
...
@@ -8,6 +8,7 @@
#include
<QVariant>
#include
<Fonction.h>
#include
<voisinage.h>
#include
<Automate.h>
/// Cette classe adapte un objet base de données pour le rendre facile d'utilisation dans le cadre de l'application
///
...
...
@@ -23,7 +24,7 @@ class Database {
RegleVoisinage
*
getRegleVoisinage
(
const
QString
&
name
)
const
;
std
::
vector
<
QString
>
getListeReseaux
(
const
QString
&
name
)
const
;
Reseau
&
getReseau
(
int
idReseau
)
const
;
void
stockerReseau
(
Reseau
&
reseau
,
QString
nomReseau
,
QString
nomAutomate
)
const
;
void
stockerReseau
(
const
Reseau
&
reseau
,
const
QString
&
nomReseau
,
const
QString
&
nomAutomate
)
const
;
void
initEnsEtat
(
const
QString
&
name
)
const
;
void
saveAutomaton
(
const
Automate
&
a
)
const
;
void
saveFunction
(
const
QString
&
name
,
const
Fonction
&
f
)
const
;
...
...
includes/reseau_cellule_etats.h
View file @
8090e919
...
...
@@ -38,7 +38,7 @@ private:
public:
std
::
string
getLabel
(){
return
label
;}
QColor
getColor
(){
return
color
;}
unsigned
int
getIndice
()
{
return
indice
;
}
unsigned
int
getIndice
()
const
{
return
indice
;
}
};
...
...
includes/voisinage.h
View file @
8090e919
...
...
@@ -32,7 +32,7 @@ public:
class
VoisinageIterator
{
const
Voisinage
*
vsn
;
in
t
i
;
size_
t
i
;
public
:
VoisinageIterator
(
const
Voisinage
*
v
){
...
...
@@ -40,7 +40,7 @@ public:
}
void
first
(){
i
=
0
;
i
=
0
;
}
void
next
(){
...
...
@@ -69,6 +69,8 @@ class RegleVoisinage{
public
:
virtual
void
calculVoisinage
(
Voisinage
&
v
,
const
Reseau
&
r
)
const
=
0
;
virtual
int
getType
()
const
=
0
;
/// Renvoie le rayon d'une règle de voisinage, 0 si ce n'est pas pertinant pour ce voisinage (arbitraire, ...)
virtual
unsigned
int
getr
()
const
{
return
0
;
}
};
class
RegleVoisinageNeumann
:
public
RegleVoisinage
{
...
...
src/autosql.cpp
View file @
8090e919
...
...
@@ -283,127 +283,127 @@ Reseau& Database::getReseau(int idReseau) const
void
Database
::
saveAutomaton
(
const
Automate
&
a
)
const
{
QSqlQuery
query
(
db
);
query
.
prepare
(
"INSERT INTO automates (nom, defaut, description, auteur, annee) VALUES (:nom, :etatDefaut, :description, :auteur, :annee)"
);
query
.
bind
(
":nom"
,
a
.
getTitle
());
query
.
bind
(
":etatDefaut"
,
a
.
getFonction
().
getEtatDefaut
());
query
.
bind
(
":description"
,
a
.
getDesc
ription
());
query
.
bind
(
":auteur"
,
a
.
getAut
eu
r
());
query
.
bind
(
":annee"
,
a
.
get
Annee
());
query
.
bind
Value
(
":nom"
,
a
.
getTitle
()
.
c_str
()
);
query
.
bind
Value
(
":etatDefaut"
,
a
.
getFonction
().
getEtatDefaut
()
.
getIndice
()
);
query
.
bind
Value
(
":description"
,
a
.
getDesc
().
c_str
());
query
.
bind
Value
(
":auteur"
,
a
.
getAut
hor
().
c_st
r
());
query
.
bind
Value
(
":annee"
,
a
.
get
Year
());
query
.
exec
();
saveFunction
(
a
.
getTitle
(),
a
.
getFonction
());
saveVoisinage
(
a
.
getTitle
(),
a
.
getRegleVoisinage
());
stockerReseau
(
a
.
getReseauInit
(),
"To be determined"
,
a
.
getTitle
());
saveFunction
(
a
.
getTitle
()
.
c_str
()
,
a
.
getFonction
());
saveVoisinage
(
a
.
getTitle
()
.
c_str
()
,
a
.
getRegleVoisinage
());
stockerReseau
(
a
.
getReseauInit
(),
"To be determined"
,
a
.
getTitle
()
.
c_str
()
);
}
void
Database
::
saveFunction
(
const
QString
&
name
,
const
Fonction
&
f
)
const
{
QSqlQuery
query
(
db
);
for
(
auto
rule
:
f
.
getRules
())
{
query
.
prepare
(
"INSERT INTO regles_transition VALUES (:name, :min1, :min2, :min3, :min4, :min5, :min6, :min7, :min8, :max1, :max2, :max3, :max4, :max5, :max6, :max7, :max8, :courant, :dest)"
);
query
.
bind
(
":name"
,
name
);
query
.
bind
(
":dest"
,
static_cast
<
int
>
(
rule
->
getDestination
().
getIndice
()));
if
(
rule
.
getCourant
()
!=
-
1
)
{
query
.
bind
(
":courant"
,
rule
.
getCourant
());
query
.
bind
Value
(
":name"
,
name
);
query
.
bind
Value
(
":dest"
,
static_cast
<
int
>
(
rule
->
getDestination
().
getIndice
()));
if
(
rule
->
getCourant
()
!=
-
1
)
{
query
.
bind
Value
(
":courant"
,
rule
->
getCourant
());
}
else
{
// NULL value
query
.
bind
(
":courant"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":courant"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
1
)
!=
-
1
)
{
query
.
bind
(
":min1"
,
rule
.
getMin
(
1
));
if
(
rule
->
getMin
(
1
)
!=
-
1
)
{
query
.
bind
Value
(
":min1"
,
rule
->
getMin
(
1
));
}
else
{
// NULL value
query
.
bind
(
":min1"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min1"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
2
)
!=
-
1
)
{
query
.
bind
(
":min2"
,
rule
.
getMin
(
2
));
if
(
rule
->
getMin
(
2
)
!=
-
1
)
{
query
.
bind
Value
(
":min2"
,
rule
->
getMin
(
2
));
}
else
{
// NULL value
query
.
bind
(
":min2"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min2"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
3
)
!=
-
1
)
{
query
.
bind
(
":min3"
,
rule
.
getMin
(
3
));
if
(
rule
->
getMin
(
3
)
!=
-
1
)
{
query
.
bind
Value
(
":min3"
,
rule
->
getMin
(
3
));
}
else
{
// NULL value
query
.
bind
(
":min3"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min3"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
4
)
!=
-
1
)
{
query
.
bind
(
":min4"
,
rule
.
getMin
(
4
));
if
(
rule
->
getMin
(
4
)
!=
-
1
)
{
query
.
bind
Value
(
":min4"
,
rule
->
getMin
(
4
));
}
else
{
// NULL value
query
.
bind
(
":min4"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min4"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
5
)
!=
-
1
)
{
query
.
bind
(
":min5"
,
rule
.
getMin
(
5
));
if
(
rule
->
getMin
(
5
)
!=
-
1
)
{
query
.
bind
Value
(
":min5"
,
rule
->
getMin
(
5
));
}
else
{
// NULL value
query
.
bind
(
":min5"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min5"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
6
)
!=
-
1
)
{
query
.
bind
(
":min6"
,
rule
.
getMin
(
6
));
if
(
rule
->
getMin
(
6
)
!=
-
1
)
{
query
.
bind
Value
(
":min6"
,
rule
->
getMin
(
6
));
}
else
{
// NULL value
query
.
bind
(
":min6"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min6"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
7
)
!=
-
1
)
{
query
.
bind
(
":min7"
,
rule
.
getMin
(
7
));
if
(
rule
->
getMin
(
7
)
!=
-
1
)
{
query
.
bind
Value
(
":min7"
,
rule
->
getMin
(
7
));
}
else
{
// NULL value
query
.
bind
(
":min7"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min7"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMin
(
8
)
!=
-
1
)
{
query
.
bind
(
":min8"
,
rule
.
getMin
(
8
));
if
(
rule
->
getMin
(
8
)
!=
-
1
)
{
query
.
bind
Value
(
":min8"
,
rule
->
getMin
(
8
));
}
else
{
// NULL value
query
.
bind
(
":min8"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":min8"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
1
)
!=
-
1
)
{
query
.
bind
(
":max1"
,
rule
.
getMax
(
1
));
if
(
rule
->
getMax
(
1
)
!=
-
1
)
{
query
.
bind
Value
(
":max1"
,
rule
->
getMax
(
1
));
}
else
{
// NULL value
query
.
bind
(
":max1"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max1"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
2
)
!=
-
1
)
{
query
.
bind
(
":max2"
,
rule
.
getMax
(
2
));
if
(
rule
->
getMax
(
2
)
!=
-
1
)
{
query
.
bind
Value
(
":max2"
,
rule
->
getMax
(
2
));
}
else
{
// NULL value
query
.
bind
(
":max2"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max2"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
3
)
!=
-
1
)
{
query
.
bind
(
":max3"
,
rule
.
getMax
(
3
));
if
(
rule
->
getMax
(
3
)
!=
-
1
)
{
query
.
bind
Value
(
":max3"
,
rule
->
getMax
(
3
));
}
else
{
// NULL value
query
.
bind
(
":max3"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max3"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
4
)
!=
-
1
)
{
query
.
bind
(
":max4"
,
rule
.
getMax
(
4
));
if
(
rule
->
getMax
(
4
)
!=
-
1
)
{
query
.
bind
Value
(
":max4"
,
rule
->
getMax
(
4
));
}
else
{
// NULL value
query
.
bind
(
":max4"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max4"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
5
)
!=
-
1
)
{
query
.
bind
(
":max5"
,
rule
.
getMax
(
5
));
if
(
rule
->
getMax
(
5
)
!=
-
1
)
{
query
.
bind
Value
(
":max5"
,
rule
->
getMax
(
5
));
}
else
{
// NULL value
query
.
bind
(
":max5"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max5"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
6
)
!=
-
1
)
{
query
.
bind
(
":max6"
,
rule
.
getMax
(
6
));
if
(
rule
->
getMax
(
6
)
!=
-
1
)
{
query
.
bind
Value
(
":max6"
,
rule
->
getMax
(
6
));
}
else
{
// NULL value
query
.
bind
(
":max6"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max6"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
7
)
!=
-
1
)
{
query
.
bind
(
":max7"
,
rule
.
getMax
(
7
));
if
(
rule
->
getMax
(
7
)
!=
-
1
)
{
query
.
bind
Value
(
":max7"
,
rule
->
getMax
(
7
));
}
else
{
// NULL value
query
.
bind
(
":max7"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max7"
,
QVariant
(
QVariant
::
Int
));
}
if
(
rule
.
getMax
(
8
)
!=
-
1
)
{
query
.
bind
(
":max8"
,
rule
.
getMax
(
8
));
if
(
rule
->
getMax
(
8
)
!=
-
1
)
{
query
.
bind
Value
(
":max8"
,
rule
->
getMax
(
8
));
}
else
{
// NULL value
query
.
bind
(
":max8"
,
QVariant
(
QVariant
::
Int
));
query
.
bind
Value
(
":max8"
,
QVariant
(
QVariant
::
Int
));
}
query
.
exec
();
...
...
@@ -416,9 +416,9 @@ void Database::saveVoisinage(const QString& name, const RegleVoisinage& r) const
if
(
type
==
1
||
type
==
2
)
{
//Von Neumann OR Moore (same structure)
query
.
prepare
(
"INSERT INTO regles_voisinage (id, type, rayon) VALUES (:nom, :type, :rayon)"
);
query
.
bind
(
":nom"
,
name
);
query
.
bind
(
":type"
,
type
);
query
.
bind
(
":rayon"
,
r
.
getr
());
query
.
bind
Value
(
":nom"
,
name
);
query
.
bind
Value
(
":type"
,
type
);
query
.
bind
Value
(
":rayon"
,
r
.
getr
());
query
.
exec
();
}
...
...
@@ -434,7 +434,7 @@ void Database::saveVoisinage(const QString& name, const RegleVoisinage& r) const
///@param reseau est le réseau à stocker
///@param nomReseau est le nom du réseau à stocker
///@param nomAutomate est le nom de l'automate en cours
void
Database
::
stockerReseau
(
Reseau
&
reseau
,
QString
nomReseau
,
QString
nomAutomate
)
const
void
Database
::
stockerReseau
(
const
Reseau
&
reseau
,
const
QString
&
nomReseau
,
const
QString
&
nomAutomate
)
const
{
//Tout d'abord, on a besoin de créer un tuple dans la table reseaux :
//toutes les autres tables l'ont en clé étrangère !
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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