TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
EcrFicPartage.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 EcrFicPartage_included
17#define EcrFicPartage_included
18
19#include <SFichier.h>
20#include <OBuffer.h>
21#include <Nom.h>
22
23/*! @brief Ecriture dans un fichier partage Cette classe implemente les operateurs et les methodes virtuelles de la clase SFichier de la facon suivante :
24 *
25 * un fichier physiquement localise sur le disque de la machine heberge la tache maitre de
26 * l'application Trio-U (le processus de rang 0 dans le groupe "tous").
27 * Chacun des processus ecrit ses donnees l'un apres l'autre, par ordre croissant de rang dans le groupe "tous"
28 * La synchronisation est realisee par un systeme de semaphore.
29 * Ce type de fichier est notamment utilise pour la creation d'un fichier de post-traitement unique.
30 *
31 */
32
33class OBuffer;
34
35// Chaque PE ecrit dans le meme() fichier
36class EcrFicPartage : public SFichier
37{
38 Declare_instanciable_sans_constructeur_ni_destructeur(EcrFicPartage);
39public:
41 EcrFicPartage(const char* name,IOS_OPEN_MODE mode=ios::out);
42 int ouvrir(const char* name,IOS_OPEN_MODE mode=ios::out) override;
43 ~EcrFicPartage() override;
44 void close();
45 Sortie& lockfile() override;
46 Sortie& unlockfile() override;
47 Sortie& syncfile() override;
48 void precision(int) override;
49 int get_precision() override;
50
51 Sortie& flush() override;
52 void set_bin(bool bin) override;
53 void set_64b(bool is64) override;
54
55 Sortie& operator <<(const char* ob) override;
56 Sortie& operator <<(const Objet_U& ob) override;
57 Sortie& operator <<(const std::string& ob) override;
58 Sortie& operator <<(const Separateur& ) override;
59
60 Sortie& operator <<(const int ob) override;
61 Sortie& operator <<(const unsigned ob) override;
62 Sortie& operator <<(const long ob) override;
63 Sortie& operator <<(const long long ob) override;
64 Sortie& operator <<(const unsigned long ob) override;
65 Sortie& operator <<(const float ob) override;
66 Sortie& operator <<(const double ob) override;
67
68 int put(const unsigned* ob, std::streamsize n, std::streamsize pas) override;
69 int put(const int* ob, std::streamsize n, std::streamsize pas) override;
70 int put(const long* ob, std::streamsize n, std::streamsize pas) override;
71 int put(const long long* ob, std::streamsize n, std::streamsize pas) override;
72 int put(const float* ob, std::streamsize n, std::streamsize pas) override;
73 int put(const double* ob, std::streamsize n, std::streamsize pas) override;
74
75protected:
77
78private:
79 OBuffer& get_obuffer();
80 OBuffer * obuffer_ptr_ = nullptr; // Pointeur : permet de ne pas inclure OBuffer.h
81
82 template <typename _TYPE_>
83 int put_template(const _TYPE_* ob, std::streamsize n, std::streamsize pas)
84 {
85 get_obuffer().put(ob,n,pas);
86 return 1;
87 }
88
89 template <typename _TYPE_>
90 Sortie& operator_template(const _TYPE_& ob)
91 {
92 get_obuffer() << ob;
93 return *this;
94 }
95};
96
97#endif /* EcrFicPartage_included */
int put(const unsigned *ob, std::streamsize n, std::streamsize pas) override
int get_precision() override
~EcrFicPartage() override
ferme le fichier
Sortie & unlockfile() override
Permet de debloquer la ressource critique pour leprocessus suivant.
Sortie & lockfile() override
Permet au processus appelant de bloquer en attente de la ressource commune a tous les processus qui e...
Sortie & flush() override
void set_bin(bool bin) override
Sortie & operator<<(const char *ob) override
Ecriture d'une chaine de caracteres.
int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out) override
Ouvre le fichier avec les parametres mode et prot donnes Ces parametres sont les parametres de la met...
Sortie & syncfile() override
Provoque l'ecriture sur disque des donnees accumulees sur les differents processeurs depuis le dernie...
void precision(int) override
void set_64b(bool is64) override
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
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
SFichier(const char *name, IOS_OPEN_MODE mode=ios::out)
Definition SFichier.h:30
Separateur pour les fichiers.
Definition Separateur.h:30
Classe de base des flux de sortie.
Definition Sortie.h:52
virtual int put(const unsigned *ob, std::streamsize n, std::streamsize nb_colonnes=1)
Definition Sortie.cpp:101