stmm-games-doc  0.32.0
Public Member Functions | Protected Member Functions | List of all members
stmi::BasicDevice< ODM > Class Template Reference

Device class template. More...

Inheritance diagram for stmi::BasicDevice< ODM >:
Inheritance graph
[legend]

Public Member Functions

std::string getName () const noexcept override
 
shared_ptr< DeviceManagergetDeviceManager () const noexcept override
 The device manager that manages the device. More...
 
shared_ptr< ODM > getOwnerDeviceManager () const noexcept
 
- Public Member Functions inherited from stmi::Device
virtual ~Device () noexcept=default
 
int32_t getId () const noexcept
 The device id. More...
 
template<typename TCapa >
bool getCapability (shared_ptr< TCapa > &refCapa) const noexcept
 Request a registered capability from this device. More...
 
virtual shared_ptr< CapabilitygetCapability (const Capability::Class &oClass) const noexcept=0
 Requests the instance of a capability class. More...
 
virtual shared_ptr< CapabilitygetCapability (int32_t nCapabilityId) const noexcept=0
 Returns the capability with the given id, or null if not found. More...
 
virtual std::vector< int32_t > getCapabilities () const noexcept=0
 Returns the ids of all the device's capabilities. More...
 
virtual std::vector< Capability::ClassgetCapabilityClasses () const noexcept=0
 The capability classes supported by this device. More...
 

Protected Member Functions

 BasicDevice (std::string sName, const shared_ptr< ODM > &refOwnerDeviceManager) noexcept
 Device template constructor. More...
 
void resetOwnerDeviceManager () noexcept
 Resets the link to the owner device manager. More...
 
- Protected Member Functions inherited from stmi::Device
 Device () noexcept
 

Detailed Description

template<class ODM>
class stmi::BasicDevice< ODM >

Device class template.

Helper class that Device classes can subclass. It stores name and owner device manager. ODM = Owner DeviceManager, must be subclass of ChildDeviceManager.

Constructor & Destructor Documentation

◆ BasicDevice()

template<class ODM >
stmi::BasicDevice< ODM >::BasicDevice ( std::string  sName,
const shared_ptr< ODM > &  refOwnerDeviceManager 
)
inlineprotectednoexcept

Device template constructor.

The instances of this class keep a weak reference to their owner ChildDeviceManager to avoid memory leaks.

Parameters
sNameThe name of the device. Cannot be empty.
refOwnerDeviceManagerThe ChildDeviceManager subclass. Cannot be null.

Member Function Documentation

◆ getDeviceManager()

template<class ODM >
shared_ptr< DeviceManager > stmi::BasicDevice< ODM >::getDeviceManager ( ) const
overridevirtualnoexcept

The device manager that manages the device.

As a convention Device instances should hold a weak_ptr to their manager to avoid reference cycles.

Returns
The device manager or null if the device is no longer attached to its manager.

Implements stmi::Device.

◆ getName()

template<class ODM >
std::string stmi::BasicDevice< ODM >::getName ( ) const
inlineoverridevirtualnoexcept
Returns
Name of the device. Not necessarily unique among devices.

Implements stmi::Device.

◆ getOwnerDeviceManager()

template<class ODM >
shared_ptr<ODM> stmi::BasicDevice< ODM >::getOwnerDeviceManager ( ) const
inlinenoexcept

◆ resetOwnerDeviceManager()

template<class ODM >
void stmi::BasicDevice< ODM >::resetOwnerDeviceManager ( )
inlineprotectednoexcept

Resets the link to the owner device manager.

When a device is removed from a device manager this function should be called.