Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
MeshHandle.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/* MeshHandle.h (C) 2000-2026 */
9/* */
10/* Handle on a mesh. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MESHHANDLE_H
13#define ARCANE_CORE_MESHHANDLE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arccore/base/StringView.h"
19#include "arccore/base/String.h"
20#include "arccore/base/AutoRef2.h"
21
24
25#include <atomic>
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
47class ARCANE_CORE_EXPORT MeshHandle
48{
49 private:
50
51 // Temporary: to access the constructor that uses ISubDomain.
52 friend class MeshMng;
53
54 private:
55
56 class MeshHandleRef;
57
58 public:
59
60 MeshHandle();
61 ~MeshHandle();
62
63 MeshHandle(const MeshHandle&);
64 MeshHandle& operator=(const MeshHandle&);
65 MeshHandle(MeshHandle&&) noexcept;
66 MeshHandle& operator=(MeshHandle&&) noexcept;
67
68 private:
69
70 // TODO make accessible only to classes implementing IMeshMng.
71 MeshHandle(ISubDomain* sd, const String& name);
72
73 public:
74
86 IMesh* mesh() const;
87
89 bool hasMesh() const;
90
97 IMesh* meshOrNull() const;
98
99 public:
100
102 ARCCORE_DEPRECATED_2020("Do not use this method. Try to get ISubDomain from another way")
103 ISubDomain* subDomain() const;
104
105 public:
106
108 IMeshMng* meshMng() const;
109
111 ITraceMng* traceMng() const;
112
114 IVariableMng* variableMng() const;
115
117 IApplication* application() const;
118
121
122 String meshName() const;
123
125 bool isNull() const;
126
129
131 const void* reference() const { return m_ref.get(); }
132
133 public:
134
135 // TODO: Make these privates and add friend on them
136
138 void _setMesh(IMesh* mesh);
139
141 void _destroyMesh();
142
144 IMesh* _internalMeshOrNull() const;
145
146 private:
147
149};
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
158class ARCANE_CORE_EXPORT MeshHandleOrMesh
159{
160 public:
161
162 // NOTE: The constructors must not be explicit
163 // to allow conversions
164
167
174
176 IMesh* mesh() const { return m_handle.meshOrNull(); }
177
179 operator IMesh*() const { return mesh(); }
180
182 const MeshHandle& handle() const { return m_handle; }
183
184 private:
185
186 MeshHandle m_handle;
187};
188
189/*---------------------------------------------------------------------------*/
190/*---------------------------------------------------------------------------*/
191
192} // End namespace Arcane
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197#endif
Declarations of Arcane's general types.
Declarations of types used in Arcane.
Encapsulation of a pointer with a reference counter.
Definition AutoRef2.h:41
Application interface.
Mesh manager interface.
Definition IMeshMng.h:41
Interface of the subdomain manager.
Definition ISubDomain.h:78
Interface of a list that manages user data.
Variable manager interface.
IMesh * mesh() const
Associated mesh. Can be null if the mesh has not yet been created.
Definition MeshHandle.h:176
const MeshHandle & handle() const
Associated handle.
Definition MeshHandle.h:182
MeshHandleOrMesh(const MeshHandle &handle)
Constructs an instance from a MeshHandle.
Handle on a mesh.
Definition MeshHandle.h:48
ITraceMng * traceMng() const
Associated trace manager. nullptr if isNull() is true.
ISubDomain * subDomain() const
Associated sub-domain. Null if isNull() is true.
bool hasMesh() const
Indicates if the associated mesh has already been created (i.e.: mesh() is valid).
const void * reference() const
Definition MeshHandle.h:131
IMesh * meshOrNull() const
Returns the mesh associated with this instance.
bool isNull() const
Indicates if the handle is null (it does not reference any existing mesh or not).
IMesh * mesh() const
Associated mesh.
IApplication * application() const
Associated application. nullptr if isNull() is true.
IUserDataList * meshUserDataList() const
Associated user data.
IVariableMng * variableMng() const
Associated variable manager. nullptr if isNull() is true.
IMeshMng * meshMng() const
Associated mesh manager. nullptr if isNull() is true.
IObservable * onDestroyObservable() const
Observable to be notified of destruction.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --