metaforce/Runtime/IAllocator.hpp

80 lines
1.7 KiB
C++
Raw Normal View History

2016-02-13 09:02:47 +00:00
#ifndef __PSHAG_IALLOCATOR_HPP__
#define __PSHAG_IALLOCATOR_HPP__
2015-08-17 05:26:58 +00:00
2015-08-23 18:53:43 +00:00
#include "RetroTypes.hpp"
2016-02-13 09:02:47 +00:00
namespace pshag
{
2015-08-22 01:58:41 +00:00
class COsContext;
2015-08-23 18:53:43 +00:00
class CCallStack;
2015-08-17 05:26:58 +00:00
class IAllocator
{
public:
2015-08-23 18:53:43 +00:00
virtual ~IAllocator() {}
2015-11-21 01:16:07 +00:00
enum class EHint
2015-08-23 18:53:43 +00:00
{
2015-11-21 01:16:07 +00:00
None = 0x0,
TopOfHeap = 0x1,
Large = 0x2
2015-08-23 18:53:43 +00:00
};
2015-11-21 01:16:07 +00:00
enum class EScope
2015-08-23 18:53:43 +00:00
{
2015-11-21 01:16:07 +00:00
None = 0,
Default = 1
2015-08-23 18:53:43 +00:00
};
2015-11-21 01:16:07 +00:00
enum class EType
2015-08-23 18:53:43 +00:00
{
2015-11-21 01:16:07 +00:00
Primitive = 0,
Array = 1
2015-08-23 18:53:43 +00:00
};
struct SAllocInfo
{
};
struct SMetrics
{
u32 a;
u32 b;
u32 c;
u32 d;
u32 e;
u32 f;
u32 g;
u32 h;
u32 i;
u32 j;
u32 k;
u32 l;
u32 m;
u32 n;
u32 o;
u32 p;
u32 q;
u32 r;
u32 s;
u32 t;
u32 u;
u32 v;
};
typedef bool(*TOutOfMemoryCallback)(void*, u32);
typedef bool(*TAllocationVisitCallback)(const SAllocInfo&, void*);
2015-08-28 00:11:31 +00:00
virtual bool Initialize()=0;
2015-08-17 05:26:58 +00:00
virtual void Shutdown()=0;
2015-08-23 23:58:07 +00:00
virtual void* Alloc(size_t, EHint, EScope, EType, const CCallStack&)=0;
2015-08-23 18:53:43 +00:00
virtual void Free(void*)=0;
virtual void ReleaseAll()=0;
2015-08-23 23:58:07 +00:00
virtual void* AllocSecondary(size_t, EHint, EScope, EType, const CCallStack&)=0;
2015-08-23 18:53:43 +00:00
virtual void FreeSecondary(void*)=0;
virtual void ReleaseAllSecondary()=0;
virtual void SetOutOfMemoryCallback(const TOutOfMemoryCallback, void*)=0;
virtual int EnumAllocations(const TAllocationVisitCallback, void*, bool) const=0;
virtual SAllocInfo GetAllocInfo(void*) const=0;
virtual void OffsetFakeStatics(int)=0;
virtual SMetrics GetMetrics() const=0;
2015-08-17 05:26:58 +00:00
};
}
2016-02-13 09:02:47 +00:00
#endif // __PSHAG_IALLOCATOR_HPP__