V-Gears 0
Free Final Fantasy VII engine.
RefCounted.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18class RefCounted;
19
20inline void intrusive_ptr_add_ref(RefCounted *ptr);
21inline void intrusive_ptr_release(RefCounted *ptr);
22
29
30 protected:
32 virtual ~RefCounted(){}
33
34 private:
35
40
42
44
45
46};
47
53inline void intrusive_ptr_add_ref(RefCounted *ptr){++ (ptr->ref_count_);}
54
61 if (-- (ptr->ref_count_) == 0) delete ptr;
62}
void intrusive_ptr_add_ref(RefCounted *ptr)
Add a reference to a pointer.
Definition: RefCounted.h:53
void intrusive_ptr_release(RefCounted *ptr)
Remove a reference from a pointer.
Definition: RefCounted.h:60
Provides a base implementation of reference counting.
Definition: RefCounted.h:28
RefCounted()
Definition: RefCounted.h:31
long ref_count_
Reference count used for boost::intrusive_ptr.
Definition: RefCounted.h:39
virtual ~RefCounted()
Definition: RefCounted.h:32