83 lines
1.4 KiB
C++
83 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <a8/list.h>
|
|
|
|
class Creature;
|
|
|
|
class CreatureWeakPtrChunk
|
|
{
|
|
public:
|
|
|
|
CreatureWeakPtrChunk();
|
|
~CreatureWeakPtrChunk();
|
|
void Clear();
|
|
void Set(Creature* c);
|
|
|
|
private:
|
|
Creature* ptr_ = nullptr;
|
|
list_head ptrs_;
|
|
friend class CreatureWeakPtr;
|
|
};
|
|
|
|
class CreatureWeakPtr
|
|
{
|
|
public:
|
|
|
|
CreatureWeakPtr();
|
|
CreatureWeakPtr(const CreatureWeakPtr& x);
|
|
CreatureWeakPtr(CreatureWeakPtr&& x);
|
|
CreatureWeakPtr& operator=(const CreatureWeakPtr& x);
|
|
CreatureWeakPtr&& operator=(CreatureWeakPtr&& x);
|
|
~CreatureWeakPtr();
|
|
void Reset();
|
|
Creature* Get();
|
|
void Attach(Creature* c);
|
|
void Detach();
|
|
|
|
private:
|
|
Creature* ptr_ = nullptr;
|
|
list_head entry_;
|
|
|
|
friend class CreatureWeakPtrChunk;
|
|
};
|
|
|
|
class Entity;
|
|
|
|
class EntityWeakPtrChunk
|
|
{
|
|
public:
|
|
|
|
EntityWeakPtrChunk();
|
|
~EntityWeakPtrChunk();
|
|
void Clear();
|
|
void Set(Entity* c);
|
|
|
|
private:
|
|
Entity* ptr_ = nullptr;
|
|
list_head ptrs_;
|
|
friend class EntityWeakPtr;
|
|
};
|
|
|
|
class EntityWeakPtr
|
|
{
|
|
public:
|
|
|
|
EntityWeakPtr();
|
|
EntityWeakPtr(const EntityWeakPtr& x);
|
|
EntityWeakPtr(EntityWeakPtr&& x);
|
|
EntityWeakPtr& operator=(const EntityWeakPtr& x);
|
|
EntityWeakPtr&& operator=(EntityWeakPtr&& x);
|
|
~EntityWeakPtr();
|
|
void Reset();
|
|
Entity* Get();
|
|
void Attach(Entity* c);
|
|
void Detach();
|
|
|
|
private:
|
|
Entity* ptr_ = nullptr;
|
|
list_head entry_;
|
|
|
|
friend class EntityWeakPtrChunk;
|
|
};
|