Arcane  v3.16.4.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
core/ItemGroupObserver.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ItemGroupObserver.h (C) 2000-2025 */
9/* */
10/* Interface et implémentation basique des observeurs de groupe. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMGROUPOBSERVER_H
13#define ARCANE_CORE_ITEMGROUPOBSERVER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
29{
30 public:
31
32 template <typename T>
34 {
35 //! Type du pointeur sur la méthode avec Infos
36 typedef void (T::*FuncPtrWithInfo)(const Int32ConstArrayView* info);
37
38 //! Type du pointeur sur la méthode sans Infos
39 typedef void (T::*FuncPtr)();
40 };
41
42 public:
43
44 //! Destructeur
45 virtual ~IItemGroupObserver() = default;
46
47 /*!
48 * \brief Execute l'action associée à l'extension.
49 *
50 * \param info liste des localIds ajoutés
51 * Suppose qu'il n'y a pas de changement d'ordre ou de renumérotation.
52 *
53 * Cette méthode ne peut pas être parallèle.
54 */
55 virtual void executeExtend(const Int32ConstArrayView* info) = 0;
56
57 /*!
58 * \brief Execute l'action associée à l'extension.
59 *
60 * \param info liste des positions supprimées dans l'ancien groupe
61 * Suppose qu'il n'y a pas de changement d'ordre ou de renumérotation
62 * Cette approche par rapport à la liste des localIds est motivée par
63 * la contrainte dans PartialVariable qui n'a pas connaissance des localIds
64 * qu'il héberge.
65 * \param info2 liste des localIds des éléments supprimés. Potentiellement redondant
66 * avec \a info, mais inévitable pour certaines structures changeant l'ordre par rapport
67 * au groupe de référence (ex: ItemGroupDynamicMeshObserver) (DEPRECATED)
68 *
69 * Cette méthode ne peut pas être parallèle.
70 */
71 virtual void executeReduce(const Int32ConstArrayView* info) = 0;
72
73 /*!
74 * \brief Éxecute l'action associée au compactage.
75 *
76 * \param info liste des permutations dans le sens old->new
77 * Suppose qu'il n'y a pas de changement de taille.
78 */
79 virtual void executeCompact(const Int32ConstArrayView* info) = 0;
80
81 /*!
82 * \brief Execute l'action associée à l'invalidation.
83 *
84 * Aucune information de transition disponible.
85 */
86 virtual void executeInvalidate() = 0;
87
88 /*!
89 * \brief Indique si l'observer aura besoin d'information de transition
90 *
91 * Cette information ne doit pas changer après le premier appel à cet fonction
92 */
93 virtual bool needInfo() const = 0;
94};
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99template <typename T>
100class ItemGroupObserverWithInfoT
101: public IItemGroupObserver
102{
103 public:
104
105 ItemGroupObserverWithInfoT(T* object,
106 typename FuncTraits<T>::FuncPtrWithInfo extend_funcptr,
107 typename FuncTraits<T>::FuncPtrWithInfo reduce_funcptr,
108 typename FuncTraits<T>::FuncPtrWithInfo compact_funcptr,
109 typename FuncTraits<T>::FuncPtr invalidate_funcptr)
110 : m_object(object)
111 , m_extend_function(extend_funcptr)
112 , m_reduce_function(reduce_funcptr)
113 , m_compact_function(compact_funcptr)
114 , m_invalidate_function(invalidate_funcptr)
115 {}
116
117 public:
118
119 void executeExtend(const Int32ConstArrayView* info) override
120 {
121 (m_object->*m_extend_function)(info);
122 }
123
124 void executeReduce(const Int32ConstArrayView* info) override
125 {
126 (m_object->*m_reduce_function)(info);
127 }
128
129 void executeCompact(const Int32ConstArrayView* info) override
130 {
131 (m_object->*m_compact_function)(info);
132 }
133
134 void executeInvalidate() override
135 {
136 (m_object->*m_invalidate_function)();
137 }
138
139 bool needInfo() const override { return true; }
140
141 private:
142
143 T* m_object = nullptr; //!< Objet associé.
144 typename FuncTraits<T>::FuncPtrWithInfo m_extend_function = nullptr; //!< Pointeur vers la méthode associée.
145 typename FuncTraits<T>::FuncPtrWithInfo m_reduce_function = nullptr; //!< Pointeur vers la méthode associée.
146 typename FuncTraits<T>::FuncPtrWithInfo m_compact_function = nullptr; //!< Pointeur vers la méthode associée.
147 typename FuncTraits<T>::FuncPtr m_invalidate_function = nullptr; //!< Pointeur vers la méthode associée.
148};
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
153template <typename T>
155: public IItemGroupObserver
156{
157 public:
158
159 //! Constructeur à partir d'une unique fonction sans argument
161 : m_object(object)
162 , m_function(funcptr)
163 {}
164
165 public:
166
167 void executeExtend(const Int32ConstArrayView*) override
168 {
169 (m_object->*m_function)();
170 }
171
172 void executeReduce(const Int32ConstArrayView*) override
173 {
174 (m_object->*m_function)();
175 }
176
178 {
179 (m_object->*m_function)();
180 }
181
182 void executeInvalidate() override
183 {
184 (m_object->*m_function)();
185 }
186
187 bool needInfo() const override
188 {
189 return false;
190 }
191
192 private:
193
194 T* m_object = nullptr; //!< Objet associé.
195 typename FuncTraits<T>::FuncPtr m_function = nullptr; //!< Pointeur vers la méthode associée.
196};
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
201//! Utilitaire pour création simplifié de ItemGroupObserverT
202template <typename T>
205{
206 return new ItemGroupObserverWithoutInfoT<T>(object, funcptr);
207}
208
209/*---------------------------------------------------------------------------*/
210/*---------------------------------------------------------------------------*/
211
212//! Utilitaire pour création simplifié de ItemGroupObserverT
213template <typename T> inline IItemGroupObserver*
218 typename IItemGroupObserver::FuncTraits<T>::FuncPtr invalidate_funcptr)
219{
220 return new ItemGroupObserverWithInfoT<T>(object, extend_funcptr, reduce_funcptr, compact_funcptr, invalidate_funcptr);
221}
222
223/*---------------------------------------------------------------------------*/
224/*---------------------------------------------------------------------------*/
225
226} // namespace Arcane
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231#endif
Déclarations de types sur les entités.
virtual ~IItemGroupObserver()=default
Destructeur.
virtual bool needInfo() const =0
Indique si l'observer aura besoin d'information de transition.
virtual void executeExtend(const Int32ConstArrayView *info)=0
Execute l'action associée à l'extension.
virtual void executeInvalidate()=0
Execute l'action associée à l'invalidation.
virtual void executeCompact(const Int32ConstArrayView *info)=0
Éxecute l'action associée au compactage.
virtual void executeReduce(const Int32ConstArrayView *info)=0
Execute l'action associée à l'extension.
void executeReduce(const Int32ConstArrayView *info) override
Execute l'action associée à l'extension.
bool needInfo() const override
Indique si l'observer aura besoin d'information de transition.
void executeExtend(const Int32ConstArrayView *info) override
Execute l'action associée à l'extension.
void executeInvalidate() override
Execute l'action associée à l'invalidation.
void executeCompact(const Int32ConstArrayView *info) override
Éxecute l'action associée au compactage.
ItemGroupObserverWithoutInfoT(T *object, typename FuncTraits< T >::FuncPtr funcptr)
Constructeur à partir d'une unique fonction sans argument.
void executeCompact(const Int32ConstArrayView *) override
Éxecute l'action associée au compactage.
void executeInvalidate() override
Execute l'action associée à l'invalidation.
bool needInfo() const override
Indique si l'observer aura besoin d'information de transition.
void executeExtend(const Int32ConstArrayView *) override
Execute l'action associée à l'extension.
void executeReduce(const Int32ConstArrayView *) override
Execute l'action associée à l'extension.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:569
IItemGroupObserver * newItemGroupObserverT(T *object, typename IItemGroupObserver::FuncTraits< T >::FuncPtr funcptr)
Utilitaire pour création simplifié de ItemGroupObserverT.
void(T::* FuncPtr)()
Type du pointeur sur la méthode sans Infos.
void(T::* FuncPtrWithInfo)(const Int32ConstArrayView *info)
Type du pointeur sur la méthode avec Infos.