stmm-input-doc  0.17.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
stmi::DeviceMgmtEvent Class Reference

Event informing about a device being added, removed or changed. More...

Inheritance diagram for stmi::DeviceMgmtEvent:
Inheritance graph
[legend]

Public Types

enum  DEVICE_MGMT_TYPE { DEVICE_MGMT_ADDED = 1, DEVICE_MGMT_REMOVED = 2, DEVICE_MGMT_CHANGED = 3 }
 The event type. More...
 
- Public Types inherited from stmi::Event
enum  AS_KEY_INPUT_TYPE { AS_KEY_PRESS = 1, AS_KEY_RELEASE = 2, AS_KEY_RELEASE_CANCEL = 3 }
 Key simulation type. More...
 

Public Member Functions

shared_ptr< DevicegetDevice () const noexcept
 The involved device. More...
 
 DeviceMgmtEvent (int64_t nTimeUsec, const shared_ptr< DeviceMgmtCapability > &refDeviceMgmtCapability, DEVICE_MGMT_TYPE eDeviceMgmtType, const shared_ptr< Device > &refDevice) noexcept
 Constructor. More...
 
DEVICE_MGMT_TYPE getDeviceMgmtType () const noexcept
 What happens to the involved device. More...
 
shared_ptr< DeviceMgmtCapabilitygetDeviceMgmtCapability () const noexcept
 Returns the capability that generated this event. More...
 
shared_ptr< CapabilitygetCapability () const noexcept override
 Returns the capability that generated this event. More...
 
- Public Member Functions inherited from stmi::Event
virtual ~Event () noexcept=default
 
int64_t getTimeUsec () const noexcept
 Returns the time this event originated. More...
 
int32_t getCapabilityId () const noexcept
 Returns the id of the capability that generated this event. More...
 
const shared_ptr< Accessor > & getAccessor () const noexcept
 Returns the accessor that helped generate this event. More...
 
virtual bool getAsKey (HARDWARE_KEY &eKey, AS_KEY_INPUT_TYPE &eType, bool &bMoreThanOne) const noexcept
 Tells whether the event can simulate hardware keys. More...
 
virtual std::vector< std::pair< HARDWARE_KEY, AS_KEY_INPUT_TYPE > > getAsKeys () const noexcept
 All the keys this event simulates. More...
 
const ClassgetEventClass () const noexcept
 Get the registered class of the event instance. More...
 

Static Public Member Functions

static const Event::ClassgetClass () noexcept
 
- Static Public Member Functions inherited from stmi::Event
static bool isEventClassIdRegistered (const std::string &sEventClassId) noexcept
 Tells whether the given event class id is registered. More...
 
static Class getEventClassIdClass (const std::string &sEventClassId) noexcept
 Gets the event class with given class id. More...
 

Static Public Attributes

static const char *const s_sClassId
 The class id of this event. More...
 

Protected Member Functions

void setDevice (const shared_ptr< Device > &refDevice) noexcept
 Sets the device. More...
 
void setDeviceMgmtType (DEVICE_MGMT_TYPE eDeviceMgmtType) noexcept
 Sets the type. More...
 
void setDeviceMgmtCapability (const shared_ptr< DeviceMgmtCapability > &refDeviceMgmtCapability) noexcept
 Sets the capability. More...
 
- Protected Member Functions inherited from stmi::Event
 Event (const Class &oClass, int64_t nTimeUsec, int32_t nCapabilityId, const shared_ptr< Accessor > &refAccessor) noexcept
 Constructor to be called from subclasses. More...
 
 Event (const Class &oClass, int64_t nTimeUsec, int32_t nCapabilityId) noexcept
 Constructor to be called from subclasses (with empty accessor). More...
 
void setTimeUsec (int64_t nTimeUsec) noexcept
 Set the event time. More...
 
void setCapabilityId (int32_t nCapabilityId) noexcept
 Set the capability id. More...
 
void setAccessor (const shared_ptr< Accessor > &refAccessor) noexcept
 Set the accessor. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from stmi::Event
