API Documentation
Public Member Functions | List of all members
nkInputs::KeyboardDeviceManager Class Referencefinal

Manages keyboard devices available in a System. More...

Inheritance diagram for nkInputs::KeyboardDeviceManager:

Public Member Functions

SystemgetSystem () const
 
KeyboardDevicecreateOrRetrieve (nkMemory::StringView name)
 
KeyboardDevicerecord (nkMemory::StringView name, nkMemory::UniquePtr< KeyboardDevice > device)
 
KeyboardDeviceget (nkMemory::StringView name) const
 
KeyboardDevicegetByIndex (unsigned int index) const
 
void rename (nkMemory::StringView currentName, nkMemory::StringView newName)
 
void erase (nkMemory::StringView name)
 
nkMemory::UniquePtr< KeyboardDevicerelinquish (nkMemory::StringView name)
 

Detailed Description

Manages keyboard devices available in a System.

At all times, managers own any memory allocated inside, through the creation methods, or ownership given to them. External code should never delete memory returned by it, unless the ownership is passed back through the dedicated method.

Member Function Documentation

◆ getSystem()

System* nkInputs::KeyboardDeviceManager::getSystem ( ) const
Returns
The System in which the manager works.

◆ createOrRetrieve()

KeyboardDevice* nkInputs::KeyboardDeviceManager::createOrRetrieve ( nkMemory::StringView  name)

Creates if unavailable, or retrieves if available, a keybaord device.

Parameters
nameThe name of the device to retrieve.
Returns
The device requested, possibly freshly created. The manager owns the memory returned, external code should never delete it. See erase().

◆ record()

KeyboardDevice* nkInputs::KeyboardDeviceManager::record ( nkMemory::StringView  name,
nkMemory::UniquePtr< KeyboardDevice device 
)

Records an already existing resource, passing its ownership to the manager. This method can be used after manually creating a resource, as needed, as long as the resource provided is part of the same System.

Parameters
nameThe name to register the resource to.
deviceThe device to register.
Returns
The raw pointer over the registered device.
Remarks
The device provided needs to be living inside the same System as the Manager does. Doing so will fail the recording, log a warning and erase the device right away, as the ownership is passed during calling.

◆ get()

KeyboardDevice* nkInputs::KeyboardDeviceManager::get ( nkMemory::StringView  name) const

Retrieves a keyboard device.

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

◆ getByIndex()

KeyboardDevice* nkInputs::KeyboardDeviceManager::getByIndex ( unsigned int  index) const

Retrieves a device by index. Keep in mind that as devices are added / erased, the same index can return a different device. This function is useful when retrieving all existing devices in one go.

Parameters
indexThe index from which to retrieve a device.
Returns
The device currently attached to the index if available, nullptr else.

◆ rename()

void nkInputs::KeyboardDeviceManager::rename ( nkMemory::StringView  currentName,
nkMemory::StringView  newName 
)

Renames a keyboard device.

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

◆ erase()

void nkInputs::KeyboardDeviceManager::erase ( nkMemory::StringView  name)

Erases and frees a keyboard device.

Parameters
nameThe name of the device to erase.

◆ relinquish()

nkMemory::UniquePtr<KeyboardDevice> nkInputs::KeyboardDeviceManager::relinquish ( nkMemory::StringView  name)

Relinquishes a device's ownership, leaving its lifetime management to the caller.

Parameters
nameThe name of the device to return back.
Returns
The device requested.

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