Utility class for instantiating a service of a given interface. More...
#include <arcane/core/ServiceBuilder.h>
Public Member Functions | |
| ServiceBuilder (ISubDomain *sd) | |
| Instantiation to create a subdomain service. | |
| ServiceBuilder (const MeshHandle &mesh_handle) | |
| Instantiation to create a subdomain service associated with the mesh_handle. | |
| ServiceBuilder (ISession *session) | |
| Instantiation to create a session service. | |
| ServiceBuilder (IApplication *app) | |
| Instantiation to create an application service. | |
| ServiceBuilder (IApplication *app, ICaseOptions *opt) | |
| Instantiation to create a dataset options service. | |
| Ref< InterfaceType > | createReference (const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the InterfaceType interface. | |
| Ref< InterfaceType > | createReference (const String &name, IMesh *mesh, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the InterfaceType interface. | |
| UniqueArray< Ref< InterfaceType > > | createAllInstances () |
| Creates an instance of every service that implements InterfaceType. | |
| InterfaceType * | getSingleton (eServiceBuilderProperties properties=SB_None) |
| Singleton instance of the service implementing the InterfaceType interface. | |
| void | getServicesNames (Array< String > &names) const |
| Fills names with the names of services available to instantiate this interface. | |
| void | createAllInstances (Array< InterfaceType * > &instances) |
| Creates an instance of every service that implements InterfaceType. | |
| InterfaceType * | createInstance (const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the interface InterfaceType. | |
| InterfaceType * | createInstance (const String &name, IMesh *mesh, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the interface InterfaceType. | |
Static Public Member Functions | |
| static Ref< InterfaceType > | createReference (ISubDomain *sd, const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the InterfaceType interface. | |
| static Ref< InterfaceType > | createReference (ISession *session, const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the InterfaceType interface. | |
| static Ref< InterfaceType > | createReference (IApplication *app, const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the InterfaceType interface. | |
| static Ref< InterfaceType > | createReference (ISubDomain *sd, const String &name, IMesh *mesh, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the InterfaceType interface. | |
| static InterfaceType * | createInstance (ISubDomain *sd, const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the interface InterfaceType. | |
| static InterfaceType * | createInstance (ISession *session, const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the interface InterfaceType. | |
| static InterfaceType * | createInstance (IApplication *app, const String &name, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the interface InterfaceType. | |
| static InterfaceType * | createInstance (ISubDomain *sd, const String &name, IMesh *mesh, eServiceBuilderProperties properties=SB_None) |
| Creates an instance implementing the interface InterfaceType. | |
Private Member Functions | |
| String | _getErrorMessage (String wanted_name) |
| void | _throwFatal (const String &name, eServiceBuilderProperties properties) |
| void | _throwFatal (eServiceBuilderProperties properties) |
Private Attributes | |
| Internal::ServiceFinderBase2T< InterfaceType > | m_service_finder |
Utility class for instantiating a service of a given interface.
This class allows searching for all available services implementing the InterfaceType interface passed as a template parameter.
This class replaces older classes that allowed service creation, namely ServiceFinderT, ServiceFinder2T, and FactoryT.
There are three constructors depending on whether you want to instantiate a subdomain, a session, or an application service. Generally, it is a subdomain service; the last two categories are rather used for internal Arcane services.
The following example creates a subdomain service implementing the IMyInterface interface with the name TOTO:
The returned instance is managed by a reference counter and is destroyed as soon as there are no more references to it. By default, createInstance() throws an exception if the service is not found, unless the SB_AllowNull property is specified. If the SB_Collective property is true, the exception thrown is of type ParallelFatalErrorException; otherwise, it is of type FatalErrorException. This is useful if you are sure that all processes will perform the same operation. In this case, this allows only one error message to be generated and the code to stop cleanly.
It is also possible to retrieve a singleton instance of a service, via getSingleton(). The available singleton instances are referenced in the code configuration file (see arcanedoc_core_types_codeconfig).
Definition at line 101 of file ServiceBuilder.h.
|
inline |
Instantiation to create a subdomain service.
Definition at line 106 of file ServiceBuilder.h.
Referenced by createInstance(), createInstance(), createInstance(), createReference(), createReference(), and createReference().
|
inline |
Instantiation to create a subdomain service associated with the mesh_handle.
Definition at line 110 of file ServiceBuilder.h.
|
inline |
Instantiation to create a session service.
Definition at line 114 of file ServiceBuilder.h.
|
inline |
Instantiation to create an application service.
Definition at line 118 of file ServiceBuilder.h.
|
inline |
Instantiation to create a dataset options service.
Definition at line 122 of file ServiceBuilder.h.
|
inline |
Definition at line 126 of file ServiceBuilder.h.
|
inlineprivate |
Definition at line 410 of file ServiceBuilder.h.
|
inlineprivate |
Definition at line 422 of file ServiceBuilder.h.
|
inlineprivate |
Definition at line 430 of file ServiceBuilder.h.
|
inline |
Creates an instance of every service that implements InterfaceType.
The created instances are stored in instances. The caller must destroy them using the delete operator once they are no longer useful.
Definition at line 184 of file ServiceBuilder.h.
Referenced by createAllInstances(), and Arcane::Application::getCodeService().
|
inline |
Creates an instance of every service that implements InterfaceType.
The created instances are stored in instances. The caller must destroy them using the delete operator once they are no longer needed.
Definition at line 285 of file ServiceBuilder.h.
References createAllInstances().
|
inline |
Creates an instance implementing the interface InterfaceType.
The instance is created using the factory registered under the name name. The returned pointer must be deallocated using delete.
By default, an exception is thrown if the specified service is not found. It is possible to change this behavior by specifying SB_AllowNull in properties in which case the function returns a null pointer if the specified service does not exist.
Definition at line 303 of file ServiceBuilder.h.
References createInstance(), Arcane::SB_AllowNull, and Arcane::SB_None.
Referenced by createInstance(), createInstance(), createInstance(), createInstance(), createInstance(), and createInstance().
|
inline |
Creates an instance implementing the interface InterfaceType.
The instance is created using the factory registered under the name name. The returned pointer must be deallocated using delete.
It is possible to specify the mesh mesh on which the service will rely. This is only useful for subdomain services. For session or application services, this argument is not used.
By default, an exception is thrown if the specified service is not found. It is possible to change this behavior by specifying SB_AllowNull in properties in which case the function returns a null pointer if the specified service does not exist.
Definition at line 344 of file ServiceBuilder.h.
References createInstance(), Arcane::SB_AllowNull, and Arcane::SB_None.
|
inlinestatic |
Creates an instance implementing the interface InterfaceType.
Definition at line 377 of file ServiceBuilder.h.
References createInstance(), Arcane::SB_None, and ServiceBuilder().
|
inlinestatic |
Creates an instance implementing the interface InterfaceType.
Definition at line 361 of file ServiceBuilder.h.
References createInstance(), Arcane::SB_None, and ServiceBuilder().
|
inlinestatic |
Creates an instance implementing the interface InterfaceType.
Definition at line 321 of file ServiceBuilder.h.
References createInstance(), and Arcane::SB_None.
|
inlinestatic |
Creates an instance implementing the interface InterfaceType.
Definition at line 393 of file ServiceBuilder.h.
References createInstance(), Arcane::SB_None, and ServiceBuilder().
|
inline |
Creates an instance implementing the InterfaceType interface.
The instance is created using the factory registered under the name name.
By default, an exception is thrown if the specified service is not found. It is possible to change this behavior by specifying SB_AllowNull in properties, in which case the function returns a null pointer if the specified service does not exist.
Definition at line 140 of file ServiceBuilder.h.
References Arcane::SB_AllowNull, and Arcane::SB_None.
Referenced by Arcane::Application::_tryCreateService(), Arcane::SubDomain::allocateMeshes(), Arcane::Application::build(), Arcane::MessagePassing::HybridParallelSuperMng::build(), Arcane::MessagePassing::SharedMemoryParallelSuperMng::build(), createReference(), createReference(), createReference(), createReference(), Arcane::Application::initialize(), Arcane::ArcaneVerifierModule::onExit(), Arcane::ArcaneInitialPartitioner::partitionAndDistributeMeshes(), and Arcane::UnstructuredMeshUtilities::writeToFile().
|
inline |
Creates an instance implementing the InterfaceType interface.
The instance is created using the factory registered under the name name. The returned pointer must be deallocated using delete.
It is possible to specify the mesh on which the service will reside. This is only useful for subdomain services. For session or application services, this argument is not used.
By default, an exception is thrown if the specified service is not found. It is possible to change this behavior by specifying SB_AllowNull in properties, in which case the function returns a null pointer if the specified service does not exist.
Definition at line 166 of file ServiceBuilder.h.
References Arcane::SB_AllowNull, and Arcane::SB_None.
|
inlinestatic |
Creates an instance implementing the InterfaceType interface.
Definition at line 241 of file ServiceBuilder.h.
References createReference(), Arcane::SB_None, and ServiceBuilder().
|
inlinestatic |
Creates an instance implementing the InterfaceType interface.
Definition at line 225 of file ServiceBuilder.h.
References createReference(), Arcane::SB_None, and ServiceBuilder().
|
inlinestatic |
Creates an instance implementing the InterfaceType interface.
Definition at line 214 of file ServiceBuilder.h.
References createReference(), and Arcane::SB_None.
|
inlinestatic |
Creates an instance implementing the InterfaceType interface.
Definition at line 257 of file ServiceBuilder.h.
References createReference(), Arcane::SB_None, and ServiceBuilder().
|
inline |
Fills names with the names of services available to instantiate this interface.
Definition at line 269 of file ServiceBuilder.h.
Referenced by Arcane::UnstructuredMeshUtilities::writeToFile().
|
inline |
Singleton instance of the service implementing the InterfaceType interface.
The returned instance must not be destroyed.
By default, an exception is thrown if the specified service is not found. It is possible to change this behavior by specifying SB_AllowNull in properties, in which case the function returns a null pointer if the specified service does not exist.
Definition at line 198 of file ServiceBuilder.h.
References Arcane::SB_AllowNull, and Arcane::SB_None.
|
private |
Definition at line 406 of file ServiceBuilder.h.