Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ISharedReference.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/* ISharedReference.h (C) 2000-2025 */
9/* */
10/* Interface of the reference counter class. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ISHAREDREFERENCE_H
13#define ARCANE_CORE_ISHAREDREFERENCE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Ptr.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \ingroup Core
30 * \brief Interface of a reference counter.
31 *
32 * The reference counter allows a class instance to know the number
33 * of references on it. When this number reaches zero, it means
34 * that the instance is no longer used. This system is used primarily
35 * to automatically free memory when the number of references
36 * drops to zero.
37 *
38 * This class is used through classes like AutoRefT which
39 * allow automatically incrementing or decrementing the counter
40 * of the objects they point to.
41 */
42class ARCANE_CORE_EXPORT ISharedReference
43{
44 public:
45
46 //! Releases resources
47 virtual ~ISharedReference() = default;
48
49 public:
50
51 //! Increments the reference counter
52 virtual void addRef() = 0;
53
54 //! Decrements the reference counter
55 virtual void removeRef() = 0;
56
57 //! Returns the value of the reference counter
58 virtual Int32 refCount() const = 0;
59};
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64} // namespace Arcane
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69#endif
Interface of a reference counter.
virtual Int32 refCount() const =0
Returns the value of the reference counter.
virtual ~ISharedReference()=default
Releases resources.
virtual void removeRef()=0
Decrements the reference counter.
virtual void addRef()=0
Increments the reference counter.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.