cAudio  2.3.0
3d Audio Engine
IRefCounted.h
1 // Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
2 // This file is part of the "cAudio Engine"
3 // For conditions of distribution and use, see copyright notice in cAudio.h
4 
5 #pragma once
6 
7 #include "cAudioMemory.h"
8 
9 namespace cAudio
10 {
13  {
14  public:
15  IRefCounted() : RefCount(1) { }
16  virtual ~IRefCounted() { }
17 
19  virtual void grab()
20  {
21  ++RefCount;
22  }
23 
25  virtual bool drop()
26  {
27  --RefCount;
28  if (RefCount < 1)
29  {
30  CAUDIO_DELETE this;
31  return true;
32  }
33  return false;
34  }
35 
37  int getReferenceCount() const
38  {
39  return RefCount;
40  }
41 
42  protected:
43  int RefCount;
44  };
45 }
Applies reference counting to certain cAudio objects.
Definition: IRefCounted.h:12
virtual void grab()
Increments the reference count by one.
Definition: IRefCounted.h:19
virtual bool drop()
Decrements the reference count by one. If it hits zero, this object is deleted.
Definition: IRefCounted.h:25
int getReferenceCount() const
Returns the current reference count of this object.
Definition: IRefCounted.h:37
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:15