Manages the mouse devices available in the component. More...
Public Member Functions | |
System * | getSystem () const |
MouseDevice * | createOrRetrieve (nkMemory::StringView name) |
MouseDevice * | record (nkMemory::StringView name, nkMemory::UniquePtr< MouseDevice > device) |
MouseDevice * | get (nkMemory::StringView name) const |
MouseDevice * | getByIndex (unsigned int index) const |
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName) |
void | erase (nkMemory::StringView name) |
nkMemory::UniquePtr< MouseDevice > | relinquish (nkMemory::StringView name) |
Manages the mouse devices available in the component.
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::MouseDeviceManager::getSystem | ( | ) | const |
MouseDevice* nkInputs::MouseDeviceManager::createOrRetrieve | ( | nkMemory::StringView | name | ) |
Creates if unavailable, or retrieves if available, a mouse device.
name | The name of the device to retrieve. |
MouseDevice* nkInputs::MouseDeviceManager::record | ( | nkMemory::StringView | name, |
nkMemory::UniquePtr< MouseDevice > | 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. |
MouseDevice* nkInputs::MouseDeviceManager::get | ( | nkMemory::StringView | name | ) | const |
Retrieves a mouse device.
name | The name of the device to retrieve. |
MouseDevice* nkInputs::MouseDeviceManager::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::MouseDeviceManager::rename | ( | nkMemory::StringView | currentName, |
nkMemory::StringView | newName | ||
) |
Renames a mouse device.
currentName | The name of the device to rename. |
newName | The name to reassign to the device. |
void nkInputs::MouseDeviceManager::erase | ( | nkMemory::StringView | name | ) |
Erases and frees a mouse device.
name | The name of the device to erase. |
nkMemory::UniquePtr<MouseDevice> nkInputs::MouseDeviceManager::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. |