PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: RefCountPtr.h * 00003 * 00004 * Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight 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 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_REFCOUNT_PTR_H__ 00024 #define __PLCORE_REFCOUNT_PTR_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/Core/RefCount.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Classes ] 00042 //[-------------------------------------------------------] 00043 /** 00044 * @brief 00045 * Reference counted pointer template 00046 * 00047 * @remarks 00048 * RefCountPtr contains a pointer to the reference counted object, 00049 * while RefCount is used in derived classes and therefore is the 00050 * reference counted object itself. 00051 */ 00052 template <class AType> 00053 class RefCountPtr : public RefCount<AType> { 00054 00055 00056 //[-------------------------------------------------------] 00057 //[ Public functions ] 00058 //[-------------------------------------------------------] 00059 public: 00060 /** 00061 * @brief 00062 * Constructor 00063 * 00064 * @param[in] pPointer 00065 * Pointer to the referenced object, can be a null pointer 00066 */ 00067 RefCountPtr(AType *pPointer); 00068 00069 /** 00070 * @brief 00071 * Destructor 00072 */ 00073 virtual ~RefCountPtr(); 00074 00075 /** 00076 * @brief 00077 * Get a pointer to the object 00078 * 00079 * @return 00080 * Pointer to the reference counter's object, can be a null pointer 00081 */ 00082 virtual const AType *GetPointer() const override; 00083 virtual AType *GetPointer() override; 00084 00085 00086 //[-------------------------------------------------------] 00087 //[ Private data ] 00088 //[-------------------------------------------------------] 00089 private: 00090 AType *m_pPointer; /**< Pointer to the referenced object, can be a null pointer */ 00091 00092 00093 }; 00094 00095 00096 //[-------------------------------------------------------] 00097 //[ Namespace ] 00098 //[-------------------------------------------------------] 00099 } // PLCore 00100 00101 00102 //[-------------------------------------------------------] 00103 //[ Implementation ] 00104 //[-------------------------------------------------------] 00105 #include "PLCore/Core/RefCountPtr.inl" 00106 00107 00108 #endif // __PLCORE_REFCOUNT_PTR_H__
|