Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ItemPairGroup.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* ItemPairGroup.h (C) 2000-2025 */
9/* */
10/* Table of entity lists. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMPAIRGROUP_H
13#define ARCANE_CORE_ITEMPAIRGROUP_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/AutoRef.h"
18#include "arcane/utils/Iterator.h"
19#include "arcane/utils/IFunctorWithArgument.h"
20
21#include "arcane/core/ItemPairGroupImpl.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33//NOTE: The complete documentation is in ItemPairGroup.cc
34
35/*!
36 * \brief Table of entity lists.
37 */
38class ARCANE_CORE_EXPORT ItemPairGroup
39{
40 public:
41
42 /*!
43 * \brief Functor for custom connectivity calculation.
44 */
47
48 public:
49
50 //! Constructs an empty table.
52 //! Constructs a group from the internal representation \a prv
53 explicit ItemPairGroup(ItemPairGroupImpl* prv);
54 /*!
55 * \brief Constructs an instance by specifying the neighborhood via entities
56 * of kind \a link_kind.
57 */
58 ItemPairGroup(const ItemGroup& group, const ItemGroup& sub_item_group,
59 eItemKind link_kind);
60 //! Constructs an instance with a specific functor.
61 ItemPairGroup(const ItemGroup& group, const ItemGroup& sub_item_group,
62 CustomFunctor* functor);
63 //! Copy constructor.
65 : m_impl(from.m_impl)
66 {}
67
68 const ItemPairGroup& operator=(const ItemPairGroup& from)
69 {
70 m_impl = from.m_impl;
71 return (*this);
72 }
73 virtual ~ItemPairGroup() = default;
74
75 public:
76
77 //! \a true means the group is the null group
78 inline bool null() const { return m_impl->null(); }
79 //! Type of entities in the group
80 inline eItemKind itemKind() const { return m_impl->itemKind(); }
81 //! Type of sub-entities in the group
82 inline eItemKind subItemKind() const { return m_impl->subItemKind(); }
83
84 public:
85
86 /*!
87 * \brief Returns the group implementation.
88 *
89 * \warning This method returns a pointer to the group's internal representation
90 * and should not be used outside of Arcane.
91 */
92 ItemPairGroupImpl* internal() const { return m_impl.get(); }
93
94 //! Entity family to which this group belongs (0 for a null list)
95 IItemFamily* itemFamily() const { return m_impl->itemFamily(); }
96
97 //! Entity family to which this group belongs (0 for a null list)
98 IItemFamily* subItemFamily() const { return m_impl->subItemFamily(); }
99
100 //! Mesh to which this list belongs (0 for a null list)
101 IMesh* mesh() const { return m_impl->mesh(); }
102
103 //! Initial item group
104 const ItemGroup& itemGroup() const { return m_impl->itemGroup(); }
105
106 //! Final item group (after bounce)
107 const ItemGroup& subItemGroup() const { return m_impl->subItemGroup(); }
108
109 public:
110
111 /*! \brief Invalidates the list.
112 */
113 void invalidate(bool force_recompute = false)
114 {
115 m_impl->invalidate(force_recompute);
116 }
117
118 //! Internal check of group validity
119 void checkValid() { m_impl->checkValid(); }
120
121 public:
122
123 ItemPairEnumerator enumerator() const;
124
125 protected:
126
127 //! Internal representation of the group.
129
130 protected:
131
132 //! Returns the group \a impl if it is of kind \a kt, the null group otherwise
134 {
135 return (impl->itemKind() == ik && impl->subItemKind() == aik) ? impl : ItemPairGroupImpl::checkSharedNull();
136 }
137};
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142/*!
143 * \brief Compares the references of two groups.
144 * \retval true if \a g1 and \a g2 refer to the same group,
145 * \retval false otherwise.
146 */
147inline bool
148operator==(const ItemPairGroup& g1, const ItemPairGroup& g2)
149{
150 return g1.internal() == g2.internal();
151}
152
153/*!
154 * \brief Compares the references of two groups.
155 * \retval true if \a g1 and \a g2 do not refer to the same group,
156 * \retval false otherwise.
157 */
158inline bool
159operator!=(const ItemPairGroup& g1, const ItemPairGroup& g2)
160{
161 return g1.internal() != g2.internal();
162}
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
167/*!
168 * \brief Reference to a group of a given kind.
169 */
170template <typename ItemKind, typename SubItemKind>
171class ItemPairGroupT
172: public ItemPairGroup
173{
174 public:
175
176 //! Type of this class
177 typedef ItemPairGroupT<ItemKind, SubItemKind> ThatClass;
178 //! Type of the class containing the entity characteristics
180 typedef ItemTraitsT<SubItemKind> SubTraitsType;
181
182 typedef typename TraitsType::ItemType ItemType;
183 typedef typename TraitsType::ItemGroupType ItemGroupType;
184 typedef typename SubTraitsType::ItemType SubItemType;
185 typedef typename SubTraitsType::ItemGroupType SubItemGroupType;
186
187 public:
188
189 ItemPairGroupT() {}
190 ItemPairGroupT(const ItemPairGroup& from)
191 : ItemPairGroup(_check(from.internal(), TraitsType::kind(), SubTraitsType::kind()))
192 {}
193 ItemPairGroupT(const ThatClass& from)
194 : ItemPairGroup(from)
195 {}
196 ItemPairGroupT(const ItemGroupType& group, const SubItemGroupType& sub_group,
197 eItemKind link_kind)
198 : ItemPairGroup(group, sub_group, link_kind)
199 {}
200 ItemPairGroupT(const ItemGroupType& group, const SubItemGroupType& sub_group,
201 CustomFunctor* functor)
202 : ItemPairGroup(group, sub_group, functor)
203 {}
204 ~ItemPairGroupT() {}
205
206 public:
207
208 const ThatClass& operator=(const ThatClass& from)
209 {
210 m_impl = from.internal();
211 return (*this);
212 }
213 const ThatClass& operator=(const ItemPairGroup& from)
214 {
215 _assign(from);
216 return (*this);
217 }
218
219 protected:
220
221 void _assign(const ItemPairGroup& from)
222 {
223 m_impl = _check(from.internal(), TraitsType::kind(), SubTraitsType::kind());
224 }
225};
226
227/*---------------------------------------------------------------------------*/
228/*---------------------------------------------------------------------------*/
229
230} // namespace Arcane
231
232/*---------------------------------------------------------------------------*/
233/*---------------------------------------------------------------------------*/
234
235#endif
Declarations of types on entities.
Encapsulation of a pointer with a reference counter.
Definition AutoRef.h:43
Interface of a functor with an argument but without a return value.
Interface of an entity family.
Definition IItemFamily.h:83
Mesh entity group.
Definition ItemGroup.h:51
Enumerator over an array of arrays of mesh entities.
Reference to a group of a given kind.
ItemTraitsT< ItemKind > TraitsType
Type of the class containing the entity characteristics.
ItemPairGroupT< ItemKind, SubItemKind > ThatClass
Type of this class.
Table of entity lists.
IFunctorWithArgumentT< ItemPairGroupBuilder & > CustomFunctor
Functor for custom connectivity calculation.
eItemKind itemKind() const
Type of entities in the group.
const ItemGroup & itemGroup() const
Initial item group.
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for a null list).
eItemKind subItemKind() const
Type of sub-entities in the group.
ItemPairGroup(const ItemPairGroup &from)
Copy constructor.
static ItemPairGroupImpl * _check(ItemPairGroupImpl *impl, eItemKind ik, eItemKind aik)
Returns the group impl if it is of kind kt, the null group otherwise.
void checkValid()
Internal check of group validity.
void invalidate(bool force_recompute=false)
Invalidates the list.
IItemFamily * subItemFamily() const
Entity family to which this group belongs (0 for a null list).
ItemPairGroup()
Constructs an empty table.
AutoRefT< ItemPairGroupImpl > m_impl
Internal representation of the group.
const ItemGroup & subItemGroup() const
Final item group (after bounce).
ItemPairGroupImpl * internal() const
Returns the group implementation.
bool null() const
true means the group is the null group
IMesh * mesh() const
Mesh to which this list belongs (0 for a null list).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eItemKind
Mesh entity type.