12#ifndef ARCANE_CORE_SERVICEFINDER2_H
13#define ARCANE_CORE_SERVICEFINDER2_H
17#include "arcane/utils/String.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/Collection.h"
20#include "arcane/utils/Enumerator.h"
22#include "arcane/core/IServiceInfo.h"
23#include "arcane/core/IFactoryService.h"
24#include "arcane/core/IApplication.h"
25#include "arcane/core/IServiceFactory.h"
26#include "arcane/core/IServiceMng.h"
27#include "arcane/core/ServiceBuildInfo.h"
28#include "arcane/core/ServiceInstance.h"
46template <
typename InterfaceType>
47class ServiceFinderBase2T
57 , m_service_build_info_base(sbi)
61 virtual ~ServiceFinderBase2T() {}
72 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
75 return _create(name, m_service_build_info_base);
85 return _createReference(name, m_service_build_info_base);
98 ARCCORE_DEPRECATED_2019(
"Use createReference() instead")
101 ISubDomain* sd = m_service_build_info_base.subDomain();
119 ISubDomain* sd = m_service_build_info_base.subDomain();
134 IServiceMng* sm = m_service_build_info_base.serviceParent()->serviceMng();
143 return m->instance().
get();
157 ARCCORE_DEPRECATED_2019(
"Use createAll(Array<ServiceRef<InterfaceType>>&) instead")
160 _createAll(instances, m_service_build_info_base);
168 return _createAll(m_service_build_info_base);
187 void getServicesNames(Array<String>& names)
const
190 IServiceFactory2* sf2 = *j;
191 IServiceFactory2T<InterfaceType>* true_factory =
dynamic_cast<IServiceFactory2T<InterfaceType>*
>(sf2);
193 IServiceInfo* si = sf2->serviceInfo();
194 names.add(si->localName());
201 InterfaceType* _create(
const String& name,
const ServiceBuildInfoBase& sbib)
203 return _createReference(name, sbib)._release();
206 Ref<InterfaceType> _createReference(
const String& name,
const ServiceBuildInfoBase& sbib)
209 Internal::IServiceFactory2* sf2 = *j;
210 IServiceInfo* s = sf2->serviceInfo();
211 if (s->localName() != name)
213 IServiceFactory2T<InterfaceType>* m =
dynamic_cast<IServiceFactory2T<InterfaceType>*
>(sf2);
216 Ref<InterfaceType> tt = m->createServiceReference(sbib);
224 void _createAll(Array<InterfaceType*>& instances,
const ServiceBuildInfoBase& sbib)
226 UniqueArray<Ref<InterfaceType>> ref_instances = _createAll(sbib);
227 for (
auto& x : ref_instances)
228 instances.add(x._release());
231 UniqueArray<Ref<InterfaceType>> _createAll(
const ServiceBuildInfoBase& sbib)
233 UniqueArray<Ref<InterfaceType>> instances;
235 Internal::IServiceFactory2* sf2 = *j;
236 IServiceFactory2T<InterfaceType>* m =
dynamic_cast<IServiceFactory2T<InterfaceType>*
>(sf2);
238 Ref<InterfaceType> tt = m->createServiceReference(sbib);
249 IApplication* m_application;
250 ServiceBuildInfoBase m_service_build_info_base;
270template <
typename InterfaceType,
typename ParentType>
281 ~ServiceFinder2T() {}
Base class for 1D data vectors.
void add(ConstReferenceType val)
Adds element val to the end of the array.
ConstArrayView< T > constView() const
Constant view of this array.
EnumeratorT< SingletonServiceInstanceRef > Enumerator
virtual ServiceFactory2Collection serviceFactories2()=0
List of service factories.
Typed interface managing a service instance.
Interface of a service instance.
Service manager interface.
virtual SingletonServiceInstanceCollection singletonServices() const =0
Returns the list of singleton services.
Interface of a singleton service instance.
virtual ServiceInstanceCollection interfaceInstances()=0
List of instances of interfaces implemented by the singleton.
Interface of the subdomain manager.
Factory for a service implementing the InterfaceType interface.
Utility class to find one or more services implementing the InterfaceType interface.
virtual InterfaceType * create(const String &name)
Creates an instance of the service name.
virtual UniqueArray< Ref< InterfaceType > > createAll()
Creates an instance of every service that implements InterfaceType.
virtual void createAll(Array< InterfaceType * > &instances)
Creates an instance of every service that implements InterfaceType.
virtual InterfaceType * getSingleton()
Singleton instance of the service having the InterfaceType interface.
virtual Ref< InterfaceType > createReference(const String &name, IMesh *mesh)
Creates a reference to the service name for the mesh mesh.
virtual Ref< InterfaceType > createReference(const String &name)
Creates a reference to the service name.
InstanceType * get() const
Associated instance or nullptr if none.
Reference to an instance.
Information for creating a service.
1D vector of data with reference semantics.
Unicode character string.
1D data vector with value semantics (STL style).
Internal types of Arcane.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Collection< SingletonServiceInstanceRef > SingletonServiceInstanceCollection
Collection of singleton service instances.