Add ecs ComponentListener
- Add ecs ComponentListener which listens to Component addition and removal - Add RefCounter class used to keep track of moves and copies
This commit is contained in:
@@ -5,51 +5,17 @@
|
||||
namespace Copium
|
||||
{
|
||||
AssetRef::AssetRef(AssetHandle handle)
|
||||
: handle{handle}, refCounter{new int{1}}
|
||||
: handle{handle}
|
||||
{}
|
||||
|
||||
AssetRef::~AssetRef()
|
||||
{
|
||||
if (refCounter == nullptr)
|
||||
return;
|
||||
|
||||
(*refCounter)--;
|
||||
if (*refCounter == 0)
|
||||
if (refCounter.LastRef())
|
||||
{
|
||||
AssetManager::UnloadAsset(handle);
|
||||
delete refCounter;
|
||||
}
|
||||
}
|
||||
|
||||
AssetRef::AssetRef(const AssetRef& other)
|
||||
: handle{other.handle}, refCounter{other.refCounter}
|
||||
{
|
||||
(*refCounter)++;
|
||||
}
|
||||
|
||||
AssetRef::AssetRef(AssetRef&& other)
|
||||
: handle{other.handle}, refCounter{other.refCounter}
|
||||
{
|
||||
other.refCounter = nullptr;
|
||||
}
|
||||
|
||||
AssetRef& AssetRef::operator=(const AssetRef& rhs)
|
||||
{
|
||||
handle = rhs.handle;
|
||||
refCounter = rhs.refCounter;
|
||||
|
||||
(*refCounter)++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AssetRef& AssetRef::operator=(AssetRef&& rhs)
|
||||
{
|
||||
handle = rhs.handle;
|
||||
refCounter = rhs.refCounter;
|
||||
rhs.refCounter = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AssetRef::operator AssetHandle() const
|
||||
{
|
||||
return handle;
|
||||
|
||||
Reference in New Issue
Block a user