Projet tutoré 3 - Graphes
ProjetGraphes.cpp
Aller à la documentation de ce fichier.
1 /*!
2  * \file ProjetGraphes.cpp
3  * \brief Fichier contenant la fonction main
4  * \warning La fonction main nécessite au moins 1 chemin vers un fichier pour traiter la création d'un graphe, sinon fin de programme
5  * \author Guillaume ELAMBERT
6  * \author Clément NONCHER-GILLET
7  * \date 2021
8  */
9 
10 
11 #include <iostream>
12 #include <Windows.h>
13 #include "CGraphe.h"
14 #include "CSommet.h"
15 #include "CArc.h"
16 #include "CException.h"
17 #include "conio.h"
18 
19 using namespace std;
20 
21 
22 /*!
23  * La fonction principale.
24  *
25  * \warning Nécessite au moins 1 chemin vers un fichier pour traiter la création d'un graphe, sinon fin de programme
26  * \param argc Le nombre d'arguments passés au programme
27  * \param argv La liste des arguments passés au programme
28  * \return 0 => l'exécution s'est faite sans erreur
29  */
30 int main(int argc, char * argv[])
31 {
32  // Set console code page to UTF-8 so console known how to interpret string data
33  SetConsoleOutputCP(CP_UTF8);
34 
35  // Enable buffering to prevent VS from chopping up UTF-8 byte sequences
36  setvbuf(stdout, nullptr, _IOFBF, 1000);
37 
38 
39  if (argc > 1) {
40 
41  CGraphe *GPHLeGraphe = NULL;
42  CGraphe *GPHLeGrapheInverse = NULL;
43 
44  //On parcourt l'ensemble des chemins passés en paramètre
45  for (int i = 1; i < argc; ++i) {
46  try {
47  printf(i > 1 ? "\n\n" : "");
48 
49 
50  printf("----- GRAPHE DU FICHIER \"%s\" -----\n\n", argv[i]);
51  GPHLeGraphe = new CGraphe(argv[i], true);
52  GPHLeGraphe->GPHAfficherGraphe();
53 
54 
55  printf("\n----- GRAPHE INVERSE DU FICHIER \"%s\" -----\n\n", argv[i]);
56  GPHLeGrapheInverse = &GPHLeGraphe->GPHRenverserGraphe();
57  GPHLeGrapheInverse->GPHAfficherGraphe();
58 
59  cout << endl << endl;
60 
61  delete GPHLeGraphe;
62  delete GPHLeGrapheInverse;
63  }
64  //On gère les erreurs de création du graphe et d'inversion du graphe
65  catch (CException EXCELevee) {
66  cerr << EXCELevee.EXCGetMessage();
67  }
68  }
69  }
70  else {
71  cout << "Il faut passer au moins un fichier en paramètre.\n";
72  }
73 
74  cout << "\n\nAppuyez sur une touche pour fermer" << endl;
75  _getch();
76  return 0;
77 }
CSommet.h
Fichier contenant la déclaration de la classe CSommet.
CArc.h
Fichier contenant la déclaration de la classe CArc.
CGraphe
Classe du graphe.
Definition: CGraphe.h:41
CGraphe::GPHAfficherGraphe
void GPHAfficherGraphe()
Definition: CGraphe.cpp:571
main
int main(int argc, char *argv[])
Definition: ProjetGraphes.cpp:30
CException.h
Fichier contenant la déclaration de la classe CException.
CException
Classe d'exception personnalisée.
Definition: CException.h:25
CGraphe::GPHRenverserGraphe
CGraphe & GPHRenverserGraphe()
Definition: CGraphe.cpp:594
CException::EXCGetMessage
const char * EXCGetMessage(void)
Definition: CException.cpp:71
CGraphe.h
Fichier contenant la déclaration de la classe CGraphe.