|
stmm-games-doc
0.32.0
|
This class manages devices that generate events that listeners will receive. More...

Public Member Functions | |
| virtual | ~DeviceManager () noexcept=default |
| virtual shared_ptr< Device > | getDevice (int32_t nDeviceId) const noexcept=0 |
| Returns the device with the given id, or null if not found. More... | |
| virtual std::vector< Capability::Class > | getCapabilityClasses () const noexcept=0 |
| The registered capability classes of the device manager. More... | |
| virtual std::vector< Capability::Class > | getDeviceCapabilityClasses () const noexcept=0 |
| The registered capability classes of the device manager's devices. More... | |
| template<typename TCapa > | |
| bool | getCapability (shared_ptr< TCapa > &refCapa) const noexcept |
| Request a registered device manager capability. More... | |
| virtual shared_ptr< Capability > | getCapability (const Capability::Class &oClass) const noexcept=0 |
| Requests the instance of a capability class. More... | |
| virtual shared_ptr< Capability > | getCapability (int32_t nCapabilityId) const noexcept=0 |
| Returns the device manager's capability with the given id, or null if not found. More... | |
| virtual std::vector< Event::Class > | getEventClasses () const noexcept=0 |
| The registered event classes the device manager and all its devices can send. More... | |
| virtual std::vector< int32_t > | getDevicesWithCapabilityClass (const Capability::Class &oCapabilityClass) const noexcept=0 |
| Returns the ids of the devices that have the given capability class. More... | |
| virtual std::vector< int32_t > | getDevices () const noexcept=0 |
| Returns the ids of all the device manager's devices. More... | |
| virtual bool | isEventClassEnabled (const Event::Class &oEventClass) const noexcept=0 |
| Tells whether an event class is enabled. More... | |
| virtual void | enableEventClass (const Event::Class &oEventClass) noexcept=0 |
| Enables an event class. More... | |
| virtual bool | addAccessor (const shared_ptr< Accessor > &refAccessor) noexcept=0 |
| Adds an accessor to the device manager. More... | |
| virtual bool | removeAccessor (const shared_ptr< Accessor > &refAccessor) noexcept=0 |
| Removes an accessor from the device manager. More... | |
| virtual bool | hasAccessor (const shared_ptr< Accessor > &refAccessor) noexcept=0 |
| Tells whether the device manager has a given accessor. More... | |
| virtual bool | addEventListener (const shared_ptr< EventListener > &refEventListener, const shared_ptr< CallIf > &refCallIf) noexcept=0 |
| Adds an event listener with its callif condition to the device manager. More... | |
| virtual bool | addEventListener (const shared_ptr< EventListener > &refEventListener) noexcept=0 |
| Adds an event listener to the device manager. More... | |
| virtual bool | removeEventListener (const shared_ptr< EventListener > &refEventListener, bool bFinalize) noexcept=0 |
| Removes an event listener from the device manager. More... | |
| virtual bool | removeEventListener (const shared_ptr< EventListener > &refEventListener) noexcept=0 |
| Removes an event listener from the device manager. More... | |
Static Public Member Functions | |
| static int64_t | getNowTimeMicroseconds () noexcept |
| Current time from epoch in microseconds. More... | |
Protected Member Functions | |
| DeviceManager () noexcept | |
This class manages devices that generate events that listeners will receive.
|
virtualdefaultnoexcept |
|
protectednoexcept |
|
pure virtualnoexcept |
Adds an accessor to the device manager.
If the device manager recognizes the accessor and the accessor wasn't already added true is returned, false otherwise.
It's possible to add a null accessor, it's meaning is implementation dependent.
| refAccessor | The accessor to add. Can be null. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Adds an event listener with its callif condition to the device manager.
The EventListener callback function (actually its address) identifies the listener being added and is therefore used to remove it with removeEventListener(). The callback function is called for all events originating from this device manager's devices that satisfy the callif condition.
If the listener was already added, even with a different callif, the function has no effect and false is returned.
The device manager keeps a weak reference (std::weak_ptr) to the listener. This means that the caller has to keep a strong reference to the listener, otherwise it will be removed automatically.
A null callback condition refCallIf means that the callback function is called for all events. The device manager keeps a strong reference to the callif object as long as the listener remains in the device manager.
The event parameter passed to the callback function can be queued (outlive the callback) or modified if its interface allows it. To get the registered class of the event use Event::getEventClass() and statically cast to it. Note: don't use typeid(*refEvent) since it isn't necessarily equal to refEvent->getEventClass().getTypeInfo().
Example:
void createListeners()
...
// The listener has to be stored in a member variable otherwise it will
// automatically be removed from the device manager.
m_refKeyEventListener = std::make_shared<stmi::EventListener>(
[this](const shared_ptr<stmi::Event>& refEvent)
{
// Because of the callif condition below we know that refEvent
// is a stmi::KeyEvent
auto pKeyEvent = static_cast<stmi::KeyEvent*>(refEvent.get());
...
});
m_refDeviceManager->addEventListener(m_refKeyEventListener
, std::make_shared<stmi::CallIfEventClass>(typeid(stmi::KeyEvent)));
...
}
| refEventListener | The listener to be added. Cannot be null. |
| refCallIf | The callif condition to call back the listener. Can be null. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Adds an event listener to the device manager.
Shortcut of addEventListener(refEventListener, shared_ptr<CallIf>{}).
| refEventListener | The listener to be added. Cannot be null. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Enables an event class.
| oEventClass | The event class to enable. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
inlinenoexcept |
Request a registered device manager capability.
| refCapa | [out] The registered DeviceManagerCapability subclass or null if not supported by device manager. |
|
pure virtualnoexcept |
Requests the instance of a capability class.
If the device manager doesn't have the capability null is returned.
| oClass | The requested registered device manager capability class. |
Implemented in stmi::ParentDeviceManager, and stmi::StdDeviceManager.
|
pure virtualnoexcept |
Returns the device manager's capability with the given id, or null if not found.
Implemented in stmi::ParentDeviceManager, and stmi::StdDeviceManager.
|
pure virtualnoexcept |
The registered capability classes of the device manager.
Example: the vector {DeviceMgmtCapability::getClass()} is returned.
Implemented in stmi::ParentDeviceManager, stmi::BasicDeviceManager, and stmi::StdDeviceManager.
|
pure virtualnoexcept |
Returns the device with the given id, or null if not found.
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
The registered capability classes of the device manager's devices.
The capability classes include those that managed devices potentially have, independently from the currently available devices.
Example: a device manager that handles mice and touch pads will return {PointerCapability::getClass(), TouchCapability::getClass()} even though no touch device is connected.
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Returns the ids of all the device manager's devices.
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Returns the ids of the devices that have the given capability class.
| oCapabilityClass | The registered capability class. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
The registered event classes the device manager and all its devices can send.
The event classes include those that managed devices potentially can send, independently from the currently available devices.
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
inlinestaticnoexcept |
Current time from epoch in microseconds.
Helper function used to set timestamp of events.
|
pure virtualnoexcept |
Tells whether the device manager has a given accessor.
Note that the implementation might return whether the thing (usually a window) wrapped by an accessor was already added to the device manager rather than the accessor instance itself. In general if this function returns true, calling addAccessor with the same accessor should return false.
| refAccessor | The accessor. Can be null. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Tells whether an event class is enabled.
If an event class is disabled the device manager (with all its devices) won't send events of that class to listeners.
| oEventClass | The registered event class. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Removes an accessor from the device manager.
If the accessor wasn't previously (successfully) added with addAccessor(const shared_ptr<Accessor>&), false is returned.
| refAccessor | The accessor to remove. Can be null. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Removes an event listener from the device manager.
If the listener wasn't found, false is returned, true otherwise. To be found the event listener must have been added with addEventListener() and not deleted since then. Beware! A copy of the event listener can't be used to remove it.
Optionally finalization events are sent to the listener before its removal. Example: if a device's key is pressed when this function is called, a RELEASE_CANCEL event is sent to the listener being removed.
| refEventListener | The listener to remove. Cannot be null. |
| bFinalize | Whether to send closing events to the listener. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
|
pure virtualnoexcept |
Removes an event listener from the device manager.
Shortcut of removeEventListener(refEventListener, false).
| refEventListener | The listener to remove. Cannot be null. |
Implemented in stmi::ParentDeviceManager, and stmi::BasicDeviceManager.
1.8.13