]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/meshtex/RefCounted.cpp
* added MeshTex plugin src to project (can't compile)
[xonotic/netradiant.git] / contrib / meshtex / RefCounted.cpp
1 /**
2  * @file RefCounted.cpp
3  * Implements the RefCounted class.
4  * @ingroup generic-util
5  */
6
7 /*
8  * Copyright 2012 Joel Baxter
9  *
10  * This file is part of MeshTex.
11  *
12  * MeshTex is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * MeshTex is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
24  */
25
26 #include "RefCounted.h"
27
28
29 /**
30  * Default constructor. Initialize reference count to zero.
31  */
32 RefCounted::RefCounted() :
33    _refCount(0)
34 {
35 }
36
37 /**
38  * Virtual destructor.
39  */
40 RefCounted::~RefCounted()
41 {
42 }
43
44 /**
45  * Increment reference count.
46  */
47 void
48 RefCounted::IncRef()
49 {
50    ++_refCount;
51 }
52
53 /**
54  * Decrement reference count, and self-delete if count is <= 0.
55  */
56 void
57 RefCounted::DecRef()
58 {
59    if (--_refCount <= 0)
60    {
61       delete this;
62    }
63 }