static bool isEventTypeRegistered (const std::type_info &oEventType) noexcept
 Tells whether an event type was registered. More...
 
static const std::type_info & getEventClassIdType (const std::string &sEventClassId, bool &bRegistered) noexcept
 Gets the type of the registered event subclass associated with class id. More...
 
static std::string getEventTypeClassId (const std::type_info &oType) noexcept
 Gets the class id of the given type. More...
 

Detailed Description

Event informing about a device being added, removed or changed.

Member Enumeration Documentation

◆ DEVICE_MGMT_TYPE

The event type.

Enumerator
DEVICE_MGMT_ADDED 
DEVICE_MGMT_REMOVED 
DEVICE_MGMT_CHANGED 

The meaning is device specific.

Example: for a XInput master device it could mean a slave was added or removed.

Constructor & Destructor Documentation

◆ DeviceMgmtEvent()

stmi::DeviceMgmtEvent::DeviceMgmtEvent ( int64_t  nTimeUsec,
const shared_ptr< DeviceMgmtCapability > &  refDeviceMgmtCapability,
DEVICE_MGMT_TYPE  eDeviceMgmtType,
const shared_ptr< Device > &  refDevice 
)
noexcept

Constructor.

The device and the capability are stored by this instance as std::weak_ptr to avoid possible cyclic references.

Parameters
nTimeUsecThe time in microseconds from time epoch.
refDeviceMgmtCapabilityThe device manager's capability. Can't be null.
eDeviceMgmtTypeThe type.
refDeviceThe involved device. Can't be null.

Member Function Documentation

◆ getCapability()

shared_ptr<Capability> stmi::DeviceMgmtEvent::getCapability ( ) const
inlineoverridevirtualnoexcept

Returns the capability that generated this event.

The Event subclass implementation keeps only a weak_ptr on the capability to avoid reference cycles.

Returns
The capability or null if the capability was deleted.

Implements stmi::Event.

◆ getClass()

static const Event::Class& stmi::DeviceMgmtEvent::getClass ( )
inlinestaticnoexcept

◆ getDevice()

shared_ptr<Device> stmi::DeviceMgmtEvent::getDevice ( ) const
inlinenoexcept

The involved device.

If a device is removed (DEVICE_MGMT_REMOVED), it no longer is attached to its device manager, but its methods should still work and its capabilities be accessible, at least during the listener's callback.

Returns
The device or null if it was deleted.

◆ getDeviceMgmtCapability()

shared_ptr<DeviceMgmtCapability> stmi::DeviceMgmtEvent::getDeviceMgmtCapability ( ) const
inlinenoexcept

Returns the capability that generated this event.

Returns
If null the capability (and probably the device manager) was deleted.

◆ getDeviceMgmtType()

DEVICE_MGMT_TYPE stmi::DeviceMgmtEvent::getDeviceMgmtType ( ) const
inlinenoexcept

What happens to the involved device.

Returns
The type.

◆ setDevice()

void stmi::DeviceMgmtEvent::setDevice ( const shared_ptr< Device > &  refDevice)
inlineprotectednoexcept

Sets the device.

Parameters
refDeviceThe involved device. Can't be null.

◆ setDeviceMgmtCapability()

void stmi::DeviceMgmtEvent::setDeviceMgmtCapability ( const shared_ptr< DeviceMgmtCapability > &  refDeviceMgmtCapability)
inlineprotectednoexcept

Sets the capability.

Parameters
refDeviceMgmtCapabilityThe device manager's capability. Can't be null.

◆ setDeviceMgmtType()

void stmi::DeviceMgmtEvent::setDeviceMgmtType ( DEVICE_MGMT_TYPE  eDeviceMgmtType)
inlineprotectednoexcept

Sets the type.

Parameters
eDeviceMgmtTypeThe type.

Member Data Documentation

◆ s_sClassId

const char* const stmi::DeviceMgmtEvent::s_sClassId
static

The class id of this event.