2022-04-10 00:17:06 +00:00
|
|
|
#ifndef _RSTL_RC_PTR_HPP
|
|
|
|
#define _RSTL_RC_PTR_HPP
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
class CRefData {
|
|
|
|
public:
|
2022-09-13 04:26:54 +00:00
|
|
|
CRefData(void* ptr) : x0_ptr(ptr), x4_refCount(1) {}
|
|
|
|
CRefData(void* ptr, int refCount) : x0_ptr(ptr), x4_refCount(refCount) {}
|
|
|
|
|
|
|
|
void* x0_ptr;
|
2022-04-10 00:17:06 +00:00
|
|
|
unsigned int x4_refCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace rstl {
|
|
|
|
template < typename T >
|
|
|
|
class rc_ptr {
|
|
|
|
public:
|
2022-09-13 04:26:54 +00:00
|
|
|
rc_ptr(T* ptr) : x0_refData(new CRefData(ptr)) {}
|
2022-04-10 00:17:06 +00:00
|
|
|
~rc_ptr();
|
2022-09-13 04:26:54 +00:00
|
|
|
T* GetPtr() const { return reinterpret_cast< T* >(x0_refData->x0_ptr); }
|
2022-08-16 02:14:28 +00:00
|
|
|
// TODO ReleaseData__Q24rstl20rc_ptr
|
|
|
|
T* operator->() const { return GetPtr(); }
|
|
|
|
T& operator*() const { return *GetPtr(); }
|
2022-09-13 04:26:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
CRefData* x0_refData;
|
2022-04-10 00:17:06 +00:00
|
|
|
};
|
2022-08-14 18:38:41 +00:00
|
|
|
|
|
|
|
template < typename T >
|
|
|
|
class ncrc_ptr : public rc_ptr< T > {
|
2022-09-13 04:26:54 +00:00
|
|
|
public:
|
|
|
|
ncrc_ptr(T* ptr) : rc_ptr(ptr) {}
|
2022-08-14 18:38:41 +00:00
|
|
|
};
|
2022-04-10 00:17:06 +00:00
|
|
|
} // namespace rstl
|
|
|
|
|
|
|
|
#endif
|