|
CeresEngine 0.2.0
A game development framework
|
A type-safe component store implementation. More...
#include <CeresEngine/Entity/ComponentStore.hpp>
Public Member Functions | |
| ComponentStore (const size_t chunkSize) | |
Creates a new component store with the given chunkSize. | |
| ~ComponentStore () noexcept final=default | |
| Destroys the component store. | |
| template<typename... Args> | |
| C & | create (const EntityIndex entityIndex, Args &&... args) noexcept(std::is_nothrow_constructible_v< C, Args... >) |
Creates a new component at entityIndex position. | |
| C & | create (const EntityIndex entityIndex) final |
Creates a new component at entityIndex position. | |
| void | destroy (const EntityIndex entityIndex) final |
Destroys the component located at entityIndex. | |
| void | copy (const EntityIndex sourceEntityIndex, const EntityIndex targetEntityIndex) final |
Copies the component located at entityIndex | |
| C & | get (const EntityIndex entityIndex) final |
Gets the component at entityIndex position. | |
| const C & | get (const EntityIndex entityIndex) const final |
Gets the component at entityIndex position. | |
Public Member Functions inherited from CeresEngine::AbstractComponentStore | |
| AbstractComponentStore (const size_t chunkSize, const size_t elementSize) | |
| virtual | ~AbstractComponentStore () noexcept |
| Defaulted virtual destructor. | |
| size_t | getSize () const noexcept |
| size_t | getCapacity () const noexcept |
| size_t | getChunkSize () const noexcept |
| size_t | getChunkCount () const noexcept |
Private Member Functions | |
| C * | getPointer (const EntityIndex index) noexcept |
Gets a pointer to the the component stored at index. | |
| const C * | getPointer (const EntityIndex index) const noexcept |
Gets a pointer to the the component stored at index. | |
Additional Inherited Members | |
Protected Member Functions inherited from CeresEngine::AbstractComponentStore | |
| void * | getRawPointer (const EntityIndex index) noexcept |
Gets a pointer to the the component stored at index. | |
| const void * | getRawPointer (const EntityIndex index) const noexcept |
Gets a pointer to the the component stored at index. | |
| void | ensureMinimumSize (std::size_t size) |
Ensures that the store size is at least size bytes. | |
| void | ensureMinimumCapacity (size_t minCapacity) |
Ensures that the store capacity is at least minCapacity bytes. | |
Protected Attributes inherited from CeresEngine::AbstractComponentStore | |
| size_t | mSize = 0 |
| The current store size (in bytes) | |
| size_t | mCapacity = 0 |
| The current store capacity (in bytes) | |
| size_t | mChunkSize |
| The size to be used for each memory chunk (in bytes) | |
| size_t | mElementSize |
| The amount of bytes allocated for each element in the store. | |
| Vector< char * > | mChunks |
| A vector of all allocated memory chunks. | |
A type-safe component store implementation.
This store uses a chunked memory pool to store the component data semi-contiguous in memory.
| C | the component type |
|
inlineexplicit |
Creates a new component store with the given chunkSize.
| chunkSize | The chunk size to be used |
|
finaldefaultnoexcept |
Destroys the component store.
Will destroy all components store in it.
|
inlinefinalvirtual |
Copies the component located at entityIndex
| sourceEntityIndex | The index of the component to copy from |
| targetEntityIndex | The index of the component to copy to |
Implements CeresEngine::AbstractComponentStore.
|
inlinefinalvirtual |
Creates a new component at entityIndex position.
create() on a already created index could lead to a memory leak! The previously constructed component destructor will not be called. The user must manually call `destroy()´ before calling create on the same index.| entityIndex | The component position |
Implements CeresEngine::AbstractComponentStore.
|
inlinenoexcept |
Creates a new component at entityIndex position.
create() on a already created index could lead to a memory leak! The previously constructed component destructor will not be caled. The user must manually call `destroy()´ before calling create on the same index.| Args | the component constructor argument types |
| entityIndex | The component position |
| args | The component constructor arguments |
|
inlinefinalvirtual |
Destroys the component located at entityIndex.
| entityIndex | The index of the component to be destroyed |
Implements CeresEngine::AbstractComponentStore.
|
inlinefinalvirtual |
Gets the component at entityIndex position.
get() on a not allocated/created position will cause a crash. The user must make sure that the component being retrieved has been previously created with a call to create().| entityIndex | The component position |
Implements CeresEngine::AbstractComponentStore.
|
inlinefinalvirtual |
Gets the component at entityIndex position.
get() on a not allocated/created position will cause a crash. The user must make sure that the component being retrieved has been previously created with a call to create().| entityIndex | The component position |
Implements CeresEngine::AbstractComponentStore.
|
inlineprivatenoexcept |
Gets a pointer to the the component stored at index.
| index | The component position |
index.
|
inlineprivatenoexcept |
Gets a pointer to the the component stored at index.
| index | The component position |
index.