12#ifndef ARCANE_CORE_ANYITEM_ANYITEMFAMILY_H
13#define ARCANE_CORE_ANYITEM_ANYITEMFAMILY_H
17#include "arcane/utils/SharedPtr.h"
24#include "arcane/utils/FatalErrorException.h"
25#include "arcane/core/anyitem/AnyItemGlobal.h"
26#include "arcane/core/anyitem/AnyItemPrivate.h"
27#include "arcane/core/anyitem/AnyItemGroup.h"
28#include "arcane/core/anyitem/AnyItemFamilyObserver.h"
29#include "arcane/core/ItemGroupObserver.h"
34namespace Arcane::AnyItem
48 typedef std::set<IFamilyObserver*> FamilyObservers;
73 info.group =
group.internal();
74 info.group_index = size;
77 info.is_partial = builder.isPartial();
82 _notifyFamilyIsIncreased();
98 return info->is_partial;
114 return info->group_index;
123 return info->local_id_offset;
127 template <
typename AnyItemT>
132 const Integer group_index = any_item.groupIndex();
135 Integer index_in_group = any_item.localId() - info.local_id_offset;
165 m_groups[igrp].group->detachObserver(
this);
172 _notifyFamilyIsInvalidate();
178 FamilyObservers::const_iterator it =
m_observers.find(&observer);
187 FamilyObservers::const_iterator it =
m_observers.find(&observer);
202 void _notifyFamilyIsInvalidate()
205 (*it)->notifyFamilyIsInvalidate();
208 void _notifyFamilyIsIncreased()
211 (*it)->notifyFamilyIsIncreased();
214 void _notifyGroupHasChanged()
216 throw FatalErrorException(A_FUNCINFO,
"Group changes while registered in AnyItem::Family");
246 Family(
const Family& f)
257 Family& operator=(
const Family& f)
301 template <
typename AnyItemT>
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
AnyItem internal family Aggregation of groups to describe variables / partial variables.
Private::GroupIndexMapping m_groups
Container of groups.
bool contains(const ItemGroup &group) const
Returns true if the family contains the group.
Integer groupSize() const
Size of the family, i.e., number of groups.
Integer m_max_local_id
Maximum identifier (equivalent to the size of the family).
ItemGroup group(Integer i) const
Accessor for the i-th group of the family.
void removeObserver(IFamilyObserver &observer) const
Remove an observer.
Item item(const AnyItemT &any_item) const
Returns the concrete item associated with this AnyItem.
void registerObserver(IFamilyObserver &observer) const
Register an observer.
FamilyObservers m_observers
So that objects built on the family cannot modify it.
Integer firstLocalId(const ItemGroup &group) const
Position in the family of the first localId of this group.
void clear()
Clear the family.
Group allItems() const
Group of all items.
bool isPartial(const ItemGroup &group) const
Returns true if the group is associated with a partial variable.
Integer maxLocalId() const
Number of items in this family.
Integer groupIndex(const ItemGroup &group) const
Position of the group in the family.
FamilyInternal & operator<<(GroupBuilder builder)
Add a group to the family.
AnyItem family (flyweight pattern) Aggregation of groups to describe variables / partial variables Co...
ItemGroup group(Integer i) const
Accessor for the i-th group of the family.
Integer maxLocalId() const
Number of items in this family.
Integer firstLocalId(const ItemGroup &group) const
Position in the family of the first localId of this group.
bool operator==(const Family &f) const
Comparisons.
Item item(const AnyItemT &any_item) const
Returns the concrete item associated with this AnyItem.
SharedPtrT< FamilyInternal > m_internal
Internal family.
bool isPartial(const ItemGroup &group) const
Returns true if the group is associated with a partial variable.
void removeObserver(IFamilyObserver &observer) const
Remove an observer.
Integer groupSize() const
Size of the family, i.e., number of groups.
Group allItems()
Group of all items.
void clear()
Clear the family.
Family & operator<<(GroupBuilder builder)
Add a group to the family.
bool contains(const ItemGroup &group) const
Returns true if the family contains the group.
void registerObserver(IFamilyObserver &observer) const
Register an observer.
Integer groupIndex(const ItemGroup &group) const
Position of the group in the family.
Tool for building a group.
AnyItem Group Aggregation of Arcane group + information {partial or not} for variables Construction w...
AnyItem family observer interface.
Exception when a fatal error has occurred.
Brief: Implementation of a mesh entity group.
void attachObserver(const void *ref, IItemGroupObserver *obs)
Attaches an observer.
ItemGroupImpl * internal() const
Returns the group implementation.
Base class for a mesh element.
Int32 Integer
Type representing an integer.
IItemGroupObserver * newItemGroupObserverT(T *object, typename IItemGroupObserver::FuncTraits< T >::FuncPtr funcptr)
Utility for simplified creation of ItemGroupObserverT.