TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Typer_Lire.cpp
1/****************************************************************************
2* Copyright (c) 2022, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Typer_Lire.h>
17#include <Synonyme_info.h>
18#include <Interprete_bloc.h>
19
20Implemente_instanciable(Typer_Lire,"Typer_Lire|Type_Read",Lire);
21
22/*! @brief appel a la methode printOn de la classe Interprete
23 *
24 */
26{
27 return Lire::printOn(os);
28}
29
30/*! @brief appel a la methode readOn de la classe Interprete
31 *
32 */
34{
35 return Lire::readOn(is);
36}
37
38/*! @brief Read an object.
39 *
40 */
42{
43 // Example in a data file:
44 // Typer_Lire name type { ... }
45 Nom name;
46 is >> name; // The object name is read from the input stream is
47
48 if (objet_existant(name)) //nom d'un objet existant -> on le lit
49 {
50 Objet_U& object=objet(name);
51 return is >> object; // Then "{ ... }" is read by the object readOn
52 }
53 else //pas le nom d'un objet existant -> on lit le type, on cree l'objet, puis on le lit
54 {
55 // Lire name type { ... }
56 DerObjU ref;
57 Nom type;
58 is >> type;
59 if (type=="{")
60 {
61 Objet_U& object=objet(name); // Pour faire planter avec le message d'erreur habituel
62 return is >> object;
63 }
64 ref.typer(type);
65 //on ajoute l'objet a l'interprete courant...
67 return is >> obj; //et on lit
68 }
69}
70
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Objet_U & ajouter(const Nom &nom, DerObjU &object_to_add)
Ajoute l'objet ob a la liste des objets de l'interprete, et nomme l'objet avec nom.
static Interprete_bloc & interprete_courant()
renvoie l'interprete_bloc en train d'etre lu dans le jeu de donnees.
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
static int objet_existant(const Nom &)
Renvoie 1 si l'objet existe, 0 sinon voir Interprete_bloc::objet_global_existant().
Keyword to read an object, typically from a data file.
Definition Lire.h:25
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Objet_U * typer(const char *nom_type)
Essaie de creer une instance du type "type".
friend class Entree
Definition Objet_U.h:76
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Classe de base des flux de sortie.
Definition Sortie.h:52
Keyword to read an object, typically from a data file.
Definition Typer_Lire.h:25
Entree & interpreter(Entree &) override
Read an object.