12#ifndef ROC_CORE_ALLOCATION_POLICY_H_
13#define ROC_CORE_ALLOCATION_POLICY_H_
37 template <
class T>
void destroy(T&
object) {
39 roc_panic(
"allocation policy: null allocator");
48 roc_panic(
"allocation policy: null allocator");
73 template <
class T>
void destroy(T&
object) {
75 roc_panic(
"allocation policy: null factory");
77 factory_->destroy(
object);
84 roc_panic(
"allocation policy: null factory");
95 typedef void (*DestroyFunc)(
void*);
101 : destroy_func_(NULL) {
108 : destroy_func_((DestroyFunc)destroy_func) {
113 if (!destroy_func_) {
114 roc_panic(
"allocation policy: null func");
116 destroy_func_(&
object);
120 DestroyFunc destroy_func_;
Allocation policy for objects (de)allocated using custom functions.
CustomAllocation()
Initialize in invalid state. Such instance wont be usable.
CustomAllocation(void(*destroy_func)(T *))
Initialize with given function. Such instance will use function to destroy objects.
void destroy(T &object)
Destroy object and deallocate its memory.
Allocation policy for objects (de)allocated using speciailized factory.
Factory & factory() const
Get factory.
FactoryAllocation()
Initialize in invalid state. Such instance wont be usable.
void destroy(T &object)
Destroy object and deallocate its memory.
FactoryAllocation(Factory &factory)
Initialize with given factory. Such instance will use factory to destroy objects.
Memory allocator interface.
void destroy_object(T &object)
Destroy object and deallocate its memory.
Allocation policy for objects (de)allocated using IAllocator.
void destroy(T &object)
Destroy object and deallocate its memory.
StandardAllocation(IAllocator &allocator)
Initialize with given allocator. Such instance will use allocator to destroy objects.
IAllocator & allocator() const
Get allocator.
StandardAllocation()
Initialize in invalid state. Such instance wont be usable.
Memory allocator interface.
#define roc_panic(...)
Print error message and terminate program gracefully.