TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
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 <Lire.h>
17#include <Synonyme_info.h>
18#include <Interprete_bloc.h>
19
20Implemente_instanciable(Lire,"Lire|Read",Interprete);
21// XD read interprete lire NO_BRACE Interpretor to read the a_object objet defined between the braces.
22// XD attr a_object chaine a_object REQ Object to be read.
23// XD attr bloc chaine bloc REQ Definition of the object.
24
25
26/*! @brief appel a la methode printOn de la classe Interprete
27 *
28 */
29Sortie& Lire::printOn(Sortie& os) const
30{
31 return Interprete::printOn(os);
32}
33
34/*! @brief appel a la methode readOn de la classe Interprete
35 *
36 */
38{
39 return Interprete::readOn(is);
40}
41
42/*! @brief Read an object.
43 *
44 */
46{
47 // Example in a data file:
48 // Lire name { ... }
49 Nom name;
50 is >> name; // The object name is read from the input stream is
51
52 if (objet_existant(name)) //nom d'un objet existant -> on le lit
53 {
54 Objet_U& object=objet(name);
55 return is >> object; // Then "{ ... }" is read by the object readOn
56 }
57 else //pas le nom d'un objet existant -> on lit le type, on cree l'objet, puis on le lit
58 {
59 DerObjU ref;
60 Nom type;
61 is >> type;
62 ref.typer(type);
63 //on ajoute l'objet a l'interprete courant...
65 return is >> obj; //et on lit
66 }
67}
68
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.
Classe de base des objets "interprete".
Definition Interprete.h:38
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
Entree & interpreter(Entree &) override
Read an object.
Definition Lire.cpp:45
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