Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemSharedInfoList.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/* ItemSharedInfoList.h (C) 2000-2022 */
9/* */
10/* List of 'ItemSharedInfo'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_ITEMSHAREDINFOLIST_H
13#define ARCANE_MESH_ITEMSHAREDINFOLIST_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/String.h"
19#include "arcane/utils/HashTableMap.h"
20
21#include "arcane/core/ItemGroup.h"
22#include "arcane/core/ItemInternal.h"
24
25#include "arcane/mesh/MeshGlobal.h"
26
27#include <map>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane::mesh
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38class ItemFamily;
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
49class ItemSharedInfoWithType
50{
51 friend class ItemSharedInfoList;
52 static const Int32 NULL_INDEX = ItemSharedInfo::NULL_INDEX;
53
54 public:
55
56 ItemSharedInfoWithType()
58 {}
59
60 private:
61
62 ItemSharedInfoWithType(ItemSharedInfo* shared_info, ItemTypeInfo* item_type);
63 ItemSharedInfoWithType(ItemSharedInfo* shared_info, ItemTypeInfo* item_type, Int32ConstArrayView buffer);
64
65 public:
66
67 ItemSharedInfo* sharedInfo() { return m_shared_info; }
68 ItemTypeId itemTypeId() { return this->m_type_id; }
69 Int32 index() const { return m_index; }
70 void setIndex(Int32 aindex) { m_index = aindex; }
71 Int32 nbReference() const { return m_nb_reference; }
72 void addReference() { ++m_nb_reference; }
73 void removeReference() { --m_nb_reference; }
74 void serializeWrite(Int32ArrayView buffer);
75 static Integer serializeSize() { return 6; }
76
77 public:
78
79 friend std::ostream& operator<<(std::ostream& o, const ItemSharedInfoWithType& isi)
80 {
81 isi.m_shared_info->print(o);
82 return o;
83 }
84
85 private:
86
87 ItemSharedInfo* m_shared_info = nullptr;
88 ItemTypeId m_type_id;
89 Int32 m_index = NULL_INDEX;
90 Int32 m_nb_reference = 0;
91};
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
101class ItemSharedInfoList
102: public TraceAccessor
103{
104 public:
105
106 class ItemNumElements;
107 class Variables;
108 typedef std::map<ItemNumElements, ItemSharedInfoWithType*> ItemSharedInfoMap;
109
110 public:
111
112 ItemSharedInfoList(ItemFamily* family, ItemSharedInfo* common_shared_info);
115
116 public:
117
118 ConstArrayView<ItemSharedInfoWithType*> itemSharedInfos() const { return m_item_shared_infos; }
119 ArrayView<ItemSharedInfoWithType*> itemSharedInfos() { return m_item_shared_infos; }
120
121 private:
122
123 ItemSharedInfoWithType* allocOne()
124 {
125 bool need_alloc = false;
126 ItemSharedInfoWithType* next = _allocOne(need_alloc);
127 return next;
128 }
129
130 ItemSharedInfoWithType* allocOne(bool& need_alloc)
131 {
132 ItemSharedInfoWithType* next = _allocOne(need_alloc);
133 return next;
134 }
135
136 void removeOne(ItemSharedInfoWithType* item)
137 {
138 m_list_changed = true;
139 m_free_item_shared_infos.add(item);
141 }
142
143 public:
144
146 void checkValid();
147
148 Integer nbItemSharedInfo() const { return m_nb_item_shared_info; }
149
150 void prepareForDump();
151 void readFromDump();
152
153 void dumpSharedInfos();
154
156 bool hasChanged() { return m_list_changed; }
157
158 public:
159
160 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
161 Integer maxNodePerItem() const { return 0; }
162 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
163 Integer maxEdgePerItem() const { return 0; }
164 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
165 Integer maxFacePerItem() const { return 0; }
166 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
167 Integer maxCellPerItem() const { return 0; }
168 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
169 Integer maxLocalNodePerItemType() const { return 0; }
170 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
171 Integer maxLocalEdgePerItemType() const { return 0; }
172 ARCANE_DEPRECATED_REASON("Y2022: This method always return 0")
173 Integer maxLocalFacePerItemType() const { return 0; }
174
175 public:
176
177 ItemSharedInfoWithType* findSharedInfo(ItemTypeInfo* type);
178
179 private:
180
181 ItemSharedInfoWithType* _allocOne(bool& need_alloc)
182 {
183 ItemSharedInfoWithType* new_item = 0;
184 Integer nb_free = m_free_item_shared_infos.size();
185 m_list_changed = true;
186 if (nb_free != 0) {
187 new_item = m_free_item_shared_infos.back();
188 m_free_item_shared_infos.popBack();
189 need_alloc = false;
190 }
191 else {
192 new_item = m_item_shared_infos_buffer->allocOne();
193 new_item->setIndex(m_item_shared_infos.size());
194 m_item_shared_infos.add(new_item);
195 need_alloc = true;
196 }
198 return new_item;
199 }
200
201 private:
202
203 ItemFamily* m_family = nullptr;
204 ItemSharedInfo* m_common_item_shared_info = nullptr;
206 eItemKind m_item_kind = IK_Unknown;
207 UniqueArray<ItemSharedInfoWithType*> m_item_shared_infos;
208 UniqueArray<ItemSharedInfoWithType*> m_free_item_shared_infos;
209 MultiBufferT<ItemSharedInfoWithType>* m_item_shared_infos_buffer;
210 ItemSharedInfoMap* m_infos_map = nullptr;
211 Variables* m_variables = nullptr;
212 bool m_list_changed = false;
213};
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
217
218} // End namespace Arcane::mesh
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
223#endif
Modifiable view of an array of type T.
Constant view of an array of type T.
Internal shared structure of a mesh entity.
static ItemSharedInfo nullItemSharedInfo
For the null entity.
Type of an entity (Item).
Definition ItemTypeId.h:33
Info on a mesh entity type.
Buffer for multiple allocation.
Definition MultiBuffer.h:45
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
bool hasChanged()
Indicates if the list has changed since the last call to prepareForDump().
Integer m_nb_item_shared_info
Number of allocated objects.
void checkValid()
Checks if the internal structures of the instance are valid.
Temporary class to hold an ItemSharedInfo and an entity type.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:453
eItemKind
Mesh entity type.
@ IK_Unknown
Unknown or uninitialized mesh entity.
std::int32_t Int32
Signed integer type of 32 bits.