Skip to content

Commit d592007

Browse files
Merge pull request #2013 from arcaneframework/dev/gg-add-event-for-add-remove-item
Add support for notification when adding/removing items.
2 parents 3f556f0 + dd41e3a commit d592007

14 files changed

+462
-182
lines changed

arcane/src/arcane/core/ArcaneTypes.h

+22
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class MeshBuildInfo;
118118
class MeshKind;
119119
class IPrimaryMesh;
120120
class IMeshInitialAllocator;
121+
class ItemFamilyCompactInfos;
122+
class ItemFamilyItemListChangedEventArgs;
121123
class ItemPairEnumerator;
122124
class ItemInfoListView;
123125
class ItemGenericInfoListView;
@@ -147,6 +149,14 @@ class IParallelMngInternal;
147149
class IIOMng;
148150
class ITimerMng;
149151
class IThreadMng;
152+
class ItemUniqueId;
153+
class IItemConnectivityInfo;
154+
class IItemConnectivity;
155+
class IItemInternalSortFunction;
156+
class IItemConnectivityMng;
157+
class Properties;
158+
class IItemFamilyTopologyModifier;
159+
class IItemFamilyPolicyMng;
150160
enum class eMeshStructure;
151161
enum class eMeshAMRKind;
152162

@@ -549,6 +559,18 @@ class AcceleratorRuntimeInitialisationInfo;
549559
using Accelerator::IAcceleratorMng;
550560
using Accelerator::AcceleratorRuntimeInitialisationInfo;
551561

562+
/*---------------------------------------------------------------------------*/
563+
/*---------------------------------------------------------------------------*/
564+
// Déclarations de types utilisés pour les classes 'friend'.
565+
namespace mesh
566+
{
567+
class DynamicMesh;
568+
class ItemFamily;
569+
class ItemSharedInfoWithType;
570+
class DynamicMeshKindInfos;
571+
class ItemDataList;
572+
}
573+
552574
/*---------------------------------------------------------------------------*/
553575
/*---------------------------------------------------------------------------*/
554576

arcane/src/arcane/core/IItemFamily.h

+15-37
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,30 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* IItemFamily.h (C) 2000-2024 */
8+
/* IItemFamily.h (C) 2000-2025 */
99
/* */
1010
/* Interface d'une famille d'entités. */
1111
/*---------------------------------------------------------------------------*/
12-
#ifndef ARCANE_IITEMFAMILY_H
13-
#define ARCANE_IITEMFAMILY_H
12+
#ifndef ARCANE_CORE_IITEMFAMILY_H
13+
#define ARCANE_CORE_IITEMFAMILY_H
1414
/*---------------------------------------------------------------------------*/
1515
/*---------------------------------------------------------------------------*/
1616

17-
#include "arcane/ArcaneTypes.h"
18-
#include "arcane/ItemTypes.h"
19-
#include "arcane/VariableTypedef.h"
20-
#include "arcane/Parallel.h"
17+
#include "arcane/core/ArcaneTypes.h"
18+
#include "arcane/core/ItemTypes.h"
19+
#include "arcane/core/VariableTypedef.h"
20+
#include "arcane/core/Parallel.h"
2121

2222
/*---------------------------------------------------------------------------*/
2323
/*---------------------------------------------------------------------------*/
2424

