// FICHIER : EnumTypeGrandeur.cp // This file is part of the Herezh++ application. // // The finite element software Herezh++ is dedicated to the field // of mechanics for large transformations of solid structures. // It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600) // INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) . // // Herezh++ is distributed under GPL 3 license ou ultérieure. // // Copyright (C) 1997-2022 Université Bretagne Sud (France) // AUTHOR : Gérard Rio // E-MAIL : gerardrio56@free.fr // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, // or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // For more information, please consult: . #include "EnumTypeGrandeur.h" # include using namespace std; //introduces namespace std #include #include "Sortie.h" //#ifdef SYSTEM_MAC_OS_X // #include // a priori ce n'est pas portable //#el #if defined SYSTEM_MAC_OS_CARBON #include // a priori ce n'est pas portable #else #include // pour le flot en memoire centrale #endif #include #include "ParaGlob.h" // tout d'abord on définit la map qui permet de relier les chaines et les types énumérés // 1) def de la map map < string, EnumTypeGrandeur , std::less < string> > ClassPourEnumTypeGrandeur::map_EnumTypeGrandeur; map < string, EnumType2Niveau , std::less < string> > ClassPourEnumTypeGrandeur::map_EnumType2Niveau; // 2) def de la grandeur statique qui permet de remplir la map ClassPourEnumTypeGrandeur ClassPourEnumTypeGrandeur::remplir_map; // le constructeur qui rempli effectivement la map ClassPourEnumTypeGrandeur::ClassPourEnumTypeGrandeur() { // pour les types de base map_EnumTypeGrandeur["RIEN_TYPEGRANDEUR"]=RIEN_TYPEGRANDEUR; map_EnumTypeGrandeur["SCALAIRE"]=SCALAIRE; map_EnumTypeGrandeur["VECTEUR"]=VECTEUR; map_EnumTypeGrandeur["TENSEUR"]=TENSEUR; map_EnumTypeGrandeur["TENSEUR_NON_SYM"]=TENSEUR_NON_SYM; map_EnumTypeGrandeur["SCALAIRE_ENTIER"]=SCALAIRE_ENTIER; map_EnumTypeGrandeur["SCALAIRE_DOUBLE"]=SCALAIRE_DOUBLE; map_EnumTypeGrandeur["TENSEURBB"]=TENSEURBB; map_EnumTypeGrandeur["TENSEURHH"]=TENSEURHH; map_EnumTypeGrandeur["TENSEURBH"]=TENSEURBH; map_EnumTypeGrandeur["TENSEURHB"]=TENSEURHB; map_EnumTypeGrandeur["TENSEUR_NON_SYM_BB"]=TENSEUR_NON_SYM_BB; map_EnumTypeGrandeur["TENSEUR_NON_SYM_HH"]=TENSEUR_NON_SYM_HH; map_EnumTypeGrandeur["COORDONNEE"]=COORDONNEE; map_EnumTypeGrandeur["COORDONNEEB"]=COORDONNEEB; map_EnumTypeGrandeur["COORDONNEEH"]=COORDONNEEH; map_EnumTypeGrandeur["BASE__H"]=BASE__H; map_EnumTypeGrandeur["BASE__B"]=BASE__B; map_EnumTypeGrandeur["CHAINE_CAR"]=CHAINE_CAR; map_EnumTypeGrandeur["GRANDEUR_QUELCONQUE"]=GRANDEUR_QUELCONQUE; // pour les structures secondaires map_EnumType2Niveau["TYPE_SIMPLE"]=TYPE_SIMPLE; map_EnumType2Niveau["TABLEAU_T"]=TABLEAU_T; map_EnumType2Niveau["TABLEAU2_T"]=TABLEAU2_T; map_EnumType2Niveau["LISTE_T"]=LISTE_T; map_EnumType2Niveau["LISTE_IO_T"]=LISTE_IO_T; map_EnumType2Niveau["MAP_T"]=MAP_T; map_EnumType2Niveau["VECTOR_T"]=VECTOR_T; }; string NomTypeGrandeur(EnumTypeGrandeur id_typeGrandeur) // Retourne le nom du type de grandeur correspondant a l'identificateur // de type enumere id_typeGrandeur {string result; switch (id_typeGrandeur) {case RIEN_TYPEGRANDEUR : result="RIEN_TYPEGRANDEUR"; break; case SCALAIRE : result="SCALAIRE"; break; case VECTEUR : result="VECTEUR"; break; case TENSEUR : result="TENSEUR"; break; case TENSEUR_NON_SYM : result="TENSEUR_NON_SYM"; break; case SCALAIRE_ENTIER : result="SCALAIRE_ENTIER"; break; case SCALAIRE_DOUBLE : result="SCALAIRE_DOUBLE"; break; case TENSEURBB : result="TENSEURBB"; break; case TENSEURHH : result="TENSEURHH"; break; case TENSEURBH : result="TENSEURBH"; break; case TENSEURHB : result="TENSEURHB"; break; case TENSEUR_NON_SYM_BB : result="TENSEUR_NON_SYM_BB"; break; case TENSEUR_NON_SYM_HH : result="TENSEUR_NON_SYM_HH"; break; case COORDONNEE : result="COORDONNEE"; break; case COORDONNEEB : result="COORDONNEEB"; break; case COORDONNEEH : result="COORDONNEEH"; break; case BASE__H : result="BASE__H"; break; case BASE__B : result="BASE__B"; break; case CHAINE_CAR : result="CHAINE_CAR"; break; case GRANDEUR_QUELCONQUE : result="GRANDEUR_QUELCONQUE"; break; default : cout << "\nErreur : valeur incorrecte du type EnumTypeGrandeur !\n"; cout << "NomTypeGrandeur(EnumTypeGrandeur ) \n"; Sortie(1); }; return result; }; string NomType2Niveau(EnumType2Niveau id_Type2Niveau) // Retourne le nom du type de grandeur correspondant a l'identificateur // de type enumere id_Type2Niveau { string result; switch (id_Type2Niveau) { case TYPE_SIMPLE : result="TYPE_SIMPLE"; break; case TABLEAU_T : result="TABLEAU_T"; break; case TABLEAU2_T : result="TABLEAU2_T"; break; case LISTE_T : result="LISTE_T"; break; case LISTE_IO_T : result="LISTE_IO_T"; break; case MAP_T : result="MAP_T"; break; case VECTOR_T : result="VECTOR_T"; break; default : cout << "\nErreur : valeur incorrecte du type EnumType2Niveau !\n"; cout << "NomTypeGrandeur(EnumTypeGrandeur ) \n"; Sortie(1); }; return result; }; EnumTypeGrandeur Id_nomTypeGrandeur (string nom_typeGrandeur) // Retourne la variable de type enumere associe au nom nom_typeGrandeur { // on vérifie si la variable de type enumere existe map < string, EnumTypeGrandeur , std::less < string> >& maa=ClassPourEnumTypeGrandeur::map_EnumTypeGrandeur; map < string, EnumTypeGrandeur , std::less < string> >::iterator il,ilfin= maa.end(); string toto; il = maa.find(nom_typeGrandeur); if (il == maa.end()) {// on vérifie si la variable de type enumere existe cout << "\nErreur : nom du type de grandeur '" < >& maa=ClassPourEnumTypeGrandeur::map_EnumType2Niveau; map < string, EnumType2Niveau , std::less < string> >::iterator il,ilfin= maa.end(); string toto; il = maa.find(nom_Type2Niveau); if (il == maa.end()) {// on vérifie si la variable de type enumere existe cout << "\nErreur : nom du type de grandeur '" <> (istream & entree, EnumTypeGrandeur & result) { string nom_typeGrandeur; entree >> nom_typeGrandeur; result = Id_nomTypeGrandeur ( nom_typeGrandeur); return entree; }; // surcharge de l'operator d'ecriture ostream & operator << (ostream & sort, const EnumTypeGrandeur& a) { // on ecrit la forme caractère sort << NomTypeGrandeur(a) << " "; return sort; };