TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_Fichier_base.h
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#ifndef Sortie_Fichier_base_included
17#define Sortie_Fichier_base_included
18
19#include <Objet_U.h>
20#include <Sortie.h>
21#include <Nom.h>
22#include <memory>
23
24using std::ifstream;
25using std::ofstream;
26using std::streampos;
27
28class Sortie_Fichier_base : public Sortie, public Objet_U
29{
30 Declare_base_sans_constructeur(Sortie_Fichier_base);
31public:
34 Sortie_Fichier_base(const char* name, IOS_OPEN_MODE mode=ios::out);
35 ofstream& get_ofstream();
36 void close();
37 void precision(int pre) override;
38 virtual int get_precision();
39 void setf(IOS_FORMAT code) override;
40 bool is_open() ;
41 virtual int ouvrir(const char* name,IOS_OPEN_MODE mode=ios::out);
42
43 Sortie& flush() override;
44 static void set_root(const std::string dirname);
45 static std::string root;
46
47protected:
48 /*! This pointer is just a (typed) view on the smart ptr hold by the base class (Sortie).
49 * The base class is managing the memory.
50 */
51 ofstream * ofstream_ = nullptr;
52
54 {
55 if (&f != this) Process::exit("Assignement operator not allowed in Sortie_Fichier_base !");
56 return *this;
57 }
58
59private:
60 char* internalBuff_ = nullptr; // TODO - could be smart too
61 int toFlush_;
62 void set_buffer();
63 void set_toFlush();
64 int toFlush() { return toFlush_; }
65 int counter_=0;
66};
67
68#endif
friend class Sortie
Definition Objet_U.h:75
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
Sortie & flush() override
Force l'ecriture sur disque des donnees dans le tampon Utilise l'implementation de la classe ofstream...
void precision(int pre) override
void setf(IOS_FORMAT code) override
Sortie_Fichier_base & operator=(const Sortie_Fichier_base &f)
static void set_root(const std::string dirname)
static std::string root
Sortie_Fichier_base(const Sortie_Fichier_base &)=default