2021-08-10 08:55:19 +00:00

122 lines
2.3 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 RoomObstacle;
class RoomObstacleWeakPtrChunk
{
public:
RoomObstacleWeakPtrChunk();
~RoomObstacleWeakPtrChunk();
void Clear();
void Set(RoomObstacle* c);
private:
RoomObstacle* ptr_ = nullptr;
list_head ptrs_;
friend class RoomObstacleWeakPtr;
};
class RoomObstacleWeakPtr
{
public:
RoomObstacleWeakPtr();
RoomObstacleWeakPtr(const RoomObstacleWeakPtr& x);
RoomObstacleWeakPtr(RoomObstacleWeakPtr&& x);
RoomObstacleWeakPtr& operator=(const RoomObstacleWeakPtr& x);
RoomObstacleWeakPtr&& operator=(RoomObstacleWeakPtr&& x);
~RoomObstacleWeakPtr();
void Reset();
RoomObstacle* Get();
void Attach(RoomObstacle* c);
void Detach();
private:
RoomObstacle* ptr_ = nullptr;
list_head entry_;
friend class RoomObstacleWeakPtrChunk;
};
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;
};