TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Entree_complete.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Entree_complete.h>
17#include <Process.h>
18#include <communications.h>
19#include <communications_array.h>
20#include <Nom.h>
21
22Entree_complete::Entree_complete(const char* str_entree1, Entree& entree2)
23{
24 num_entree_ = 0;
25 str_size_ = (int)strlen(str_entree1);
26 chaine_str_.init(str_entree1);
27 Process::Journal() << "Construction of a Entree_complete with : " << str_entree1 << finl;
28 entree2_ = &entree2;
29 num_entree_ = 0;
30 Error_Action action = entree2.get_error_action();
32 chaine_str_.set_error_action(action);
33 int check_types_sa = entree2.check_types();
34 Entree::set_check_types(check_types_sa);
35 chaine_str_.set_check_types(check_types_sa);
36}
37
39
41{
42 if (num_entree_ == 0)
43 {
44 int pos = (int)chaine_str_.get_istream().tellg();
45 if (pos < str_size_ && pos >= 0)
46 return chaine_str_;
47 num_entree_ = 1;
48 }
49 return *entree2_;
50}
51
52int Entree_complete::get(char* ob, std::streamsize bufsize)
53{
54 Entree& is = get_input();
55 return is.get(ob, bufsize);
56}
57
58Entree& Entree_complete::operator>>(int& ob) { return operator_template<int>(ob); }
59int Entree_complete::get(int * ob, std::streamsize n) { return get_template<int>(ob,n); }
60
61Entree& Entree_complete::operator>>(long& ob) { return operator_template<long>(ob); }
62int Entree_complete::get(long * ob, std::streamsize n) { return get_template<long>(ob,n); }
63
64Entree& Entree_complete::operator>>(long long& ob) { return operator_template<long long>(ob); }
65int Entree_complete::get(long long * ob, std::streamsize n) { return get_template<long long>(ob,n); }
66
67Entree& Entree_complete::operator>>(float& ob) { return operator_template<float>(ob); }
68int Entree_complete::get(float * ob, std::streamsize n) { return get_template<float>(ob,n); }
69
70Entree& Entree_complete::operator>>(double& ob) { return operator_template<double>(ob); }
71int Entree_complete::get(double * ob, std::streamsize n) { return get_template<double>(ob,n); }
72
74{
75 Entree& is = get_input();
76 return is.eof();
77}
78
80{
81 Entree& is = get_input();
82 return is.fail();
83}
84
86{
87 Entree& is = get_input();
88 return is.good();
89}
90
91/*! @brief Il est interdit de changer de type d'entree.
92 *
93 * exit()
94 *
95 */
97{
98 if (bin)
99 {
100 Cerr << "Error in Entree_complete::set_bin(bool bin) : not supported" << finl;
102 }
103}
104
105/*! @brief affecte le drapeau aux deux entrees sources Attention, le drapeau de entree2 est modifie !
106 *
107 * Voir Entree::set_check_types()
108 *
109 */
111{
113 chaine_str_.set_check_types(flag);
114 entree2_->set_check_types(flag);
115}
116
117/*! @brief affecte la valeur aux deux entrees sources Attention, la valeur de entree2 est modifiee !
118 *
119 * Voir Entree::set_error_action()
120 *
121 */
123{
125 chaine_str_.set_error_action(action);
126 entree2_->set_error_action(action);
127}
int fail() override
void set_bin(bool bin) override
Il est interdit de changer de type d'entree.
int eof() override
Entree & operator>>(int &ob) override
int good() override
void set_error_action(Error_Action) override
affecte la valeur aux deux entrees sources Attention, la valeur de entree2 est modifiee !
int get(int *ob, std::streamsize n) override
Entree_complete(const char *str, Entree &entree2)
~Entree_complete() override
void set_check_types(bool flag) override
affecte le drapeau aux deux entrees sources Attention, le drapeau de entree2 est modifie !
virtual int good()
Definition Entree.cpp:270
Entree()
Definition Entree.cpp:24
virtual int fail()
Definition Entree.cpp:263
virtual int get(int *ob, std::streamsize n)
Definition Entree.cpp:222
Error_Action
Definition Entree.h:93
virtual void set_error_action(Error_Action)
Change le comportement en cas d'erreur de l'entree, voir error_handle_() et get_error_action().
Definition Entree.cpp:382
virtual int eof()
Definition Entree.cpp:256
bool check_types() const
Definition Entree.h:92
Error_Action get_error_action()
renvoie error_action_ pour cette entree (permet de la modifier et de restaurer ensuite la valeur ante...
Definition Entree.cpp:374
virtual void set_check_types(bool flag)
indique si le stream doit verifier les types des objets lus (ints et nombres flottants).
Definition Entree.cpp:313
static Sortie & Journal(int message_level=0)
Renvoie un objet statique de type Sortie qui sert de journal d'evenements.
Definition Process.cpp:588
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455