resonance 1.0.1
Loading...
Searching...
No Matches
idableptr.h
Go to the documentation of this file.
1#pragma once
2
3#include "game/idable.h"
4#include "game/idablebase.h"
5#include "game/nullplayer.h"
6
29template <typename T>
30class IDablePtr {
31public:
33 IDablePtr() : mCached(nullptr), mId(-1) {
34 }
35
45 explicit IDablePtr(T *pObject) : mCached(pObject), mId(pObject != nullptr ? pObject->mId : -1) {
46 }
47
56 operator T *() const {
57 if (mCached == nullptr) {
58 mCached =
60 }
61 return mCached;
62 }
63
64 mutable T *mCached;
65 int mId;
66};
int mId
Definition idableptr.h:65
IDablePtr()
Start unresolved, with no identifier.
Definition idableptr.h:33
IDablePtr(T *pObject)
Refer to an object, already resolved.
Definition idableptr.h:45
T * mCached
Definition idableptr.h:64
static std::vector< T * > sObjects
Every registered object, indexed by mId.
Definition idable.h:64
static NullPlayer sInstance
Stand-in every unoccupied player reference stores.
Definition nullplayer.h:67
constexpr int kIDableUnregistered
Identifier a never-registered object stores, distinct from any real index.
Definition idablebase.h:4