Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
BasicSerializerInternal.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* BasicSerializerInternal.h (C) 2000-2024 */
9/* */
10/* Partie interne de 'BasicSerializer'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_SERIALIZE_BASICSERIALIZERINTERNAL_H
13#define ARCCORE_SERIALIZE_BASICSERIALIZERINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/serialize/BasicSerializer.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arccore
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class ARCCORE_SERIALIZE_EXPORT BasicSerializer::Impl
30{
31 public:
32
33 virtual ~Impl() {}
34
35 public:
36
37 virtual Span<Real> getRealBuffer() = 0;
38 virtual Span<Int16> getInt16Buffer() = 0;
39 virtual Span<Int32> getInt32Buffer() = 0;
40 virtual Span<Int64> getInt64Buffer() = 0;
41 virtual Span<Byte> getByteBuffer() = 0;
42 virtual Span<Int8> getInt8Buffer() = 0;
43 virtual Span<Float16> getFloat16Buffer() = 0;
44 virtual Span<BFloat16> getBFloat16Buffer() = 0;
45 virtual Span<Float32> getFloat32Buffer() = 0;
46
47 virtual void allocateBuffer(Int64 nb_real, Int64 nb_int16, Int64 nb_int32,
48 Int64 nb_int64, Int64 nb_byte, Int64 nb_int8, Int64 nb_float16,
49 Int64 nb_bfloat16, Int64 nb_float32) = 0;
50 virtual void copy(Impl* rhs) = 0;
51 virtual Span<Byte> globalBuffer() = 0;
52 virtual Span<const Byte> globalBuffer() const = 0;
53 virtual Int64ConstArrayView sizesBuffer() const = 0;
54 virtual ByteConstArrayView copyAndGetSizesBuffer() = 0;
55 virtual void preallocate(Int64 size) = 0;
56 virtual void releaseBuffer() = 0;
57 virtual void setFromSizes() = 0;
58 virtual Int64 totalSize() const = 0;
59 virtual void printSizes(std::ostream& o) const = 0;
60
61 public:
62
63 ARCCORE_DEPRECATED_REASON("Y2023: use overload with float16/float32")
64 virtual void allocateBuffer(Int64 nb_real, Int64 nb_int16, Int64 nb_int32,
65 Int64 nb_int64, Int64 nb_byte) = 0;
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71class ARCCORE_SERIALIZE_EXPORT BasicSerializer::Impl2
72{
73 public:
74
75 Impl2();
76 ~Impl2();
77
78 public:
79
80 Span<const Real> realBytes() const { return m_real.m_buffer; }
81 Span<const Int64> int64Bytes() const { return m_int64.m_buffer; }
82 Span<const Int32> int32Bytes() const { return m_int32.m_buffer; }
83 Span<const Int16> int16Bytes() const { return m_int16.m_buffer; }
84 Span<const Byte> byteBytes() const { return m_byte.m_buffer; }
85 Span<const Int8> int8Bytes() const { return m_int8.m_buffer; }
86 Span<const Float16> float16Bytes() const { return m_float16.m_buffer; }
87 Span<const BFloat16> bfloat16Bytes() const { return m_bfloat16.m_buffer; }
88 Span<const Float32> float32Bytes() const { return m_float32.m_buffer; }
89
90 public:
91
92 void reserve(eDataType dt, Int64 n, Int64 nb_put);
93 void putType(eBasicDataType t);
94 void getAndCheckType(eBasicDataType expected_type);
96 void allocateBuffer(Int64 nb_real, Int64 nb_int16, Int64 nb_int32,
97 Int64 nb_int64, Int64 nb_byte, Int64 nb_int8, Int64 nb_float16,
98 Int64 nb_bfloat16, Int64 nb_float32);
99 void copy(const BasicSerializer& rhs);
100 void setMode(eMode new_mode);
101 void setFromSizes();
102
103 public:
104
105 ARCCORE_DEPRECATED_REASON("Y2023: use overload with float16/float32")
106 void allocateBuffer(Int64 nb_real, Int64 nb_int16, Int64 nb_int32,
107 Int64 nb_int64, Int64 nb_byte);
108
109 public:
110
111 void setSerializeTypeInfo(bool v) { m_is_serialize_typeinfo = v; }
112 bool isSerializeTypeInfo() const { return m_is_serialize_typeinfo; }
113
114 public:
115
116 eMode m_mode;
117 eReadMode m_read_mode;
118 BasicSerializer::Impl* m_p;
119 bool m_is_serialize_typeinfo = false;
120 BasicSerializerDataT<Real> m_real;
121 BasicSerializerDataT<Int64> m_int64;
122 BasicSerializerDataT<Int32> m_int32;
123 BasicSerializerDataT<Int16> m_int16;
124 BasicSerializerDataT<Byte> m_byte;
125 BasicSerializerDataT<Int8> m_int8;
126 BasicSerializerDataT<Float16> m_float16;
127 BasicSerializerDataT<BFloat16> m_bfloat16;
128 BasicSerializerDataT<Float32> m_float32;
129
130 private:
131
132 void _setViews();
133};
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137
138} // End namespace Arccore
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143#endif
Fichier contenant les définitions des types de données basiques gérés par Arccore.
void allocateBuffer()
Alloue la mémoire du sérialiseur.
void setMode(eMode new_mode)
Positionne le fonctionnement actuel.
char * copy(char *to, const char *from)
Copie from dans to.
ConstArrayView< Byte > ByteConstArrayView
Equivalent C d'un tableau à une dimension de caractères.
Definition UtilsTypes.h:634
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:638
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
std::int64_t Int64
Type entier signé sur 64 bits.