CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Allocator.hpp
Go to the documentation of this file.
1 #pragma once
3 namespace CYB {
4  namespace API {
5  namespace Interop {
7  class Allocator {
8  ENABLE_TEST_HOOKS
9  public:
11  private:
24  virtual void* InteropAllocation(const Allocatable::ID AID, Constructor<void>& AConstructor) = 0;
25  protected:
32  Allocator(Heap& AHeap) noexcept;
33 
46  template <class AObject, typename AConstructor, typename... AArgs> AObject* AllocateObject(const std::true_type AIgnored, AArgs&&... AArguments);
59  template <class AObject, typename AIgnoredConstructor, typename... AArgs> AObject* AllocateObject(const std::false_type AIgnored, AArgs&&... AArguments);
60  public:
72  template <typename AType, typename... AArgs> static AType* InPlaceAllocation(void* const ALocation, AArgs&&... AArguments);
73 
86  template <class AObject, class AConstructor, typename... AArgs> Object<AObject> ConstructObject(AArgs&&... AArguments);
98  template <class AObject, typename... AArgs> Object<AObject> NewObject(AArgs&&... AArguments);
108  template <class AObject> Object<AObject> NewObject(void);
109 
120  template <class AObject> Object<AObject> CopyObject(const AObject& ACopy);
121 
128  template <class AObject> void DeleteObject(AObject* const AAllocated) noexcept;
129  };
130  };
131  };
132 };
Template type for wrapping pointers and treating them as objects. Only works with CyberEngine interfa...
Definition: Object.hpp:10
Object< AObject > CopyObject(const AObject &ACopy)
Copys an Object of type AObject.
ID
Defines the IDs of allocatable engine objects.
Definition: Allocatable.hpp:10
Heap & FHeap
The Heap this allocator uses.
Definition: Allocator.hpp:10
Used as a base class by all constructors.
Definition: Constructor.hpp:56
Object< AObject > ConstructObject(AArgs &&...AArguments)
Allocates the Object specified by AObject using a specified Constructor.
Object< AObject > NewObject(void)
Allocates the Object specified by AObject using the empty constructor.
Used for allocating objects within and without the engine.
Definition: Allocator.hpp:7
virtual void * InteropAllocation(const Allocatable::ID AID, Constructor< void > &AConstructor)=0
Allocates the object specified by AID into FHeap.
AObject * AllocateObject(const std::true_type AIgnored, AArgs &&...AArguments)
Allocate an Allocatable object through interop.
Allocator(Heap &AHeap) noexcept
Construct an Allocator.
static AType * InPlaceAllocation(void *const ALocation, AArgs &&...AArguments)
Wrapper for placement new.
An interface which can allocate memory.
Definition: Heap.hpp:5
void DeleteObject(AObject *const AAllocated) noexcept
Deletes an object allocated with the Allocator.