Arcane  v3.16.6.0
Documentation développeur
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 {
36 typedef void (T::*FuncPtrWithInfo)(const Int32ConstArrayView* info);
37
39 typedef void (T::*FuncPtr)();
40 };
41
42 public:
43
45 virtual ~IItemGroupObserver() = default;
46
55 virtual void executeExtend(const Int32ConstArrayView* info) = 0;
56
71 virtual void executeReduce(const Int32ConstArrayView* info) = 0;
72
79 virtual void executeCompact(const Int32ConstArrayView* info) = 0;
80
86 virtual void executeInvalidate() = 0;
87
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 {
132 }
133
134 void executeInvalidate() override
135 {
137 }
138
139 bool needInfo() const override { return true; }
140
141 private:
142
143 T* m_object = nullptr;
148};
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
153template <typename T>
155: public IItemGroupObserver
156{
157 public:
158
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;
196};
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
202template <typename T>
205{
206 return new ItemGroupObserverWithoutInfoT<T>(object, funcptr);
207}
208
209/*---------------------------------------------------------------------------*/
210/*---------------------------------------------------------------------------*/
211
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.
FuncTraits< T >::FuncPtrWithInfo m_reduce_function
Pointeur vers la méthode associée.
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.
FuncTraits< T >::FuncPtrWithInfo m_extend_function
Pointeur vers la méthode associée.
FuncTraits< T >::FuncPtrWithInfo m_compact_function
Pointeur vers la méthode associée.
void executeExtend(const Int32ConstArrayView *info) override
Execute l'action associée à l'extension.
void executeInvalidate() override
Execute l'action associée à l'invalidation.
FuncTraits< T >::FuncPtr m_invalidate_function
Pointeur vers la méthode associée.
void executeCompact(const Int32ConstArrayView *info) override
Éxecute l'action associée au compactage.
FuncTraits< T >::FuncPtr m_function
Pointeur vers la méthode associée.
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.