RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
ik_IRefCounted.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2014 Nikolaus Gebhardt
2 // This file is part of the "irrKlang" library.
3 // For conditions of distribution and use, see copyright notice in irrKlang.h
4 
5 #ifndef __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__
6 #define __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__
7 
8 #include "ik_irrKlangTypes.h"
9 
10 namespace irrklang
11 {
13 
42  {
43  public:
44 
47  : ReferenceCounter(1)
48  {
49  }
50 
52  virtual ~IRefCounted()
53  {
54  }
55 
80  void grab() { ++ReferenceCounter; }
81 
98  bool drop()
99  {
100  --ReferenceCounter;
101 
102  if (!ReferenceCounter)
103  {
104  delete this;
105  return true;
106  }
107 
108  return false;
109  }
110 
111  private:
112 
113  ik_s32 ReferenceCounter;
114  };
115 
116 } // end namespace irr
117 
118 #endif
119 
Base class of most objects of the irrKlang.
signed int ik_s32
32 bit signed variable.
Everything in the irrKlang Sound Engine can be found in this namespace.
IRefCounted()
Constructor.
virtual ~IRefCounted()
Destructor.