Doxygen with github
|
A class that serves as the base for user-defined applications. More...
#include <ksApplication.h>
Public Member Functions | |
virtual | ~ksApplication () |
Destructor. | |
template<class TComponentType , class... TParams> | |
std::weak_ptr< TComponentType > | addComponent (TParams... arg) |
Instantiates a component of the type defined by the template instance. This function will pass all template-defined parameters to the component constructor. | |
template<class TComponentType > | |
void | findComponents (std::vector< std::weak_ptr< TComponentType > > &outComponents) |
Iterates through all components and returns a vector of weak pointers with components that matches the type passed as a template parameter. | |
template<class TComponentType > | |
std::weak_ptr< TComponentType > | findComponent () |
Iterates through all components and returns a weak pointer to the first component that matches the type passed as a template parameter. | |
virtual bool | init ()=0 |
Initializes application. | |
virtual bool | loop () |
Executes application logic loop. | |
Protected Attributes | |
std::list< std::shared_ptr< ksComponent > > | components |
An array with shared_ptr of components (holding main reference). | |
A class that serves as the base for user-defined applications.
ksApplication implements core application logic, handling the initialization and execution of components.
You must override the init method to build the component stack. Returning false will stop the initialization, and ksAppRotator will move to the next application.
Avoid overriding the loop method unless absolutely necessary. If you do, ensure you call the base loop method and return the result correctly. If any component returns false, the application logic should stop. It is best to add only small pieces of code and return the result of the base loop method, and it's safe to return false early, even before calling the base loop method.
When either init or loop returns false, the application will stop.
|
inline |
Instantiates a component of the type defined by the template instance. This function will pass all template-defined parameters to the component constructor.
TComponentType | A type of the component. |
TParams... | A list of parameters to be passed to the component constructor. |
arg... | A list of parameters to be passed to the component constructor. |
References components, and ksf::ksComponent::getInstanceType().
Referenced by ksf::comps::ksWifiConfigurator::init().
|
inline |
Iterates through all components and returns a weak pointer to the first component that matches the type passed as a template parameter.
TComponentType | A type of the component to look for. |
References components, and ksf::ksComponent::getInstanceType().
Referenced by ksf::comps::ksDevicePortal::postInit(), ksf::comps::ksDevStatMqttReporter::postInit(), and ksf::comps::ksMqttConnector::postInit().
|
inline |
Iterates through all components and returns a vector of weak pointers with components that matches the type passed as a template parameter.
TComponentType | A type of the component to look for. |
outComponents | A vector of weak pointers to components that match the type passed as a template parameter. |
References components, and ksf::ksComponent::getInstanceType().
Referenced by ksf::comps::ksDevicePortal::handle_getDeviceParams(), ksf::comps::ksDevicePortal::onWebsocketTextMessage(), and ksf::comps::ksWifiConfigurator::postInit().
|
pure virtual |
Initializes application.
|
virtual |
Executes application logic loop.
References components.