2525
namespace Arcane
2626
{
2727

28-
/*---------------------------------------------------------------------------*/
29-
/*---------------------------------------------------------------------------*/
30-
31-
class IParallelMng;
32-
class IDataOperation;
33-
class ItemUniqueId;
34-
class IItemInternalSortFunction;
35-
class IVariableSynchronizer;
36-
class IParticleFamily;
37-
class GroupIndexTable;
38-
class IItemConnectivityInfo;
39-
class IItemConnectivityMng;
40-
class IItemConnectivity;
41-
class IExtraGhostItemsBuilder;
42-
class IIncrementalItemConnectivity;
43-
class IItemFamilyPolicyMng;
44-
class IItemFamilyTopologyModifier;
45-
class ItemInternalConnectivityList;
46-
class Properties;
47-
48-
namespace mesh
49-
{
50-
class ItemDataList;
51-
class DynamicMesh;
52-
class ItemFamily;
53-
}
54-
5528
/*---------------------------------------------------------------------------*/
5629
/*---------------------------------------------------------------------------*/
5730
/*!
@@ -109,8 +82,8 @@ namespace mesh
10982
*/
11083
class ARCANE_CORE_EXPORT IItemFamily
11184
{
112-
friend class mesh::DynamicMesh;
113-
friend class mesh::ItemFamily;
85+
friend mesh::DynamicMesh;
86+
friend mesh::ItemFamily;
11487

11588
public:
11689

@@ -706,6 +679,11 @@ class ARCANE_CORE_EXPORT IItemFamily
706679
//! Propriétés associées à cette famille.
707680
virtual Properties* properties() =0;
708681

682+
public:
683+
684+
//! Evènement pour l'ajout et la suppression d'entité
685+
virtual EventObservableView<const ItemFamilyItemListChangedEventArgs&> itemListChangedEvent() = 0;
686+
709687
public:
710688

711689
/*!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
/* ItemFamilyItemListChangedEventArgs.h (C) 2000-2025 */
9+
/* */
10+
/* Arguments de l'évènement pour l'ajout ou la supression d'entités. */
11+
/*---------------------------------------------------------------------------*/
12+
#ifndef ARCANE_CORE_ITEMFAMILYITEMLISTCHANGEDARGS_H
13+
#define ARCANE_CORE_ITEMFAMILYITEMLISTCHANGEDARGS_H
14+
/*---------------------------------------------------------------------------*/
15+
/*---------------------------------------------------------------------------*/
16+
17+
#include "arcane/utils/ArrayView.h"
18+
#include "arcane/utils/UtilsTypes.h"
19+
20+
/*---------------------------------------------------------------------------*/
21+
/*---------------------------------------------------------------------------*/
22+
23+
namespace Arcane
24+
{
25+
26+
/*---------------------------------------------------------------------------*/
27+
/*---------------------------------------------------------------------------*/
28+
/*!
29+
* \ingroup Mesh
30+
* \brief Arguments de l'évènement pour l'ajout ou la supression d'entités.
31+
*/
32+
class ARCANE_CORE_EXPORT ItemFamilyItemListChangedEventArgs
33+
{
34+
friend mesh::DynamicMeshKindInfos;
35+
36+
private:
37+
38+
//! Constructeur. Uniquement pour DynamicMeshKindInfos.
39+
ItemFamilyItemListChangedEventArgs() = default;
40+
ItemFamilyItemListChangedEventArgs(IItemFamily* item_family, Int32 local_id, Int64 unique_id)
41+
: m_item_family(item_family)
42+
, m_local_id(local_id)
43+
, m_unique_id(unique_id)
44+
{}
45+
46+
public:
47+
48+
IItemFamily* itemFamily() const { return m_item_family; }
49+
Int32 localId() const { return m_local_id; }
50+
Int64 uniqueId() const { return m_unique_id; }
51+
bool isAdd() const { return m_is_add; }
52+
53+
public:
54+
55+
void setIsAdd(bool v) { m_is_add = v; }
56+
57+
private:
58+
59+
IItemFamily* m_item_family = nullptr;
60+
Int32 m_local_id = NULL_ITEM_LOCAL_ID;
61+
Int64 m_unique_id = NULL_ITEM_UNIQUE_ID;
62+
bool m_is_add = false;
63+
};
64+
65+
/*---------------------------------------------------------------------------*/
66+
/*---------------------------------------------------------------------------*/
67+
68+
} // namespace Arcane
69+
70+
/*---------------------------------------------------------------------------*/
71+
/*---------------------------------------------------------------------------*/
72+
73+
#endif

arcane/src/arcane/core/srcs.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ set(ARCANE_ORIGINAL_SOURCES
307307
ItemEnumerator.h
308308
ItemEnumeratorBase.h
309309
ItemFamilyCompactInfos.h
310+
ItemFamilyItemListChangedEventArgs.h
310311
ItemFamilySerializeArgs.h
311312
ItemFlags.h
312313
ItemFunctor.cc

arcane/src/arcane/mesh/DynamicMeshKindInfos.cc

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* DynamicMeshKindInfos.cc (C) 2000-2024 */
8+
/* DynamicMeshKindInfos.cc (C) 2000-2025 */
99
/* */
1010
/* Infos de maillage pour un genre d'entité donnée. */
1111
/*---------------------------------------------------------------------------*/
@@ -27,6 +27,7 @@
2727
#include "arcane/core/ItemFamilyCompactInfos.h"
2828
#include "arcane/core/IMeshCompacter.h"
2929
#include "arcane/core/MeshPartInfo.h"
30+
#include "arcane/core/ItemFamilyItemListChangedEventArgs.h"
3031

3132
#include "arcane/mesh/DynamicMeshKindInfos.h"
3233
#include "arcane/mesh/ItemFamily.h"
@@ -916,6 +917,37 @@ _updateItemSharedInfoInternalView()
916917
/*---------------------------------------------------------------------------*/
917918
/*---------------------------------------------------------------------------*/
918919

920+
EventObservableView<const ItemFamilyItemListChangedEventArgs&> DynamicMeshKindInfos::
921+
itemListChangedEvent()
922+
{
923+
return EventObservableView<const ItemFamilyItemListChangedEventArgs&>(m_item_list_change_event);
924+
}
925+
926+
/*---------------------------------------------------------------------------*/
927+
/*---------------------------------------------------------------------------*/
928+
929+
void DynamicMeshKindInfos::
930+
_notifyRemove2(ItemInternal* item)
931+
{
932+
ItemFamilyItemListChangedEventArgs args(m_item_family,item->localId(),item->uniqueId());
933+
m_item_list_change_event.notify(args);
934+
args.setIsAdd(false);
935+
}
936+
937+
/*---------------------------------------------------------------------------*/
938+
/*---------------------------------------------------------------------------*/
939+
940+
void DynamicMeshKindInfos::
941+
_notifyAdd2(ItemInternal* item,Int64 uid)
942+
{
943+
ItemFamilyItemListChangedEventArgs args(m_item_family,item->localId(),uid);
944+
args.setIsAdd(true);
945+
m_item_list_change_event.notify(args);
946+
}
947+
948+
/*---------------------------------------------------------------------------*/
949+
/*---------------------------------------------------------------------------*/
950+
919951
} // End namespace Arcane::mesh
920952

921953
/*---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)