Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
RawCopy.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* RawCopy.h (C) 2008 */
9/* */
10/* Structure de copie brute sans controle arithmétique. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_RAWCOPY_H
13#define ARCANE_RAWCOPY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20ARCANE_BEGIN_NAMESPACE
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25template<typename T> struct RawCopy { };
26
27// Specify specialization for all types to remove all implicit implementation
28// (when a new Arcane POD type will appear)
29
30template<>
31struct RawCopy<Byte> {
32 typedef Byte T;
33 inline static void copy(T & dst, const T & src) { dst = src; }
34};
35
36// Types without problem
37
38template<>
39struct RawCopy<Int16> {
40 typedef Int16 T;
41 inline static void copy(T & dst, const T & src) { dst = src; }
42};
43
44template<>
45struct RawCopy<Int32> {
46 typedef Int32 T;
47 inline static void copy(T & dst, const T & src) { dst = src; }
48};
49
50template<>
51struct RawCopy<Int64> {
52 typedef Int64 T;
53 inline static void copy(T & dst, const T & src) { dst = src; }
54};
55
56template<>
57struct RawCopy<String> {
58 typedef String T;
59 inline static void copy(T & dst, const T & src) { dst = src; }
60};
61
62// Types with problems
63
64#ifdef ARCANE_RAWCOPY
65
66#ifndef NO_USER_WARNING
67#warning "Using RawCopy for compact Variables"
68#endif /* NO_USER_WARNING */
69
70template<>
71struct RawCopy<Real> {
72 typedef Real T;
73 inline static void copy(T & dst, const T & src) {
74 reinterpret_cast<Int64&>(dst) = reinterpret_cast<const Int64&>(src);
75 }
76};
77
78template<>
79struct RawCopy<Real2> {
80 typedef Real2 T;
81 inline static void copy(T & dst, const T & src) {
82 reinterpret_cast<Int64&>(dst.x) = reinterpret_cast<const Int64&>(src.x);
83 reinterpret_cast<Int64&>(dst.y) = reinterpret_cast<const Int64&>(src.y);
84 }
85};
86
87template<>
88struct RawCopy<Real3> {
89 typedef Real3 T;
90 inline static void copy(T & dst, const T & src) {
91 reinterpret_cast<Int64&>(dst.x) = reinterpret_cast<const Int64&>(src.x);
92 reinterpret_cast<Int64&>(dst.y) = reinterpret_cast<const Int64&>(src.y);
93 reinterpret_cast<Int64&>(dst.z) = reinterpret_cast<const Int64&>(src.z);
94 }
95};
96
97template<>
98struct RawCopy<Real2x2> {
99 typedef Real2x2 T;
100 inline static void copy(T & dst, const T & src) {
101 reinterpret_cast<Int64&>(dst.x.x) = reinterpret_cast<const Int64&>(src.x.x);
102 reinterpret_cast<Int64&>(dst.x.y) = reinterpret_cast<const Int64&>(src.x.y);
103 reinterpret_cast<Int64&>(dst.y.x) = reinterpret_cast<const Int64&>(src.y.x);
104 reinterpret_cast<Int64&>(dst.y.y) = reinterpret_cast<const Int64&>(src.y.y);
105 }
106};
107
108template<>
109struct RawCopy<Real3x3> {
110 typedef Real3x3 T;
111 inline static void copy(T & dst, const T & src) {
112 reinterpret_cast<Int64&>(dst.x.x) = reinterpret_cast<const Int64&>(src.x.x);
113 reinterpret_cast<Int64&>(dst.x.y) = reinterpret_cast<const Int64&>(src.x.y);
114 reinterpret_cast<Int64&>(dst.x.z) = reinterpret_cast<const Int64&>(src.x.z);
115 reinterpret_cast<Int64&>(dst.y.x) = reinterpret_cast<const Int64&>(src.y.x);
116 reinterpret_cast<Int64&>(dst.y.y) = reinterpret_cast<const Int64&>(src.y.y);
117 reinterpret_cast<Int64&>(dst.y.z) = reinterpret_cast<const Int64&>(src.y.z);
118 reinterpret_cast<Int64&>(dst.z.x) = reinterpret_cast<const Int64&>(src.z.x);
119 reinterpret_cast<Int64&>(dst.z.y) = reinterpret_cast<const Int64&>(src.z.y);
120 reinterpret_cast<Int64&>(dst.z.z) = reinterpret_cast<const Int64&>(src.z.z);
121 }
122};
123
124#else /* ARCANE_RAWCOPY */
125
126template<>
127struct RawCopy<Real> {
128 typedef Real T;
129 inline static void copy(T & dst, const T & src) { dst = src; }
130};
131
132template<>
133struct RawCopy<Real2> {
134 typedef Real2 T;
135 inline static void copy(T & dst, const T & src) { dst = src; }
136};
137
138template<>
139struct RawCopy<Real3> {
140 typedef Real3 T;
141 inline static void copy(T & dst, const T & src) { dst = src; }
142};
143
144template<>
146 typedef Real2x2 T;
147 inline static void copy(T & dst, const T & src) { dst = src; }
148};
149
150template<>
152 typedef Real3x3 T;
153 inline static void copy(T & dst, const T & src) { dst = src; }
154};
155
156#endif /* ARCANE_RAWCOPY */
157
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162ARCANE_END_NAMESPACE
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
167#endif
168
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Classe gérant une matrice de réel de dimension 3x3.
Definition Real3x3.h:66
Chaîne de caractères unicode.
char * copy(char *to, const char *from)
Copie from dans to.