TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
AbstractIO.h
1/****************************************************************************
2* Copyright (c) 2025, 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 AbstractIO_included
17#define AbstractIO_included
18
19
20/*! @brief Base class for all input/output streams.
21 *
22 * Holds information about binary/ascii format, and 32b/64b information.
23 *
24 * - bin_ indicates whether the stream is binary or ASCII
25 * - is_64b_ incidates whether the stream is in 64b or 32b
26 * - avoid_conversion_ is used for MPI Comm buffer, where we do not want any int/long conversion.
27 *
28 * See method must_convert() and file arch.h.in for more explanations on 32/64b.
29 *
30 * Note that the .sauv files for example are always written in 32b.
31 *
32 * @sa Entree, Sortie, and specifically the comments in operator_template<>() method.
33 */
35{
36public:
37 bool is_64b() const { return is_64b_; }
38 virtual void set_64b(bool is_64b) { is_64b_ = is_64b; }
39 virtual void set_bin(bool bin) { bin_ = bin; }
40 bool is_bin() { return bin_; }
41 void set_avoid_conversion(bool avoid) { avoid_conversion_ = avoid; }
43
44protected:
45 AbstractIO();
46 virtual ~AbstractIO() { }
47
48 template<typename _TYPE_> bool must_convert() const;
49
50 bool bin_ = false; ///< Is this a binary flux?
51 bool is_64b_; ///< Will we be reading/writing in 64b? (Init in ctor to avoid including arch.h probably)
52
53 /*! If true, no hacking on int/long is performed in operator_template() methods of Entree/Sortie
54 * This is useful for CommBuffer classes (=MPI exchanges) where we always want int to be sent as int, and long to be
55 * sent as long.
56 */
57 bool avoid_conversion_ = false;
58};
59
60#endif /* AbstractIO_included */
bool avoid_conversion()
Definition AbstractIO.h:42
virtual void set_bin(bool bin)
Definition AbstractIO.h:39
bool bin_
Is this a binary flux?
Definition AbstractIO.h:50
bool is_64b() const
Definition AbstractIO.h:37
bool is_64b_
Will we be reading/writing in 64b? (Init in ctor to avoid including arch.h probably).
Definition AbstractIO.h:51
virtual ~AbstractIO()
Definition AbstractIO.h:46
bool is_bin()
Definition AbstractIO.h:40
bool avoid_conversion_
Definition AbstractIO.h:57
bool must_convert() const
Whether to convert an int into a long when reading/writing out data.
virtual void set_64b(bool is_64b)
Definition AbstractIO.h:38
void set_avoid_conversion(bool avoid)
Definition AbstractIO.h:41