IRefCounted.h

00001 // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
00002 // This file is part of the "cAudio Engine"
00003 // For conditions of distribution and use, see copyright notice in cAudio.h
00004 
00005 #ifndef IREFCOUNTED_H
00006 #define IREFCOUNTED_H
00007 
00008 namespace cAudio
00009 {
00011         class IRefCounted
00012         {
00013         public:
00014                 IRefCounted() : RefCount(1) { }
00015                 virtual ~IRefCounted() { }
00016 
00018                 void grab()
00019                 {
00020                         ++RefCount; 
00021                 }
00022 
00024                 bool drop()
00025                 {
00026                         --RefCount;
00027                         if (RefCount < 1)
00028                         {
00029                                 delete this;
00030                                 return true;
00031                         }
00032                         return false;
00033                 }
00034 
00036                 int getReferenceCount() const
00037                 {
00038                         return RefCount;
00039                 }
00040 
00041         private:
00042                 int RefCount;
00043         };      
00044 }
00045 #endif 
 All Classes Namespaces Functions Variables Enumerations

Generated on Sat Feb 20 22:55:08 2010 for cAudio by  doxygen 1.6.2