Herezh_dev/herezh_pp/Enumeration/Enum_calcul_masse.cc

116 lines
3.3 KiB
C++
Raw Normal View History

// FICHIER : Enum_calcul_masse.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_calcul_masse.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>
char* Nom_calcul_masse (Enum_calcul_masse id_calcul_masse)
// Retourne le nom du type de calcul_masse correspondant a l'identificateur
// de type enumere id_calcul_masse
{
char* result;
switch (id_calcul_masse)
{
case MASSE_DIAG_COEF_EGAUX :
result="MASSE_DIAG_COEF_EGAUX";
break;
case MASSE_DIAG_COEF_VAR :
result="MASSE_DIAG_COEF_VAR";
break;
case MASSE_CONSISTANTE :
result="MASSE_CONSISTANTE";
break;
default :
cout << "\nErreur : valeur incorrecte du type Enum_calcul_masse !\n";
cout << "Nom_calcul_masse(Enum_calcul_masse ) \n";
Sortie(1);
};
return result;
};
Enum_calcul_masse Id_nom_calcul_masse (char* nom_calcul_masse)
// Retourne la variable de type enumere associe au nom
// de calcul_masse nom_calcul_masse
{
Enum_calcul_masse result;
if ( strcmp(nom_calcul_masse,"MASSE_DIAG_COEF_EGAUX")==0 )
result=MASSE_DIAG_COEF_EGAUX;
else if ( strcmp(nom_calcul_masse,"MASSE_DIAG_COEF_VAR")==0 )
result=MASSE_DIAG_COEF_VAR;
else if ( strcmp(nom_calcul_masse,"MASSE_CONSISTANTE")==0 )
result=MASSE_CONSISTANTE;
else
{
cout << "\nErreur : nom de calcul_masse inconnu !\n";
cout << "Id_nom_interpol(char* ) \n";
Sortie(1);
};
return result;
};
// surcharge de la lecture
istream & operator >> (istream & entree, Enum_calcul_masse & result)
{ char nom_calcul_masse[60];
entree >> nom_calcul_masse;
result = Id_nom_calcul_masse ( nom_calcul_masse);
return entree;
};
// surcharge de l'operator d'ecriture
ostream & operator << (ostream & sort, const Enum_calcul_masse& a)
{ // on ecrit la forme caractère
sort << Nom_calcul_masse(a) << " ";
return sort;
};