add atReferenceCounter (#137)

This commit is contained in:
PliskinDev
2023-09-07 23:02:43 +03:00
committed by GitHub
parent 9069c364e4
commit 578e1cbd4b
2 changed files with 31 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include "../base/datBase.hpp"
namespace rage
{
class atReferenceCounter : public datBase
{
public:
atReferenceCounter() : m_ref_count(0) {}
void AddReference() {
m_ref_count++;
}
void ReleaseReference() {
m_ref_count--;
if(m_ref_count == 0) {
delete this;
}
}
int GetReferenceCount() const {
return m_ref_count;
}
private:
int m_ref_count; // 0x0000
};
}