Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ServiceInstance.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/* ServiceInstance.h (C) 2000-2025 */
9/* */
10/* Service instance. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_SERVICEINSTANCE_H
13#define ARCANE_CORE_SERVICEINSTANCE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Ref.h"
18#include "arcane/core/IService.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
35class ARCANE_CORE_EXPORT ServiceInstanceRef
36{
37 typedef Ref<IServiceInstance> RefType;
38
39 private:
40
41 ServiceInstanceRef(const RefType& r)
42 : m_instance(r)
43 {}
44
45 public:
46
47 ServiceInstanceRef() = default;
48
49 public:
50
51 static ServiceInstanceRef createRef(IServiceInstance* p)
52 {
53 return ServiceInstanceRef(RefType::create(p));
54 }
55 static ServiceInstanceRef createRefNoDestroy(IServiceInstance* p)
56 {
57 return ServiceInstanceRef(RefType::_createNoDestroy(p));
58 }
59 static ServiceInstanceRef createWithHandle(IServiceInstance* p, Internal::ExternalRef handle)
60 {
61 return ServiceInstanceRef(RefType::createWithHandle(p, handle));
62 }
63
64 public:
65
66 IServiceInstance* get() const { return m_instance.get(); }
67 void reset() { m_instance.reset(); }
68
69 private:
70
71 RefType m_instance;
72};
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77inline bool operator==(const ServiceInstanceRef& a, const ServiceInstanceRef& b)
78{
79 return a.get() == b.get();
80}
81
82inline bool operator!=(const ServiceInstanceRef& a, const ServiceInstanceRef& b)
83{
84 return a.get() != b.get();
85}
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
89
90} // End namespace Arcane
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95#endif
Interface of a service instance.
Definition IService.h:69
Management of references to an external object.
Reference to an instance.
static ThatClass create(IServiceInstance *t)
static ThatClass createWithHandle(IServiceInstance *t, Internal::ExternalRef handle)
Reference to a service instance.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --