Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #pragma once
00030
00031
00032 #include "../api_core.h"
00033
00034 template <typename Type>
00038 class CL_API_CORE CL_ComPtr
00039 {
00040 public:
00041 CL_ComPtr() : ptr(0) { }
00042 CL_ComPtr(Type *ptr) : ptr(ptr) { }
00043 CL_ComPtr(const CL_ComPtr ©) : ptr(copy.ptr) { if (ptr) ptr->AddRef(); }
00044 ~CL_ComPtr() { clear(); }
00045 CL_ComPtr &operator =(const CL_ComPtr ©)
00046 {
00047 if (this == ©)
00048 return *this;
00049 copy.ptr->AddRef();
00050 if (ptr)
00051 ptr->Release();
00052 ptr = copy.ptr;
00053 return *this;
00054 }
00055 const Type * const operator ->() const { return ptr; }
00056 Type *operator ->() { return ptr; }
00057 operator Type *() { return ptr; }
00058
00059 bool is_null() const { return ptr == 0; }
00060 void clear() { if (ptr) ptr->Release(); ptr = 0; }
00061 Type **output_variable() { clear(); return &ptr; }
00062
00063 Type *ptr;
00064 };
00065
00066