Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members

ik_IRefCounted.h

Go to the documentation of this file.
00001 // Copyright (C) 2002-2008 Nikolaus Gebhardt
00002 // This file is part of the "irrKlang" library.
00003 // For conditions of distribution and use, see copyright notice in irrKlang.h
00004 
00005 #ifndef __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__
00006 #define __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__
00007 
00008 #include "ik_irrKlangTypes.h"
00009 
00010 namespace irrklang
00011 {
00013 
00039         class IRefCounted
00040         {
00041         public:
00042 
00044                 IRefCounted()
00045                         : ReferenceCounter(1)
00046                 {
00047                 }
00048 
00050                 virtual ~IRefCounted()
00051                 {
00052                 }
00053 
00082                 void grab() { ++ReferenceCounter; }
00083 
00110                 bool drop()
00111                 {
00112                         --ReferenceCounter;
00113 
00114                         if (!ReferenceCounter)
00115                         {
00116                                 delete this;
00117                                 return true;
00118                         }
00119 
00120                         return false;
00121                 }
00122 
00123         private:
00124 
00125                 ik_s32  ReferenceCounter;
00126         };
00127 
00128 } // end namespace irr
00129 
00130 #endif
00131 

irrKlang Audio Library
The irrKlang Engine Documentation © 2003-2007 by Nikolaus Gebhardt. Generated on Sun Oct 12 13:44:49 2008 by Doxygen (1.5.4)