Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IModuleFactory.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/* IModuleFactory.h (C) 2000-2019 */
9/* */
10/* Module manufacturing interface. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_IMODULEFACTORY_H
13#define ARCANE_IMODULEFACTORY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/ReferenceCounter.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25class MeshHandle;
26class IModuleFactory2;
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31/*!
32 * \brief Information about a module factory.
33 *
34 * This interface contains the necessary information about a module
35 * factory.
36 *
37 * The module can be created directly via the createModule() method.
38 *
39 * This class uses a reference counter to manage its lifetime
40 * (see the ReferenceCounter class).
41 */
42class ARCANE_CORE_EXPORT IModuleFactoryInfo
43{
44 protected:
45
46 //! Releases resources
48
49 public:
50
51 virtual void addReference() = 0;
52 virtual void removeReference() = 0;
53 /*!
54 * \brief Indicates if the module should be loaded automatically.
55 *
56 * If this property is true, the module will always be loaded even
57 * if it does not appear in the time loop.
58 */
59 virtual bool isAutoload() const = 0;
60
61 /*!
62 * \brief If the factory is a one-to-one module,
63 * initializes it on the sub-domain \a sub_domain.
64 *
65 * This method is called when the sub-domain is created, to
66 * perform specific module initializations before
67 * it is manufactured. For example, to add time loops
68 * specific to the module.
69 */
70 virtual void initializeModuleFactory(ISubDomain* sub_domain) = 0;
71
72 /*!
73 * \brief Creates a module.
74 *
75 * The implementation must call parent->moduleMng()->addModule()
76 * for the created module.
77 *
78 * \param parent Parent of this module.
79 * \param mesh mesh associated with the module.
80 * \return the created module
81 */
82 virtual Ref<IModule> createModule(ISubDomain* parent, const MeshHandle& mesh_handle) = 0;
83
84 //! Name of the module created by this factory.
85 virtual String moduleName() const = 0;
86
87 /*!
88 * \brief Information about the module that can be created by this
89 * factory.
90 *
91 * The returned instance remains the property of the application that
92 * created it and must neither be modified nor destroyed.
93 */
94 virtual const IServiceInfo* serviceInfo() const = 0;
95};
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100/*!
101 * \internal
102 * \brief Module factory interface (V2).
103 *
104 * This interface is reserved for IModuleFactoryInfo and should not
105 * be used directly.
106 */
107class ARCANE_CORE_EXPORT IModuleFactory2
108{
109 public:
110
111 virtual ~IModuleFactory2() {}
112
113 public:
114
115 /*!
116 * \brief Creates a module instance.
117 *
118 * \param sd associated sub-domain.
119 * \param mesh mesh associated with the module.
120 * \return the created module
121 */
122 virtual Ref<IModule> createModuleInstance(ISubDomain* sd, const MeshHandle& mesh_handle) = 0;
123
124 /*!
125 * \brief Static initialization of the module.
126 *
127 * This method is called when the sub-domain is created, to
128 * perform specific module initializations before
129 * it is manufactured. For example, to add time loops
130 * specific to the module.
131 */
132 virtual void initializeModuleFactory(ISubDomain* sd) = 0;
133
134 //! Name of the module created by this factory.
135 virtual String moduleName() const = 0;
136
137 //! Information about the module that can be created by this factory.
138 virtual const IServiceInfo* serviceInfo() const = 0;
139};
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144/*!
145 * \brief Reference counter for a module factory.
146 */
147class ARCANE_CORE_EXPORT ModuleFactoryReference
148: ReferenceCounter<IModuleFactoryInfo>
149{
150 public:
151
153
154 public:
155
156 explicit ModuleFactoryReference(IModuleFactoryInfo* f)
157 : Base(f)
158 {}
159 ModuleFactoryReference(Ref<IModuleFactory2> factory, bool is_autoload);
160
161 public:
162
163 IModuleFactoryInfo* factory() const { return get(); }
164};
165
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168
169} // End namespace Arcane
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
174#endif
Arcane configuration file.
T * get() const
Returns the object referenced by the instance.
virtual Ref< IModule > createModuleInstance(ISubDomain *sd, const MeshHandle &mesh_handle)=0
Creates a module instance.
virtual String moduleName() const =0
Name of the module created by this factory.
virtual void initializeModuleFactory(ISubDomain *sd)=0
Static initialization of the module.
virtual const IServiceInfo * serviceInfo() const =0
Information about the module that can be created by this factory.
Information about a module factory.
virtual String moduleName() const =0
Name of the module created by this factory.
virtual ~IModuleFactoryInfo()
Releases resources.
virtual void initializeModuleFactory(ISubDomain *sub_domain)=0
If the factory is a one-to-one module, initializes it on the sub-domain sub_domain.
virtual Ref< IModule > createModule(ISubDomain *parent, const MeshHandle &mesh_handle)=0
Creates a module.
virtual bool isAutoload() const =0
Indicates if the module should be loaded automatically.
virtual const IServiceInfo * serviceInfo() const =0
Information about the module that can be created by this factory.
Interface for service or module information.
Interface of the subdomain manager.
Definition ISubDomain.h:75
Handle on a mesh.
Definition MeshHandle.h:48
Reference to an instance.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --