Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

IUnknown.h

00001 
00002 #ifndef __IUNKNOWN_H_
00003 #define __IUNKNOWN_H_
00004 /*
00005 Peon - Win32 Games Programming Library
00006 Copyright (C) 2002-2005 Erik Yuzwa
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Library General Public
00010 License as published by the Free Software Foundation; either
00011 version 2 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Library General Public License for more details.
00017 
00018 You should have received a copy of the GNU Library General Public
00019 License along with this library; if not, write to the Free
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 Erik Yuzwa
00023 peon AT wazooinc DOT com
00024 */
00025 
00026 #include "Peonstdafx.h"
00027 
00028 namespace peon
00029 {
00044         class PEONMAIN_API IUnknown
00045         {
00046         protected:
00048                 int             m_id;
00049 
00051                 int             m_refCount;
00052 
00053         public:
00057                 IUnknown() : m_refCount(1), m_id(0)
00058                 {
00059                 }
00060 
00064                 virtual ~IUnknown()
00065                 {
00066                 
00067                 }
00068 
00073                 int getID(){ return m_id; }
00074 
00079                 void setID( int new_id ){ m_id = new_id; }
00080 
00093                 void addRefCount() { ++m_refCount; }
00094 
00099                 bool dropRefCount()
00100                 {
00101                         //decrement the reference counter variable. If we drop
00102                         //below zero, then we can automatically clean this up
00103                         //with a delete call.
00104                         //
00105                         --m_refCount;
00106                         if (!m_refCount)
00107                         {
00108                                 delete this;
00109                                 return true;
00110                         }
00111 
00112                         return false;
00113                 }
00114 
00115         };
00116 }
00117 
00118 #endif

Generated on Thu Dec 1 01:55:40 2005 for Peon by  doxygen 1.4.1