stmm-games-doc  0.32.0
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
stmi::Capability Class Referenceabstract

Base capability class. More...

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

Classes

class  Class
 The representation of a registered capability class. More...
 
class  RegisterClass
 Template used to register capability classes. More...
 

Public Member Functions

virtual ~Capability () noexcept=default
 
int32_t getId () const noexcept
 The capability id. More...
 
virtual shared_ptr< DevicegetDevice () const noexcept=0
 Returns the device owning this capability, if any. More...
 
const ClassgetCapabilityClass () const noexcept
 Get the registered class of the capability instance. More...
 

Static Public Member Functions

static bool isCapabilityClassIdRegistered (const std::string &sCapabilityClassId) noexcept
 Tells whether the given capability class id is registered. More...
 
static Class getCapabilityClassIdClass (const std::string &sCapabilityClassId) noexcept
 Gets the class with given class id. More...
 

Protected Member Functions

 Capability (const Class &oClass) noexcept
 Constructor to be called from subclasses. More...
 

Static Protected Member Functions

static bool isCapabilityTypeRegistered (const std::type_info &oCapabilityType) noexcept
 Tells whether a capability type was registered. More...
 
static const std::type_info & getCapabilityClassIdType (const std::string &sCapabilityClassId, bool &bRegistered) noexcept
 Gets the type of the registered capability subclass associated with class id. More...
 
static std::string getCapabilityTypeClassId (const std::type_info &oType) noexcept
 Gets the class id of the given type. More...
 

Detailed Description

Base capability class.

Constructor & Destructor Documentation

◆ ~Capability()

virtual stmi::Capability::~Capability ( )
virtualdefaultnoexcept

◆ Capability()

stmi::Capability::Capability ( const Class oClass)
explicitprotectednoexcept

Constructor to be called from subclasses.

The registered type has to be the actual class of the instance being constructed or a superclass of it.

Parameters
oClassThe registered class of the capability. Cannot be empty.

Member Function Documentation

◆ getCapabilityClass()

const Class& stmi::Capability::getCapabilityClass ( ) const
inlinenoexcept

Get the registered class of the capability instance.

Returns
The registered class. Cannot be empty.

◆ getCapabilityClassIdClass()

static Class stmi::Capability::getCapabilityClassIdClass ( const std::string &  sCapabilityClassId)
staticnoexcept

Gets the class with given class id.

Parameters
sCapabilityClassIdThe registered class id.
Returns
The class. Might be empty if sCapabilityClassId is not registered.

◆ getCapabilityClassIdType()

static const std::type_info& stmi::Capability::getCapabilityClassIdType ( const std::string &  sCapabilityClassId,
bool &  bRegistered 
)
staticprotectednoexcept

Gets the type of the registered capability subclass associated with class id.

Parameters
sCapabilityClassIdThe type string.
bRegisteredWhether the return value is valid.
Returns
The registered type. If bRegistered is false the result is undefined.

◆ getCapabilityTypeClassId()

static std::string stmi::Capability::getCapabilityTypeClassId ( const std::type_info &  oType)
staticprotectednoexcept

Gets the class id of the given type.

Parameters
oTypeThe type to be tested.
Returns
The class id or an empty string if the type is not registered.

◆ getDevice()

virtual shared_ptr<Device> stmi::Capability::getDevice ( ) const
pure virtualnoexcept

Returns the device owning this capability, if any.

If it's a device manager capability this might return null. It also can be null if the device was deleted.

Implemented in stmi::DeviceManagerCapability, stmi::testing::FakeJoystickCapability, stmi::testing::FakeKeyCapability, stmi::testing::FakePointerCapability, and stmi::testing::FakeTouchCapability.

◆ getId()

int32_t stmi::Capability::getId ( ) const
inlinenoexcept

The capability id.

Returns
The unique id of the capability.

◆ isCapabilityClassIdRegistered()

static bool stmi::Capability::isCapabilityClassIdRegistered ( const std::string &  sCapabilityClassId)
staticnoexcept

Tells whether the given capability class id is registered.

Parameters
sCapabilityClassIdThe class id.
Returns
Whether registered.

◆ isCapabilityTypeRegistered()

static bool stmi::Capability::isCapabilityTypeRegistered ( const std::type_info &  oCapabilityType)
staticprotectednoexcept

Tells whether a capability type was registered.

Parameters
oCapabilityTypeThe c++ typeid of a class.
Returns
Whether the class was registered.