Doxygen with github
Loading...
Searching...
No Matches
ksf::ksRtti Class Referenceabstract

Implements RTTI (run-time type information) for objects. More...

#include <ksRtti.h>

+ Inheritance diagram for ksf::ksRtti:

Public Member Functions

virtual const size_t getInstanceType () const =0
 Retrieves type ID of the object.
 
virtual bool isA (const size_t id) const
 Checks whether object is of given type.
 
template<typename TType >
TType * as ()
 Tries to cast object to the type provided as a template parameter.
 
template<typename TType >
const TType * as () const
 Tries to cast object to the type provided as a template parameter (const version).
 

Detailed Description

Implements RTTI (run-time type information) for objects.

This is a simple, but fast and lightweight implementation of RTTI feature. Provides the ability to check whether object is of given type and cast it to the type provided as a template parameter.

Extensively used to implement components - ksComponent and easily manage components in the application (ksApplication).

Member Function Documentation

◆ as() [1/2]

template<typename TType >
TType * ksf::ksRtti::as ( )
inline

Tries to cast object to the type provided as a template parameter.

Template Parameters
TTypeTarget type.
Returns
Pointer to object of given type or nullptr if object is not of given type.

◆ as() [2/2]

template<typename TType >
const TType * ksf::ksRtti::as ( ) const
inline

Tries to cast object to the type provided as a template parameter (const version).

Template Parameters
TTypeTarget type.
Returns
Const pointer to object of given type or nullptr if object is not of given type.

◆ getInstanceType()

◆ isA()

virtual bool ksf::ksRtti::isA ( const size_t id) const
inlinevirtual

Checks whether object is of given type.

Parameters
idType ID to check against.
Returns
True if object is of given type, otherwise false.

Reimplemented in ksf::comps::ksConfigProvider, ksf::comps::ksDevicePortal, ksf::comps::ksDevStatMqttReporter, ksf::comps::ksLed, ksf::comps::ksMqttConfigProvider, ksf::comps::ksMqttConnector, ksf::comps::ksResetButton, ksf::comps::ksWifiConfigurator, ksf::comps::ksWifiConnector, and ksf::ksComponent.


The documentation for this class was generated from the following file: