00001 #ifndef __LDK_OBJECT_H__ 00002 #define __LDK_OBJECT_H__ 00003 00005 // Copyright (C) 2003-2006 Lorien Dunn. 00006 // 00007 // Contact: loriendunn AT users DOT sourceforge DOT net 00008 // 00009 // This software is provided 'as-is', without any express or implied warranty. 00010 // In no event will the authors be held liable for any damages arising from 00011 // the use of this software. 00012 // 00013 // Permission is granted to anyone to use this software for any purpose, 00014 // including commercial applications, and to alter it and redistribute it 00015 // freely, subject to the following restrictions: 00016 // 00017 // 1. The origin of this software must not be misrepresented; you must not 00018 // claim that you wrote the original software. If you use this software in a 00019 // product, an acknowledgment in the product documentation would be 00020 // appreciated but is not required. 00021 // 00022 // 2. Altered source versions must be plainly marked as such, and must not be 00023 // misrepresented as being the original software. 00024 // 00025 // 3. This notice may not be removed or altered from any source distribution. 00026 // 00028 00029 #include "LDK/Types.h" 00030 00031 namespace LDK 00032 { 00033 00036 class LDK_API Object 00037 { 00038 private: 00039 mutable uint32 mRefCount; 00040 protected: 00041 inline Object(const Object& rhs) : mRefCount(0) {} 00042 inline void operator=(const Object& rhs) { mRefCount = 0; } 00043 public: 00044 inline static uint32 incRef(const Object& rhs) { return ++rhs.mRefCount; } 00045 static uint32 decRef(const Object& rhs); 00046 inline static uint32 refCount(const Object& rhs) { return rhs.mRefCount; } 00047 inline Object() : mRefCount(0) {} 00048 virtual ~Object() {} 00049 //angelscript compat methods 00050 void AddRef() { incRef(*this); } 00051 void Release() { decRef(*this); } 00052 }; 00053 00054 }//namespace LDK 00055 #endif //__LDK_OBJECT_H__