Geogram Version 1.9.7
A programming library of geometric algorithms
|
Manages the life cycle of an object. More...
#include <geogram/basic/life_cycle.h>
Public Member Functions | |
LifeCycle (size_t object_size, bool is_pod=false) | |
LifeCycle constructor. | |
~LifeCycle () override | |
LifeCycle destructor. | |
size_t | object_size () const |
Gets the size of an object. | |
bool | is_pod () const |
Tests whether object is pod (plain ordinary datatype). | |
virtual void | construct (Memory::pointer address)=0 |
Calls the constructor of an object. | |
virtual void | copy_construct (Memory::pointer lhs, Memory::pointer rhs)=0 |
Copy-Constructs an object at a given address. | |
virtual void | destroy (Memory::pointer address)=0 |
Calls the destructor of an object. | |
virtual void | assign (Memory::pointer lhs, Memory::pointer rhs)=0 |
Calls the assignment operator. | |
virtual void | reset (Memory::pointer address)=0 |
Resets an object to its default value. | |
virtual void | swap (Memory::pointer a, Memory::pointer b)=0 |
Swaps the objects at two addresses. | |
virtual void | construct_array (Memory::pointer address, index_t nb)=0 |
Calls the constructor of objects in an array. | |
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 | destroy_array (Memory::pointer address, index_t nb)=0 |
Destroys an array of object at a given address. | |
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 | reset_array (Memory::pointer address, index_t nb)=0 |
Resets all objects in an array to their default value. | |
virtual Memory::pointer | new_object ()=0 |
Dynamically allocates a new object. | |
virtual Memory::pointer | new_object (Memory::pointer rhs)=0 |
Dynamically allocates a new object with copy constructor. | |
virtual void | delete_object (Memory::pointer address)=0 |
Deletes an object. | |
virtual Memory::pointer | new_array (index_t nb)=0 |
Dynamically allocates an array of objects. | |
virtual void | delete_array (Memory::pointer address)=0 |
Deletes an array of objects. | |
![]() | |
void | ref () const |
Increments the reference count. | |
void | unref () const |
Decrements the reference count. | |
bool | is_shared () const |
Check if the object is shared. | |
int | nb_refs () const |
Gets the number of references that point to this object. | |
Additional Inherited Members | |
![]() | |
static void | ref (const Counted *counted) |
Increments the reference count. | |
static void | unref (const Counted *counted) |
Decrements the reference count. | |
![]() | |
Counted () | |
Creates a reference counted object. | |
virtual | ~Counted () |
Destroys a reference counted object. | |
Manages the life cycle of an object.
Provides ways to call the constructor, destructor, copy constructor and assignation operator on objects known only from their addresses as raw untyped pointers. This is used by the Attribute mechanism of Geogram and by the Any class in Graphite/GOM.
Definition at line 66 of file life_cycle.h.
|
inline |
LifeCycle constructor.
[in] | object_size | the size of an object in bytes. |
Definition at line 73 of file life_cycle.h.
|
pure virtual |
Calls the assignment operator.
[in] | lhs | the address of the left hand side. |
[in] | rhs | the address of the right hand side. |
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Copies an array of object at a given address.
[in] | lhs | the address of the left-hand-side objects |
[in] | rhs | the address of the right-hand-side objects to be copied. |
[in] | nb | number of objects |
No memory allocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Calls the constructor of an object.
[in] | address | the address of the object to be constructed. |
No memory allocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Calls the constructor of objects in an array.
[in] | address | the address of the object array to be constructed. |
[in] | nb | number of objects. |
No memory allocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Copy-Constructs an object at a given address.
[in] | lhs | the address where the object should be constructed. |
[in] | rhs | the address of the right-hand-side object to be copied. |
No memory allocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Copy-Constructs an array of object at a given address.
[in] | lhs | the address of the objects to be constructed. |
[in] | rhs | the address of the right-hand-side objects to be copied. |
[in] | nb | number of objects |
No memory allocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Deletes an array of objects.
[in] | address | the address of the object array to be deleted. |
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Deletes an object.
[in] | address | the address of the object. |
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Calls the destructor of an object.
[in] | address | the address of the object to be destructed. |
No memory deallocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Destroys an array of object at a given address.
[in] | address | the address of the objects to be destroyed. |
[in] | nb | number of objects |
No memory deallocation is done.
Implemented in GEO::GenericLifeCycle< T >.
|
inline |
Tests whether object is pod (plain ordinary datatype).
Plain ordinary datatypes can be copied with memcpy().
true | if object is pod. |
false | otherwise. |
Definition at line 98 of file life_cycle.h.
|
pure virtual |
Dynamically allocates an array of objects.
[in] | nb | number of objects. |
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Dynamically allocates a new object.
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Dynamically allocates a new object with copy constructor.
[in] | rhs | the address of the right-hand-side objects to be copied. |
Implemented in GEO::GenericLifeCycle< T >.
|
inline |
Gets the size of an object.
Definition at line 86 of file life_cycle.h.
|
pure virtual |
Resets an object to its default value.
Creates a new object with the default constructor and assigns it to the object at address
.
[in] | address | the address of an already initialized object. |
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Resets all objects in an array to their default value.
creates an object with the default value and assigns it to the element for each element in the array.
[in] | address | the address of the object array to be reset. |
[in] | nb | number of objects. |
Implemented in GEO::GenericLifeCycle< T >.
|
pure virtual |
Swaps the objects at two addresses.
[in] | a,b | pointers to the two objects to be swapped |
Implemented in GEO::GenericLifeCycle< T >.