14#include "arcane/core/MeshHandle.h"
16#include "IParallelMng.h"
17#include "arcane/utils/UserDataList.h"
18#include "arcane/utils/FatalErrorException.h"
19#include "arcane/utils/Observable.h"
20#include "arcane/utils/ValueConvert.h"
22#include "arcane/core/ISubDomain.h"
23#include "arcane/core/IMesh.h"
24#include "arcane/core/IMeshBase.h"
48 const String& meshName()
const {
return m_mesh_name; }
49 bool isNull()
const {
return m_is_null; }
50 IMesh*
mesh()
const {
return m_mesh_ptr; }
51 IMeshBase* meshBase()
const {
return m_mesh_base_ptr; }
56 IUserDataList* userDataList()
const {
return m_user_data_list; }
58 bool isDoFatalInMeshMethod()
const {
return m_do_fatal_in_mesh_method; }
63 void _setMesh(
IMesh* mesh);
73 Int32 v = std::atomic_fetch_add(&m_nb_ref, -1);
81 IMesh* m_mesh_ptr =
nullptr;
91 bool m_is_null =
true;
92 bool m_do_fatal_in_mesh_method =
false;
93 std::atomic<Int32> m_nb_ref = 0;
101MeshHandle::MeshHandleRef::
105, m_is_null(name.null())
115 m_do_fatal_in_mesh_method = v.value() != 0;
121MeshHandle::MeshHandleRef::
124 delete m_user_data_list;
125 delete m_on_destroy_observable;
131void MeshHandle::MeshHandleRef::
140 m_parallel_mng_ref.reset();
146void MeshHandle::MeshHandleRef::
150 IMesh*
mesh = m_mesh_ptr;
153 m_on_destroy_observable->notifyAllObservers();
154 m_user_data_list->clear();
157 m_mesh_ptr =
nullptr;
168MeshHandle(ISubDomain* sd,
const String& name)
183MeshHandle(
const MeshHandle& x)
189MeshHandle(MeshHandle&& x) noexcept
190: m_ref(std::move(x.m_ref))
194MeshHandle& MeshHandle::
195operator=(
const MeshHandle& x)
202MeshHandle& MeshHandle::
203operator=(MeshHandle&& x)
noexcept
205 m_ref = std::move(x.m_ref);
225 return m_ref->meshMng();
234 IMesh* m = m_ref->mesh();
244 IMesh* m = m_ref->mesh();
249 bool do_fatal = m_ref->isDoFatalInMeshMethod();
251 ARCANE_FATAL(
"Invalid call for null mesh. Call MeshHandle::hasMesh() before to make sure mesh is valid");
261 return m_ref->mesh();
270 return m_ref->traceMng();
279 return m_ref->variableMng();
288 return m_ref->subDomain()->application();
297 return m_ref->onDestroyObservable();
302 return m_ref->userDataList();
305String MeshHandle::meshName()
const
307 return m_ref->meshName();
313 return m_ref->isNull();
320 m_ref->_setMesh(
mesh);
327 m_ref->_destroyMesh();
334 return m_ref->mesh();
340 return m_ref->subDomain();
361 m_handle =
mesh->handle();
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Template class for converting a type.
virtual ITraceMng * traceMng() const =0
Trace manager.
virtual IParallelMng * parallelMng()=0
Parallelism manager.
Interface of an observable.
Interface of the subdomain manager.
virtual IMeshMng * meshMng() const =0
Returns the mesh manager.
virtual IVariableMng * variableMng()=0
Returns the variable manager.
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.
const MeshHandle & handle() const
Associated handle.
MeshHandleOrMesh(const MeshHandle &handle)
Constructs an instance from a MeshHandle.
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).
void _setMesh(IMesh *mesh)
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.
IMesh * _internalMeshOrNull() const
IMeshMng * meshMng() const
Associated mesh manager. nullptr if isNull() is true.
IObservable * onDestroyObservable() const
Observable to be notified of destruction.
Base class of an observable.
Reference to an instance.
Thread-safe implementation of a reference counter.
Unicode character string.
Manages a list of user data.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.