TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Declare_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
17// .SECTION Description
18// les macros Declare_base_sans_destructeur et
19// Implemente_base_sans_destructeur
20// permettent de creer simplement des classes
21// de bases conforme a TRUST.
22
23// .SECTION Description du header
24// class A_base : public B {
25// Declare_base_sans_destructeur(A_base);
26// };
27// .SECTION Description du source
28// Implemente_base_sans_destructeur(A_base, "A_base", B);
29
30#include <arch.h>
31
32#ifdef LATATOOLS
33#define Declare_base_sans_constructeur_ni_destructeur_ni_readon(_TYPE_) \
34 public : \
35 unsigned taille_memoire() const override { return 0; }; \
36 int duplique() const override { return 0; }; \
37 protected : \
38 Sortie& printOn(Sortie& x) const override
39
40#define Implemente_base_sans_constructeur_ni_destructeur(_TYPE_,_NOM_,_BASE_)
41
42#else
43#include <Cast.h>
44#include <Type_info.h>
45#define Declare_base_sans_constructeur_ni_destructeur_ni_readon(_TYPE_) \
46 \
47 public : \
48 static const Type_info info_obj; \
49 static const Type_info* info(); \
50 const Type_info* get_info() const override; \
51 /* methode rajoutee pour caster en python */ \
52 static _TYPE_& self_cast( Objet_U&) ; \
53 static const _TYPE_& self_cast(const Objet_U&) ; \
54 protected : \
55 Sortie& printOn(Sortie& x) const override
56
57
58#define Implemente_base_sans_constructeur_ni_destructeur(_TYPE_,_NOM_,_BASE_) \
59 \
60 const Type_info* name2(_TYPE_,bases)[1]={ \
61 &(_BASE_::info_obj)}; \
62 const Type_info _TYPE_::info_obj(_NOM_, 1, name2(_TYPE_,bases)); \
63 \
64 _TYPE_& _TYPE_::self_cast( Objet_U& r) { \
65 return ref_cast_non_const(_TYPE_,r); /* _non_const important sinon recursion dans ref_cast */ \
66 } \
67 const _TYPE_& _TYPE_::self_cast(const Objet_U& r) { \
68 return ref_cast_non_const(_TYPE_,r); /* _non_const important sinon recursion dans ref_cast */ \
69 } \
70 const Type_info* _TYPE_::get_info() const { \
71 return &info_obj; \
72 } \
73 const Type_info* _TYPE_::info() { \
74 return &info_obj; \
75 } \
76 class __dummy__
77#endif
78
79/////////////////////////////////////////
80/////// Those are shared with LATATOOLS
81/////////////////////////////////////////
82
83#define Declare_base_sans_constructeur_ni_destructeur(_TYPE_) \
84 Declare_base_sans_constructeur_ni_destructeur_ni_readon(_TYPE_); \
85 Entree& readOn(Entree&) override
86
87#define Declare_base_sans_constructeur(_TYPE_) \
88 public: \
89 ~_TYPE_() override; \
90 Declare_base_sans_constructeur_ni_destructeur(_TYPE_)
91
92#define Declare_base_sans_destructeur(_TYPE_) \
93 public: \
94 _TYPE_(); \
95 Declare_base_sans_constructeur_ni_destructeur(_TYPE_)
96
97#define Declare_base(_TYPE_) \
98 public: \
99 _TYPE_(); \
100 ~_TYPE_() override; \
101 Declare_base_sans_constructeur_ni_destructeur(_TYPE_)
102
103#define Declare_base_sans_readon(_TYPE_) \
104 public: \
105 _TYPE_(); \
106 ~_TYPE_() override; \
107 Declare_base_sans_constructeur_ni_destructeur_ni_readon(_TYPE_)
108
109#define Declare_base_with_param(_TYPE_) \
110 Declare_base_sans_readon(_TYPE_); \
111 protected: \
112 void set_param(Param&) const override
113
114#define Implemente_base_sans_constructeur(_TYPE_,_NOM_,_BASE_) \
115 _TYPE_::~_TYPE_() { } \
116 Implemente_base_sans_constructeur_ni_destructeur(_TYPE_,_NOM_,_BASE_)
117
118#define Implemente_base_sans_destructeur(_TYPE_,_NOM_,_BASE_) \
119 _TYPE_::_TYPE_() { } \
120 Implemente_base_sans_constructeur_ni_destructeur(_TYPE_,_NOM_,_BASE_)
121
122#define Implemente_base(_TYPE_,_NOM_,_BASE_) \
123 _TYPE_::_TYPE_() { } \
124 _TYPE_::~_TYPE_() { } \
125 Implemente_base_sans_constructeur_ni_destructeur(_TYPE_,_NOM_,_BASE_)
126
127
128/////////////////////////////////////////
129/////// TEMPLATE VERSION for 32/64 bits !!! Oh yes baby!
130/////////////////////////////////////////
131
132// The declare remain identical but we create a new macro so that bin/KSH/mk_Instanciable spots it correctly:
133#define Declare_base_sans_constructeur_ni_destructeur_32_64(_TYPE_) Declare_base_sans_constructeur_ni_destructeur(_TYPE_>)
134#define Declare_base_sans_constructeur_32_64(_TYPE_) Declare_base_sans_constructeur(_TYPE_)
135#define Declare_base_sans_destructeur_32_64(_TYPE_) Declare_base_sans_destructeur(_TYPE_)
136#define Declare_base_32_64(_TYPE_) Declare_base(_TYPE_)
137#define Declare_base_sans_readon_32_64(_TYPE_) Declare_base_sans_readon(_TYPE_)
138#define Declare_base_with_param_32_64(_TYPE_) Declare_base_with_param(_TYPE_)
139
140// Helper macro for info_obj static variable definition:
141#if INT_is_64_ == 2
142# define info_obj_def_macro_base(_NOM_, _TYPE_) \
143 template <> const Type_info _TYPE_<int>::info_obj(_NOM_, 1, name2(_TYPE_,bases)<int> ); \
144 template <> const Type_info _TYPE_<trustIdType>::info_obj(_NOM_ "_64", 1, name2(_TYPE_, bases)<trustIdType> );
145#else
146# define info_obj_def_macro_base(_NOM_, _TYPE_) \
147 template <> const Type_info _TYPE_<int>::info_obj(_NOM_, 1, name2(_TYPE_,bases)<int> );
148#endif
149
150#ifdef LATATOOLS
151#define Implemente_base_sans_constructeur_ni_destructeur_32_64(_TYPE_,_NOM_,_BASE_)
152
153#else
154// The implemente are of course different:
155#define Implemente_base_sans_constructeur_ni_destructeur_32_64(_TYPE_,_NOM_,_BASE_) \
156 \
157 template <typename _T_> const Type_info* name2(_TYPE_,bases)[1] = { &(_BASE_::info_obj) }; \
158 \
159 info_obj_def_macro_base(_NOM_, _TYPE_) \
160 \
161 template <typename _T_> _TYPE_<_T_>& _TYPE_<_T_>::self_cast( Objet_U& r) { \
162 return ref_cast_non_const(_TYPE_<_T_>,r); /* _non_const important sinon recursion dans ref_cast */ \
163 } \
164 template <typename _T_> const _TYPE_<_T_>& _TYPE_<_T_>::self_cast(const Objet_U& r) { \
165 return ref_cast_non_const(_TYPE_<_T_>,r); /* _non_const important sinon recursion dans ref_cast */ \
166 } \
167 template <typename _T_> const Type_info* _TYPE_<_T_>::get_info() const { \
168 return &info_obj; \
169 } \
170 template <typename _T_> const Type_info* _TYPE_<_T_>::info() { \
171 return &info_obj; \
172 } \
173 class __dummy__
174
175#endif // LATATOOLS
176
177#define Implemente_base_sans_constructeur_32_64(_TYPE_,_NOM_,_BASE_) \
178 template <typename _T_> _TYPE_<_T_>::~_TYPE_() { } \
179 Implemente_base_sans_constructeur_ni_destructeur_32_64(_TYPE_,_NOM_,_BASE_)
180
181#define Implemente_base_sans_destructeur_32_64(_TYPE_,_NOM_,_BASE_) \
182 template <typename _T_> _TYPE_<_T_>::_TYPE_() { } \
183 Implemente_base_sans_constructeur_ni_destructeur_32_64(_TYPE_,_NOM_,_BASE_)
184
185#define Implemente_base_32_64(_TYPE_,_NOM_,_BASE_) \
186 template <typename _T_> _TYPE_<_T_>::_TYPE_() { } \
187 template <typename _T_> _TYPE_<_T_>::~_TYPE_() { } \
188 Implemente_base_sans_constructeur_ni_destructeur_32_64(_TYPE_,_NOM_,_BASE_)
189