Herezh_dev/herezh_pp/Enumeration/Enum_dure.cc

152 lines
3.6 KiB
C++
Executable file

// FICHIER Enum_dure.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) <https://www.irdl.fr/>.
//
// Herezh++ is distributed under GPL 3 license ou ultérieure.
//
// Copyright (C) 1997-2021 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 <https://www.gnu.org/licenses/>.
//
// For more information, please consult: <https://herezh.irdl.fr/>.
#include "Enum_dure.h"
# include <iostream>
using namespace std; //introduces namespace std
#include <stdlib.h>
#include "Sortie.h"
//#ifdef SYSTEM_MAC_OS_X
// #include <stringfwd.h> // a priori ce n'est pas portable
//#el
#if defined SYSTEM_MAC_OS_CARBON
#include <stringfwd.h> // a priori ce n'est pas portable
#else
#include <string.h> // pour le flot en memoire centrale
#endif
#include <string>
#ifndef Enum_dure_deja_inclus
#ifndef MISE_AU_POINT
inline
#endif
string Nom_dure (Enum_dure id_nom)
// Retourne le nom du temps associe
// a l'identificateur de type enumere id_nom
{
string result="";
switch (id_nom)
{
case TEMPS_0 :
result="TEMPS_0";
break;
case TEMPS_t :
result="TEMPS_t";
break;
case TEMPS_tdt :
result="TEMPS_tdt";
break;
default :
cout << "\nErreur : valeur incorrecte du type Enum_dure !\n";
cout << "Nom_dure(Enum_dure ) \n";
Sortie(1);
};
return result;
};
#ifndef MISE_AU_POINT
inline
#endif
Enum_dure Id_nom_dure (const string& nom)
// Retourne la variable de type enumere associee au nom du temps
{
Enum_dure result;
if ( nom =="TEMPS_0")
result=TEMPS_0;
else if ( nom =="TEMPS_t")
result=TEMPS_t;
else if ( nom == "TEMPS_tdt")
result=TEMPS_tdt;
else
{
cout << "\nErreur : nom du temps " << nom << " inconnu !\n";
cout << "Id_nom_dure (const string& nom) \n";
Sortie(1);
};
return result;
};
#ifndef MISE_AU_POINT
inline
#endif
// test si l'identificateur de type enumere associe au nom du temps
// existe bien : ramène true s'il s'agit bien d'un type reconnu
bool Existe_nom_dure (const string& nom_ddl)
{bool retour = false;
if ( nom_ddl =="TEMPS_0")
retour = true;
else if ( nom_ddl =="TEMPS_t")
retour = true;
else if ( nom_ddl == "TEMPS_tdt")
retour = true;
else
retour = false;
return retour;
};
// surcharge de l'operator de lecture
#ifndef MISE_AU_POINT
inline
#endif
istream & operator >> (istream & entree, Enum_dure& a)
{ char nom_Enum_dure[50];
entree >> nom_Enum_dure;
a = Id_nom_dure ( nom_Enum_dure);
return entree;
};
// surcharge de l'operator d'ecriture
#ifndef MISE_AU_POINT
inline
#endif
ostream & operator << (ostream & sort, const Enum_dure& a)
{ // on ecrit la forme caractère
sort << Nom_dure(a) << " ";
return sort;
};
#endif