fallout2-ce/src/pointer_registry.h

28 lines
468 B
C
Raw Normal View History

2022-07-05 01:00:55 -07:00
#ifndef POINTER_REGISTRY_H
#define POINTER_REGISTRY_H
#include <unordered_map>
2022-09-23 05:43:44 -07:00
namespace fallout {
2022-07-05 01:00:55 -07:00
class PointerRegistry {
public:
static PointerRegistry* shared();
PointerRegistry();
int store(void* ptr);
void* fetch(int ref, bool remove = false);
private:
std::unordered_map<int, void*> _map;
int _next;
};
int ptrToInt(void* ptr);
void* intToPtr(int ref, bool remove = false);
2022-09-23 05:43:44 -07:00
} // namespace fallout
2022-07-05 01:00:55 -07:00
#endif /* POINTER_REGISTRY_H */