Atlas-Launcher/source/utils/angelscript/MixinAsReferenceCount.hpp

34 lines
No EOL
684 B
C++

#pragma once
#include <cstddef>
namespace atlas::utils::angelscript {
/**
* A Mixin class to automatically implement the reference counting mechanism
* required for the AngelScript interpreter to run the garbage collector
*/
class MixinAsReferenceCount {
public:
MixinAsReferenceCount();
/**
* Called when the object is used in another reference.
*/
void asAddReference();
/**
* Called when the object shall be freed.
*/
void asRelease();
private:
/** the reference count of the object.
* once it reaches zero, this imply object is no longuer used
* and should be destroyed.
*/
std::size_t referenceCount;
};
}