Manages keyboard devices available in a System. More...
Public Member Functions | |
System * | getSystem () const |
KeyboardDevice * | createOrRetrieve (nkMemory::StringView name) |
KeyboardDevice * | record (nkMemory::StringView name, nkMemory::UniquePtr< KeyboardDevice > device) |
KeyboardDevice * | get (nkMemory::StringView name) const |
KeyboardDevice * | getByIndex (unsigned int index) const |
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName) |
void | erase (nkMemory::StringView name) |
nkMemory::UniquePtr< KeyboardDevice > | relinquish (nkMemory::StringView name) |
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.
System* nkInputs::KeyboardDeviceManager::getSystem | ( | ) | const |
KeyboardDevice* nkInputs::KeyboardDeviceManager::createOrRetrieve | ( | nkMemory::StringView | name | ) |
Creates if unavailable, or retrieves if available, a keybaord device.
name | The name of the device to retrieve. |
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.
name | The name to register the resource to. |
device | The device to register. |
KeyboardDevice* nkInputs::KeyboardDeviceManager::get | ( | nkMemory::StringView | name | ) | const |
Retrieves a keyboard device.
name | The name of the device to retrieve. |
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.
index | The index from which to retrieve a device. |
void nkInputs::KeyboardDeviceManager::rename | ( | nkMemory::StringView | currentName, |
nkMemory::StringView | newName | ||
) |
Renames a keyboard device.
currentName | The name of the device to rename. |
newName | The name to reassign to the device. |
void nkInputs::KeyboardDeviceManager::erase | ( | nkMemory::StringView | name | ) |
Erases and frees a keyboard device.
name | The name of the device to erase. |
nkMemory::UniquePtr<KeyboardDevice> nkInputs::KeyboardDeviceManager::relinquish | ( | nkMemory::StringView | name | ) |
Relinquishes a device's ownership, leaving its lifetime management to the caller.
name | The name of the device to return back. |