Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for notification when adding/removing items. #2013

Merged
merged 6 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions arcane/src/arcane/core/ArcaneTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class MeshBuildInfo;
class MeshKind;
class IPrimaryMesh;
class IMeshInitialAllocator;
class ItemFamilyCompactInfos;
class ItemFamilyItemListChangedEventArgs;
class ItemPairEnumerator;
class ItemInfoListView;
class ItemGenericInfoListView;
Expand Down Expand Up @@ -147,6 +149,14 @@ class IParallelMngInternal;
class IIOMng;
class ITimerMng;
class IThreadMng;
class ItemUniqueId;
class IItemConnectivityInfo;
class IItemConnectivity;
class IItemInternalSortFunction;
class IItemConnectivityMng;
class Properties;
class IItemFamilyTopologyModifier;
class IItemFamilyPolicyMng;
enum class eMeshStructure;
enum class eMeshAMRKind;

Expand Down Expand Up @@ -549,6 +559,18 @@ class AcceleratorRuntimeInitialisationInfo;
using Accelerator::IAcceleratorMng;
using Accelerator::AcceleratorRuntimeInitialisationInfo;

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
// Déclarations de types utilisés pour les classes 'friend'.
namespace mesh
{
class DynamicMesh;
class ItemFamily;
class ItemSharedInfoWithType;
class DynamicMeshKindInfos;
class ItemDataList;
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

Expand Down
52 changes: 15 additions & 37 deletions arcane/src/arcane/core/IItemFamily.h
Original file line number Diff line number Diff line change
@@ -1,57 +1,30 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* IItemFamily.h (C) 2000-2024 */
/* IItemFamily.h (C) 2000-2025 */
/* */
/* Interface d'une famille d'entités. */
/*---------------------------------------------------------------------------*/
#ifndef ARCANE_IITEMFAMILY_H
#define ARCANE_IITEMFAMILY_H
#ifndef ARCANE_CORE_IITEMFAMILY_H
#define ARCANE_CORE_IITEMFAMILY_H
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "arcane/ArcaneTypes.h"
#include "arcane/ItemTypes.h"
#include "arcane/VariableTypedef.h"
#include "arcane/Parallel.h"
#include "arcane/core/ArcaneTypes.h"
#include "arcane/core/ItemTypes.h"
#include "arcane/core/VariableTypedef.h"
#include "arcane/core/Parallel.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

namespace Arcane
{

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

class IParallelMng;
class IDataOperation;
class ItemUniqueId;
class IItemInternalSortFunction;
class IVariableSynchronizer;
class IParticleFamily;
class GroupIndexTable;
class IItemConnectivityInfo;
class IItemConnectivityMng;
class IItemConnectivity;
class IExtraGhostItemsBuilder;
class IIncrementalItemConnectivity;
class IItemFamilyPolicyMng;
class IItemFamilyTopologyModifier;
class ItemInternalConnectivityList;
class Properties;

namespace mesh
{
class ItemDataList;
class DynamicMesh;
class ItemFamily;
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
Expand Down Expand Up @@ -109,8 +82,8 @@ namespace mesh
*/
class ARCANE_CORE_EXPORT IItemFamily
{
friend class mesh::DynamicMesh;
friend class mesh::ItemFamily;
friend mesh::DynamicMesh;
friend mesh::ItemFamily;

public:

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

public:

//! Evènement pour l'ajout et la suppression d'entité
virtual EventObservableView<const ItemFamilyItemListChangedEventArgs&> itemListChangedEvent() = 0;

public:

/*!
Expand Down
73 changes: 73 additions & 0 deletions arcane/src/arcane/core/ItemFamilyItemListChangedEventArgs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ItemFamilyItemListChangedEventArgs.h (C) 2000-2025 */
/* */
/* Arguments de l'évènement pour l'ajout ou la supression d'entités. */
/*---------------------------------------------------------------------------*/
#ifndef ARCANE_CORE_ITEMFAMILYITEMLISTCHANGEDARGS_H
#define ARCANE_CORE_ITEMFAMILYITEMLISTCHANGEDARGS_H
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "arcane/utils/ArrayView.h"
#include "arcane/utils/UtilsTypes.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

namespace Arcane
{

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
* \ingroup Mesh
* \brief Arguments de l'évènement pour l'ajout ou la supression d'entités.
*/
class ARCANE_CORE_EXPORT ItemFamilyItemListChangedEventArgs
{
friend mesh::DynamicMeshKindInfos;

private:

//! Constructeur. Uniquement pour DynamicMeshKindInfos.
ItemFamilyItemListChangedEventArgs() = default;
ItemFamilyItemListChangedEventArgs(IItemFamily* item_family, Int32 local_id, Int64 unique_id)
: m_item_family(item_family)
, m_local_id(local_id)
, m_unique_id(unique_id)
{}

public:

IItemFamily* itemFamily() const { return m_item_family; }
Int32 localId() const { return m_local_id; }
Int64 uniqueId() const { return m_unique_id; }
bool isAdd() const { return m_is_add; }

public:

void setIsAdd(bool v) { m_is_add = v; }

private:

IItemFamily* m_item_family = nullptr;
Int32 m_local_id = NULL_ITEM_LOCAL_ID;
Int64 m_unique_id = NULL_ITEM_UNIQUE_ID;
bool m_is_add = false;
};

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

} // namespace Arcane

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#endif
1 change: 1 addition & 0 deletions arcane/src/arcane/core/srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ set(ARCANE_ORIGINAL_SOURCES
ItemEnumerator.h
ItemEnumeratorBase.h
ItemFamilyCompactInfos.h
ItemFamilyItemListChangedEventArgs.h
ItemFamilySerializeArgs.h
ItemFlags.h
ItemFunctor.cc
Expand Down
36 changes: 34 additions & 2 deletions arcane/src/arcane/mesh/DynamicMeshKindInfos.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* DynamicMeshKindInfos.cc (C) 2000-2024 */
/* DynamicMeshKindInfos.cc (C) 2000-2025 */
/* */
/* Infos de maillage pour un genre d'entité donnée. */
/*---------------------------------------------------------------------------*/
Expand All @@ -27,6 +27,7 @@
#include "arcane/core/ItemFamilyCompactInfos.h"
#include "arcane/core/IMeshCompacter.h"
#include "arcane/core/MeshPartInfo.h"
#include "arcane/core/ItemFamilyItemListChangedEventArgs.h"

#include "arcane/mesh/DynamicMeshKindInfos.h"
#include "arcane/mesh/ItemFamily.h"
Expand Down Expand Up @@ -916,6 +917,37 @@
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

EventObservableView<const ItemFamilyItemListChangedEventArgs&> DynamicMeshKindInfos::
itemListChangedEvent()
{
return EventObservableView<const ItemFamilyItemListChangedEventArgs&>(m_item_list_change_event);
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

void DynamicMeshKindInfos::

Check warning on line 929 in arcane/src/arcane/mesh/DynamicMeshKindInfos.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/mesh/DynamicMeshKindInfos.cc#L929

Added line #L929 was not covered by tests
_notifyRemove2(ItemInternal* item)
{
ItemFamilyItemListChangedEventArgs args(m_item_family,item->localId(),item->uniqueId());
m_item_list_change_event.notify(args);
args.setIsAdd(false);

Check warning on line 934 in arcane/src/arcane/mesh/DynamicMeshKindInfos.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/mesh/DynamicMeshKindInfos.cc#L932-L934

Added lines #L932 - L934 were not covered by tests
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

void DynamicMeshKindInfos::
_notifyAdd2(ItemInternal* item,Int64 uid)
{
ItemFamilyItemListChangedEventArgs args(m_item_family,item->localId(),uid);
args.setIsAdd(true);
m_item_list_change_event.notify(args);
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

} // End namespace Arcane::mesh

/*---------------------------------------------------------------------------*/
Expand Down
Loading
Loading