Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
AbstractModule.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/* AbstractModule.h (C) 2000-2025 */
9/* */
10/* Abstract base class of a module. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ABSTRACTMODULE_H
13#define ARCANE_CORE_ABSTRACTMODULE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18#include "arcane/utils/VersionInfo.h"
19#include "arcane/utils/TraceAccessor.h"
20
22#include "arcane/core/IModule.h"
23#include "arcane/core/ModuleBuildInfo.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34class ModuleBuildInfo;
35typedef ModuleBuildInfo ModuleBuilder;
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40/*!
41 * \brief Class representing a module.
42 *
43 * This class is THE low-level implementation class of the \a IModule interface.
44 *
45 * \ingroup Module
46 */
47class ARCANE_CORE_EXPORT AbstractModule
48: public TraceAccessor
49, public IModule
50{
51 public:
52
53 //! Constructor from a \a ModuleBuildInfo
55
56 public:
57
58 //! Destructor
59 virtual ~AbstractModule();
60
61 public:
62
63 //! Module version
64 VersionInfo versionInfo() const override { return m_version_info; }
65
66 public:
67
68 /*! \brief Initialization of the module for the sub-domain \a sd.
69 *
70 * This static method can be redefined in a derived class
71 * to perform initializations for the sub-domain \a sd
72 * even if the module is not used.
73 *
74 * A common use is registering entry points
75 * for modules without .axl
76 *
77 * This method will be called during the sub-domain creation phase
78 * on all Modules (even unused ones).
79 */
80 static void staticInitialize(ISubDomain* sd) { ARCANE_UNUSED(sd); }
81
82 public:
83
84 //! Module name
85 String name() const override { return m_name; }
86 //! Session associated with the module
87 ISession* session() const override { return m_session; }
88 //! Sub-domain associated with the module
89 ISubDomain* subDomain() const override { return m_sub_domain; }
90 //! Default mesh for this module
91 IMesh* defaultMesh() const override { return m_default_mesh_handle.mesh(); }
92 //! Default mesh for this module
93 MeshHandle defaultMeshHandle() const override { return m_default_mesh_handle; }
94 //! Message passing parallelism manager
95 IParallelMng* parallelMng() const override;
96 //! Accelerator manager.
97 IAcceleratorMng* acceleratorMng() const override;
98 //! Trace manager
99 ITraceMng* traceMng() const override;
100 //! Sets the module usage flag
101 void setUsed(bool v) override { m_used = v; }
102 //! Returns the module usage status
103 bool used() const override { return m_used; }
104 //! Sets the module activation flag
105 void setDisabled(bool v) override { m_disabled = v; }
106 //! Returns the module activation status
107 bool disabled() const override { return m_disabled; }
108 //! Indicates if the module uses a Garbage collection system
109 /*!
110 * <ul >
111 * <li >if \a true, indicates destruction by a Garbage collector and not explicit destruction</li>
112 * <li >if \a false, this module will be destroyed explicitly by calling its destructor</li>
113 * </ul >
114 *
115 * The Garbage collection system is usually activated for
116 * modules resulting from a C# implementation. Classic modules
117 * in C++ do not have this mechanism.
118 *
119 * \todo Check in ModuleMng::removeModule the use of
120 * this indication. A call to the Deleter as in
121 * ModuleMng::removeAllModules might be necessary.
122 */
123 bool isGarbageCollected() const override { return false; }
124
125 protected:
126
127 void _setVersionInfo(const VersionInfo& vi)
128 {
129 m_version_info = vi;
130 }
131
132 private:
133
134 ISession* m_session; //!< Session
135 ISubDomain* m_sub_domain; //!< sub-domain
136 MeshHandle m_default_mesh_handle; //!< Default mesh of the module
137 String m_name; //!< Module name
138 bool m_used; //!< \a true if the module is used
139 bool m_disabled; //!< Module activation status
140 VersionInfo m_version_info; //!< Module version
141 IAcceleratorMng* m_accelerator_mng; //!< Accelerator manager
142};
143
144/*---------------------------------------------------------------------------*/
145/*---------------------------------------------------------------------------*/
146
147} // End namespace Arcane
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151
152#endif
Declarations of Arcane's general types.
ISession * session() const override
Session associated with the module.
void setDisabled(bool v) override
Sets the module activation flag.
static void staticInitialize(ISubDomain *sd)
Initialization of the module for the sub-domain sd.
String name() const override
Module name.
MeshHandle defaultMeshHandle() const override
Default mesh for this module.
void setUsed(bool v) override
Sets the module usage flag.
ISubDomain * subDomain() const override
Sub-domain associated with the module.
bool isGarbageCollected() const override
Indicates if the module uses a Garbage collection system.
VersionInfo versionInfo() const override
Module version.
bool disabled() const override
Returns the module activation status.
IMesh * defaultMesh() const override
Default mesh for this module.
bool used() const override
Returns the module usage status.
AbstractModule(const ModuleBuildInfo &)
Constructor from a ModuleBuildInfo.
Interface of a module.
Definition IModule.h:40
Interface of the parallelism manager for a subdomain.
Interface for a case execution session.
Definition ISession.h:38
Interface of the subdomain manager.
Definition ISubDomain.h:75
Handle on a mesh.
Definition MeshHandle.h:48
Information for building a module.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
Information about a version.
Definition VersionInfo.h:47
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --