40#ifndef GEOGRAM_BASIC_LIFE_CYCLE
41#define GEOGRAM_BASIC_LIFE_CYCLE
52#ifdef GEO_COMPILER_CLANG
53#pragma GCC diagnostic push
54#pragma GCC diagnostic ignored "-Wcast-align"
74 object_size_(object_size), is_pod_(is_pod) {
300 std::swap(*(T*)a, *(T*)b);
307 T* array = (T*)address;
319 T* lhs_array = (T*)lhs;
320 T* rhs_array = (T*)rhs;
322 new(&lhs_array[i])T(rhs_array[i]);
330 T* array = (T*)address;
343 T* lhs_array = (T*)lhs;
344 T* rhs_array = (T*)rhs;
346 lhs_array[i] = rhs_array[i];
354 T* array = (T*)address;
393 delete[]((T*)address);
400#ifdef GEO_COMPILER_CLANG
401#pragma GCC diagnostic pop
Base class for reference-counted objects.
Concrete implementation of LifeCycle.
void assign_array(Memory::pointer lhs, Memory::pointer rhs, index_t nb) override
Copies an array of object at a given address.
void construct(Memory::pointer address) override
Calls the constructor of an object.
void reset(Memory::pointer address) override
Resets an object to its default value.
Memory::pointer new_object(Memory::pointer rhs) override
Dynamically allocates a new object.
void delete_object(Memory::pointer address) override
Deletes an object.
void copy_construct_array(Memory::pointer lhs, Memory::pointer rhs, index_t nb) override
Copy-Constructs an array of object at a given address.
void destroy_array(Memory::pointer address, index_t nb) override
Destroys an array of object at a given address.
void reset_array(Memory::pointer address, index_t nb) override
Resets all objects in an array to their default value.
Memory::pointer new_object() override
Dynamically allocates a new object.
GenericLifeCycle()
GenericLifeCycle constructor.
void construct_array(Memory::pointer address, index_t nb) override
Calls the constructor of objects in an array.
void destroy(Memory::pointer address) override
Calls the destructor of an object.
void assign(Memory::pointer lhs, Memory::pointer rhs) override
Calls the assignment operator.
void copy_construct(Memory::pointer lhs, Memory::pointer rhs) override
Copy-Constructs an object at a given address.
Memory::pointer new_array(index_t nb) override
Dynamically allocates an array of objects.
void swap(Memory::pointer a, Memory::pointer b) override
Swaps the objects at two addresses.
void delete_array(Memory::pointer address) override
Deletes an array of objects.
Manages the life cycle of an object.
virtual Memory::pointer new_array(index_t nb)=0
Dynamically allocates an array of objects.
virtual void assign_array(Memory::pointer lhs, Memory::pointer rhs, index_t nb)=0
Copies an array of object at a given address.
virtual void delete_object(Memory::pointer address)=0
Deletes an object.
virtual void delete_array(Memory::pointer address)=0
Deletes an array of objects.
virtual void copy_construct(Memory::pointer lhs, Memory::pointer rhs)=0
Copy-Constructs an object at a given address.
virtual Memory::pointer new_object(Memory::pointer rhs)=0
Dynamically allocates a new object with copy constructor.
virtual void reset(Memory::pointer address)=0
Resets an object to its default value.
virtual void copy_construct_array(Memory::pointer lhs, Memory::pointer rhs, index_t nb)=0
Copy-Constructs an array of object at a given address.
virtual void reset_array(Memory::pointer address, index_t nb)=0
Resets all objects in an array to their default value.
virtual void construct_array(Memory::pointer address, index_t nb)=0
Calls the constructor of objects in an array.
bool is_pod() const
Tests whether object is pod (plain ordinary datatype).
virtual void destroy_array(Memory::pointer address, index_t nb)=0
Destroys an array of object at a given address.
virtual void swap(Memory::pointer a, Memory::pointer b)=0
Swaps the objects at two addresses.
virtual void destroy(Memory::pointer address)=0
Calls the destructor of an object.
size_t object_size() const
Gets the size of an object.
virtual void assign(Memory::pointer lhs, Memory::pointer rhs)=0
Calls the assignment operator.
virtual void construct(Memory::pointer address)=0
Calls the constructor of an object.
LifeCycle(size_t object_size, bool is_pod=false)
LifeCycle constructor.
~LifeCycle() override
LifeCycle destructor.
virtual Memory::pointer new_object()=0
Dynamically allocates a new object.
A smart pointer with reference-counted copy semantics.
Base class of reference-counted objects, to be used with smart pointers.
Common include file, providing basic definitions. Should be included before anything else by all head...
Types and functions for memory manipulation.
byte * pointer
Pointer to unsigned byte(s)
Global Vorpaline namespace.
void geo_argused(const T &)
Suppresses compiler warnings about unused parameters.
SmartPointer< LifeCycle > LifeCycle_var
A reference_counted pointer to a LifeCycle.
geo_index_t index_t
The type for storing and manipulating indices.