API Documentation
Public Member Functions | List of all members
nkAstraeus::EffectManager Class Referencefinal

Manages the effects available in the component. More...

Inheritance diagram for nkAstraeus::EffectManager:

Public Member Functions

EffectcreateOrRetrieve (nkMemory::StringView name, EFFECT_TYPE type)
 
Effectrecord (nkMemory::StringView name, nkMemory::UniquePtr< Effect > resource)
 
Effectget (nkMemory::StringView name)
 
EffectgetByIndex (unsigned int id)
 
void rename (nkMemory::StringView currentName, nkMemory::StringView newName)
 
void erase (nkMemory::StringView name)
 
nkMemory::UniquePtr< Effectrelinquish (nkMemory::StringView name)
 

Detailed Description

Manages the effects available in the component.

At all times, manager owns any memory allocated inside. External code should never delete memory returned by it.

Member Function Documentation

◆ createOrRetrieve()

Effect* nkAstraeus::EffectManager::createOrRetrieve ( nkMemory::StringView  name,
EFFECT_TYPE  type 
)

Creates if unavailable, or retrieves if available, an effect.

Depending on the parameter given for the type, the Effect instance retrieved will be :

ValuePointer type
EFFECT_TYPE::ATMOSPHEREAtmosphereEffect
EFFECT_TYPE::FILM_GRAINFilmGrainEffect
EFFECT_TYPE::FXAAFxaaEffect
EFFECT_TYPE::IMAGE_ENVIRONMENTImageEnvironmentEffect
EFFECT_TYPE::SSAOSsaoEffect
EFFECT_TYPE::TEXTURE_COPYTextureCopyEffect
EFFECT_TYPE::TONE_MAPPINGToneMappingEffect

To address it fully, casting is required. For instance :

FxaaEffect* effect = (FxaaEffect*)EffectManager::getInstance()->createOrRetrieve("effect", EFFECT_TYPE::FXAA) ;
Parameters
nameThe name of the effect to retrieve.
typeThe effect type to create.
Returns
The effect requested, possibly freshly created. The manager owns the memory returned, external code should never delete it. See erase().

◆ record()

Effect* nkAstraeus::EffectManager::record ( nkMemory::StringView  name,
nkMemory::UniquePtr< Effect resource 
)

Records an already existing resource in the manager, passing its ownership around.

Parameters
nameThe name under which the resource should be recorded.
resourceThe resource to record.
Returns
A raw pointer over the resource, now recorded in the manager.

◆ get()

Effect* nkAstraeus::EffectManager::get ( nkMemory::StringView  name)

Retrieves an effect.

Parameters
nameThe name of the effect to retrieve.
Returns
The effect if available, nullptr else.

◆ getByIndex()

Effect* nkAstraeus::EffectManager::getByIndex ( unsigned int  id)

Get an effect, by index. Note that one index can map to a different effect after memory is changed. Useful to loop over all available effects in one go.

Parameters
idThe index of the effect to retrieve.
Returns
The effect linked if available, nullptr else.

◆ rename()

void nkAstraeus::EffectManager::rename ( nkMemory::StringView  currentName,
nkMemory::StringView  newName 
)

Renames an effect.

Parameters
currentNameThe name of the effect to rename.
newNameThe name to reassign to the effect.

◆ erase()

void nkAstraeus::EffectManager::erase ( nkMemory::StringView  name)

Erases and frees an effect.

Parameters
nameThe name of the effect to erase.

◆ relinquish()

nkMemory::UniquePtr<Effect> nkAstraeus::EffectManager::relinquish ( nkMemory::StringView  name)

Requests the manager to relinquish the ownership of a resource and pass it around.

Parameters
nameThe name of the recorded resource to relinquish.
Returns
The ownership over the resource requested if available, nullptr otherwise.

The documentation for this class was generated from the following file: