You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
79 lines
1.9 KiB
#include "Gestion.h"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <map>
|
|
#include "Base.h"
|
|
#include "Groupe.h"
|
|
#include "Photo.h"
|
|
#include "Video.h"
|
|
#include "Film.h"
|
|
|
|
using namespace std;
|
|
|
|
PhotoPtr Gestion::creerPhoto(string name, string pathname, unsigned int latitude, unsigned int longitude) {
|
|
PhotoPtr obj(new Photo(name, pathname, latitude, longitude));
|
|
objets[name] = obj;
|
|
return obj;
|
|
}
|
|
|
|
VideoPtr Gestion::creerVideo(string name, string pathname, unsigned int duree) {
|
|
VideoPtr obj(new Video(name, pathname, duree));
|
|
objets[name] = obj;
|
|
return obj;
|
|
}
|
|
|
|
FilmPtr Gestion::creerFilm(string name, string pathname, unsigned int duree) {
|
|
FilmPtr obj(new Film(name, pathname, duree));
|
|
objets[name] = obj;
|
|
return obj;
|
|
}
|
|
|
|
GroupePtr Gestion::creerGroupe(string name) {
|
|
GroupePtr obj(new Groupe(name));
|
|
groupes[name] = obj;
|
|
return obj;
|
|
}
|
|
|
|
void Gestion::afficher(string name, ostream& flux) {
|
|
int cpt = 0;
|
|
|
|
map<string,BasePtr>::iterator it;
|
|
it = objets.find(name);
|
|
if (it != objets.end()) it->second->affichage(flux);
|
|
else cpt += 1;
|
|
|
|
map<string,GroupePtr>::iterator it2;
|
|
it2 = groupes.find(name);
|
|
if (it2 != groupes.end()) it2->second->affichage(flux);
|
|
else cpt += 1;
|
|
|
|
if (cpt == 2) flux << "aucun fichier ou groupe pour ce nom : " << name << endl;
|
|
}
|
|
|
|
void Gestion::jouer(string name) {
|
|
map<string,BasePtr>::iterator it;
|
|
it = objets.find(name);
|
|
if (it != objets.end()) it->second->play();
|
|
}
|
|
|
|
void Gestion::supprimer(string name) {
|
|
map<string,GroupePtr>::iterator it2;
|
|
it2 = groupes.find(name);
|
|
if (it2 != groupes.end()) groupes.erase(it2);
|
|
|
|
map<string,BasePtr>::iterator it1;
|
|
it1 = objets.find(name);
|
|
if (it1 != objets.end()) objets.erase(it1);
|
|
|
|
for (auto & itg : groupes) {
|
|
itg.second->supprimer(name);
|
|
}
|
|
}
|
|
|
|
void Gestion::lister(ostream& flux) {
|
|
flux << "Les groupes disponibles et leurs éléments sont les suivants : " << endl;
|
|
for (auto & it : groupes) {
|
|
it.second->affichage(flux);
|
|
}
|
|
}
|
|
|