]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/meshtex/RefCounted.h
Merge commit 'b017c473e86330d5908858b8add1b16674b0a1a8' into garux-merge
[xonotic/netradiant.git] / contrib / meshtex / RefCounted.h
1 /**
2  * @file RefCounted.h
3  * Declares 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 #if !defined(INCLUDED_REFCOUNTED_H)
27 #define INCLUDED_REFCOUNTED_H
28
29 /**
30  * A mixin for maintaining a reference count associated with an object, and
31  * destroying that object when the count falls to zero. Since this class
32  * implements the IncRef and DecRef interfaces used by the Radiant
33  * SmartPointer and SmartReference templates, those templates can
34  * automatically handle the reference counting for classes that inherit from
35  * RefCounted.
36  *
37  * @ingroup generic-util
38  */
39 class RefCounted
40 {
41 public: // public methods
42
43    /// @name Lifecycle
44    //@{
45    RefCounted();
46    virtual ~RefCounted();
47    //@}
48    /// @name Reference counting
49    //@{
50    void IncRef();
51    void DecRef();
52    //@}
53
54 private: // private member vars
55
56    /**
57     * Reference count.
58     */
59    int _refCount;
60 };
61
62 #endif // #if !defined(INCLUDED_REFCOUNTED_H)