API Documentation
Public Member Functions | List of all members
nkWinUi::ComponentManager Class Referencefinal

Manages the components within nkWinUi. More...

Inheritance diagram for nkWinUi::ComponentManager:

Public Member Functions

SystemgetSystem () const
 
ComponentcreateOrRetrieve (nkMemory::StringView name, COMPONENT_TYPE componentType)
 
Componentrecord (nkMemory::StringView name, nkMemory::UniquePtr< Component > resource)
 
Componentget (nkMemory::StringView name) const
 
ComponentgetByIndex (unsigned int index) const
 
void rename (nkMemory::StringView currentName, nkMemory::StringView newName)
 
void erase (nkMemory::StringView name)
 
nkMemory::UniquePtr< Componentrelinquish (nkMemory::StringView name)
 

Detailed Description

Manages the components within nkWinUi.

Responsible for creating and book-keeping them. At all time, the manager is responsible for the memory allocated inside it.

Member Function Documentation

◆ getSystem()

System* nkWinUi::ComponentManager::getSystem ( ) const
Returns
The system the manager is living in.

◆ createOrRetrieve()

Component* nkWinUi::ComponentManager::createOrRetrieve ( nkMemory::StringView  name,
COMPONENT_TYPE  componentType 
)

Creates (if unavailable) or retrieves (if available) component attached to passed name.

Parameters
nameThe name, aka identifier, of the component to create or retrieve.
componentTypeThe type the component should be.
Returns
The component attached to passed name, of type requested. The Manager is the owner of the memory returned.
Remarks
It is possible to cast the component to the type requested if required.

◆ record()

Component* nkWinUi::ComponentManager::record ( nkMemory::StringView  name,
nkMemory::UniquePtr< Component 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()

Component* nkWinUi::ComponentManager::get ( nkMemory::StringView  name) const

Returns a component attached to a name, if available.

Parameters
nameThe name of the component that should be retrieved.
Returns
The component if existing, nullptr else.

◆ getByIndex()

Component* nkWinUi::ComponentManager::getByIndex ( unsigned int  index) const

Returns the component at given index, if available.

Parameters
indexThe index of the component to retrieve.
Returns
The component attached to given index.
Remarks
An index refers to the index in the manager's container, so one index can be attached through different components depending on allocations. This method is meant to loop on all components in one go, because of this.

◆ rename()

void nkWinUi::ComponentManager::rename ( nkMemory::StringView  currentName,
nkMemory::StringView  newName 
)

Renames a component.

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

◆ erase()

void nkWinUi::ComponentManager::erase ( nkMemory::StringView  name)

Erases a component. Memory attached to it will be freed.

Parameters
nameThe name identifying the component to erase.

◆ relinquish()

nkMemory::UniquePtr<Component> nkWinUi::ComponentManager::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: