Blender V5.0
MEM_RefCounted.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#ifndef __MEM_REFCOUNTED_H__
12#define __MEM_REFCOUNTED_H__
13
26 public:
30 MEM_RefCounted() = default;
31
36 inline virtual int getRef() const;
37
42 inline virtual int incRef();
43
49 inline virtual int decRef();
50
51 protected:
56 virtual ~MEM_RefCounted() = default;
57
59 int m_refCount = 1;
60};
61
62inline int MEM_RefCounted::getRef() const
63{
64 return m_refCount;
65}
66
68{
69 return ++m_refCount;
70}
71
73{
74 m_refCount--;
75 if (m_refCount == 0) {
76 delete this;
77 return 0;
78 }
79 return m_refCount;
80}
81
82#endif // __MEM_REFCOUNTED_H__
virtual int getRef() const
virtual ~MEM_RefCounted()=default
virtual int decRef()
virtual int incRef()
MEM_RefCounted()=default