This repository was archived by the owner on Aug 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuv.cpp
More file actions
88 lines (80 loc) · 2.46 KB
/
uv.cpp
File metadata and controls
88 lines (80 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "uv.h"
#include "templatemanager.h"
#include "Etudiant.h"
UV::UV(std::string c, std::string t, std::map<Categorie, unsigned int> cre, bool a, bool p)
{
TemplateManager<UV>& tUV=TemplateManager<UV>::getInstance();
if(!tUV.alreadyExist(c))
{
code=c;
titre=t;
credits=cre;
automne=a;
printemps=p;
tUV.New(*this);
}
else
{
throw UvException("Erreur : l'UV ' "+c+" existe deja !");
}
}
UV::UV(QString c, QString t, std::map<Categorie, unsigned int> cre, bool a, bool p)
{
UV(c.toStdString(),t.toStdString(),cre,a,p);
}
UV::UV(const char* c,const char*t, std::map<Categorie, unsigned int> cre, bool a, bool p)
{
UV(std::string(c),std::string(t),cre,a,p);
}
void UV::setCode(std::string c)
{
TemplateManager<UV>& tUV=TemplateManager<UV>::getInstance();
if(!tUV.alreadyExist(c) || tUV.getElement(c)==*this)
{
tUV.erase(*this);
code=c;
tUV.New(*this);
}
else
{
throw UvException("Erreur : l'UV ' "+c+" existe deja !");
}
}
UV StringToUV(const QString& str){//renvoie une référence vers la catégorie si elle existe, exception sinon.
TemplateManager<UV>& tUV=TemplateManager<UV>::getInstance();
if(tUV.alreadyExist(str))
{
return tUV.getElement(str);
}
else
{
throw UvException("Erreur StringToUV l'uv "+str.toStdString()+" n'existe pas.");
}
}
void UV::destroy()
{
TemplateManager<Etudiant>& tEtudiant=TemplateManager<Etudiant>::getInstance();
if(tEtudiant.size()>0)//pour chaque étudiant, on enlève les isncriptions
{
for(std::vector<Etudiant>::iterator it = tEtudiant.getIterator();it!=tEtudiant.end();it++)//on supprime toutes les uvs de cette catégorie
{
Dossier dos=it->getDossier();
std::vector<Inscription> inscr = dos.getInscription();
for(std::vector<Inscription>::iterator it2= inscr.begin();it2 != inscr.end();it2++)
{
if(it2->getUV()==*this)
{
dos.deleteInscription(*it2);
it->setDossier(dos);
}
}
}
}
}
QTextStream& operator<<(QTextStream& f, const UV& uv){
return f<<QString::fromStdString(uv.getCode())<<", "<<", "<<" credits, "<<QString::fromStdString(uv.getTitre());
}
std::ostream& operator<<(std::ostream& f, const UV& uv)
{
return f<<uv.getCode()<<", "<<", "<<" credits, "<<uv.getTitre();
}