Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IServiceFactory.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/* IServiceFactory.h (C) 2000-2025 */
9/* */
10/* Service manufacturing interface. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ISERVICEFACTORY_H
13#define ARCANE_CORE_ISERVICEFACTORY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Ref.h"
19
20#include <atomic>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
42class ARCANE_CORE_EXPORT IServiceFactoryInfo
43{
44 public:
45
48
49 public:
50
52 //TODO: check if autoload is still useful for these services.
53 virtual bool isAutoload() const = 0;
55 virtual bool isSingleton() const = 0;
56
57 public:
58
64 virtual IServiceInfo* serviceInfo() const = 0;
65};
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
70} // namespace Arcane
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75namespace Arcane::Internal
76{
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
87class ARCANE_CORE_EXPORT IServiceFactory2
88{
89 protected:
90
91 virtual ~IServiceFactory2() = default;
92
93 public:
94
96 virtual void addReference() = 0;
98 virtual void removeReference() = 0;
99
100 public:
101
104
106 virtual IServiceInfo* serviceInfo() const = 0;
107};
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
118class ARCANE_CORE_EXPORT AbstractServiceFactory
119: public IServiceFactory2
120{
121 protected:
122
123 AbstractServiceFactory()
124 : m_nb_ref(0)
125 {}
126
127 public:
128
129 void addReference() override;
130 void removeReference() override;
131
132 private:
133
134 std::atomic<Int32> m_nb_ref;
135};
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
144template <typename InterfaceType>
146: public AbstractServiceFactory
147{
148 public:
149
150 virtual Ref<InterfaceType> createServiceReference(const ServiceBuildInfoBase& sbi) = 0;
151};
152
153/*---------------------------------------------------------------------------*/
154/*---------------------------------------------------------------------------*/
155
166class ARCANE_CORE_EXPORT ISingletonServiceFactory
167{
168 public:
169
170 virtual ~ISingletonServiceFactory() = default;
171
175
177 virtual IServiceInfo* serviceInfo() const = 0;
178};
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
183} // namespace Arcane::Internal
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
188#endif
Declarations of Arcane's general types.
Information about a service factory.
virtual bool isAutoload() const =0
true if the service is a module and must be loaded automatically
virtual ~IServiceFactoryInfo()
Release resources.
virtual bool isSingleton() const =0
true if the service is a singleton service (a single instance)
virtual IServiceInfo * serviceInfo() const =0
Information about the service that can be created by this factory.
Interface for service or module information.
void removeReference() override
Remove a reference.
void addReference() override
Add a reference.
Factory for a service implementing the InterfaceType interface.
virtual void addReference()=0
Add a reference.
virtual IServiceInfo * serviceInfo() const =0
Returns the IServiceInfo associated with this factory.
virtual void removeReference()=0
Remove a reference.
virtual ServiceInstanceRef createServiceInstance(const ServiceBuildInfoBase &sbi)=0
Create a service instance from the info in sbi.
virtual Ref< ISingletonServiceInstance > createSingletonServiceInstance(const ServiceBuildInfoBase &sbi)=0
Create an instance of a singleton service.
virtual IServiceInfo * serviceInfo() const =0
Returns the IServiceInfo associated with this factory.
Reference to an instance.
Information for creating a service.
Reference to a service instance.
Internal types of Arcane.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --