![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
Base class for all managers. More...
#include <C_baseManager.hpp>
Public Types | |
using | DataType = TData |
using | DataBlockType = TDataBlock |
using | DataBlockPointer = std::shared_ptr<TDataBlock> |
using | Map = std::unordered_map<std::string, DataBlockPointer, StringHash, std::equal_to<>> |
Public Member Functions | |
BaseManager (BaseManager const &r)=delete | |
BaseManager (BaseManager &&r) noexcept=delete | |
BaseManager & | operator= (BaseManager const &r)=delete |
BaseManager & | operator= (BaseManager &&r) noexcept=delete |
virtual bool | initialize ()=0 |
Initialize the manager. | |
virtual bool | isInitialized ()=0 |
virtual void | uninitialize ()=0 |
std::size_t | size () const |
Get the number of elements in the manager. | |
AccessLock< std::mutex > | acquireLock () const |
Acquire a AccessLock, with the manager mutex. | |
Map::const_iterator | begin (AccessLock< std::mutex > const &lock) const |
Get the "begin" iterator of the manager. | |
Map::const_iterator | end (AccessLock< std::mutex > const &lock) const |
Get the "end" iterator of the manager. | |
DataBlockPointer const & | getBadElement () const |
Get the "bad" element. | |
DataBlockPointer | getElement (std::string_view name) const |
Get the resource with the given name. | |
bool | contains (std::string_view name) const |
bool | unload (std::string_view name) |
void | unloadAll () |
bool | push (std::string_view name, DataBlockPointer block) |
Add a user handled resource. | |
Protected Attributes | |
DataBlockPointer | _g_badElement |
Base class for all managers.
A manager (or registry) is a class that manages a set of resources with a string key. This class is thread-safe.
|
nodiscard |
Acquire a AccessLock, with the manager mutex.
In order to use iterators, you have to acquire a unique lock from this function. The lock is not differed and will lock the mutex.
|
nodiscard |
Get the "begin" iterator of the manager.
You have to provide a valid reference to a AccessLock acquired with the function AcquireLock(). This function will throw if one of this is not respected :
lock | A AccessLock bound to this mutex |
|
nodiscard |
Get the "end" iterator of the manager.
lock | A AccessLock bound to this mutex |
|
nodiscard |
Get the "bad" element.
A bad element is a "valid" default resource that is returned when the requested resource is not found. return The "bad" element
|
nodiscard |
Get the resource with the given name.
name | The name of the resource to get |
|
pure virtual |
Initialize the manager.
The philosophy with this class is to always return a "valid" element even if the element is not found. When this method is called, a "bad" element is created and stored in the manager.
return true if the manager is initialized, false otherwise
Implemented in fge::anim::AnimationManager, fge::audio::AudioManager, fge::font::FontManager, fge::shader::ShaderManager, and fge::texture::TextureManager.
bool fge::manager::BaseManager< TData, TDataBlock >::push | ( | std::string_view | name, |
DataBlockPointer | block ) |
Add a user handled resource.
name | The name of the texture to add |
block | The block data to add |
|
nodiscard |
Get the number of elements in the manager.
return The number of elements in the manager without the "bad" element