12#ifndef ARCANE_CORE_SERVICEBUILDER_H
13#define ARCANE_CORE_SERVICEBUILDER_H
17#include "arcane/utils/Array.h"
18#include "arcane/utils/TraceInfo.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/ParallelFatalErrorException.h"
22#include "arcane/core/ISession.h"
23#include "arcane/core/ISubDomain.h"
24#include "arcane/core/IApplication.h"
25#include "arcane/core/IMesh.h"
26#include "arcane/core/ICaseOptions.h"
27#include "arcane/core/IFactoryService.h"
28#include "arcane/core/ServiceFinder2.h"
35namespace AxlOptionsBuilder
100template <
typename InterfaceType>
146 _throwFatal(name, properties);
173 _throwFatal(name, properties);
186 return m_service_finder.createAll();
200 InterfaceType* mf = m_service_finder.getSingleton();
204 _throwFatal(properties);
271 m_service_finder.getServicesNames(names);
284 ARCCORE_DEPRECATED_2019(
"use createAllInstances(Array<Ref<InterfaceType>>) instead")
287 m_service_finder.createAll(instances);
302 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
305 InterfaceType* mf = m_service_finder.create(name);
309 _throwFatal(name, properties);
319 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
320 static InterfaceType*
343 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
347 InterfaceType* mf = m_service_finder.create(name, mesh);
351 _throwFatal(name, properties);
360 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
364 InterfaceType* it = 0;
376 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
380 InterfaceType* it = 0;
392 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
396 InterfaceType* it = 0;
413 m_service_finder.getServicesNames(valid_names);
414 if (valid_names.
size() != 0)
415 return String::format(
"no service named '{0}' found (valid values = {1})",
416 wanted_name, String::join(
", ", valid_names));
418 return String::format(
"no service named '{0}' found and no implementation available",
424 String err_msg = _getErrorMessage(name);
426 throw ParallelFatalErrorException(A_FUNCINFO, err_msg);
428 throw FatalErrorException(A_FUNCINFO, err_msg);
432 String err_msg =
"No singleton service found for that interface";
434 throw ParallelFatalErrorException(A_FUNCINFO, err_msg);
436 throw FatalErrorException(A_FUNCINFO, err_msg);
445class ARCANE_CORE_EXPORT ServiceBuilderWithOptionsBase
449 ServiceBuilderWithOptionsBase(
ICaseMng* cm)
474template <
typename InterfaceType>
475class ServiceBuilderWithOptions
476:
private ServiceBuilderWithOptionsBase
480 ServiceBuilderWithOptions(
ICaseMng* cm)
481 : ServiceBuilderWithOptionsBase(cm)
494 _readOptions(opt.
get());
Integer size() const
Number of elements in the vector.
Base class for 1D data vectors.
Data set 'ServiceInstance' option.
T * get() const
Returns the object referenced by the instance.
Interface for a case execution session.
Interface of the subdomain manager.
InstanceType * get() const
Associated instance or nullptr if none.
Reference to an instance.
Encapsulation of a pointer with a reference counter.
Information for creating a service.
Utility class for instantiating a service of a given interface.
UniqueArray< Ref< InterfaceType > > createAllInstances()
Creates an instance of every service that implements InterfaceType.
static Ref< InterfaceType > createReference(ISession *session, 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.
ServiceBuilder(ISubDomain *sd)
Instantiation to create a subdomain service.
static Ref< InterfaceType > createReference(ISubDomain *sd, const String &name, eServiceBuilderProperties properties=SB_None)
Creates an instance implementing the InterfaceType interface.
Ref< InterfaceType > createReference(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.
InterfaceType * createInstance(const String &name, eServiceBuilderProperties properties=SB_None)
Creates an instance implementing the interface InterfaceType.
static Ref< InterfaceType > createReference(IApplication *app, const String &name, eServiceBuilderProperties properties=SB_None)
Creates an instance implementing the InterfaceType interface.
ServiceBuilder(ISession *session)
Instantiation to create a session service.
InterfaceType * getSingleton(eServiceBuilderProperties properties=SB_None)
Singleton instance of the service implementing the InterfaceType interface.
ServiceBuilder(const MeshHandle &mesh_handle)
Instantiation to create a subdomain service associated with the mesh_handle.
void getServicesNames(Array< String > &names) const
Fills names with the names of services available to instantiate this interface.
ServiceBuilder(IApplication *app)
Instantiation to create an application service.
ServiceBuilder(IApplication *app, ICaseOptions *opt)
Instantiation to create a dataset options service.
Unicode character string.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eServiceBuilderProperties
Properties for service creation.
@ SB_Collective
Indicates that all processes perform the same operation.
@ SB_AllowNull
Allows the service to be absent.
@ SB_None
No specific property.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.