Doxygen with github
|
A class that is a base for user-defined application. More...
#include <ksApplication.h>
Public Member Functions | |
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 is a base for user-defined application.
ksApplication implements core application logic. It is responsible for initializing and running components.
You must override init method to build component stack. You can return false to stop the initialization. In this case, application will be stopped and ksAppRotator will move to the next application.
Do not override loop method until you have a good reason. If you do so, keep in mind that you should call base loop method and return the result properly. If any component returns false, application logic should be stopped. The best way is to add only small piece of code and return the reult of the base loop method. It is also safe to return false early, before calling base loop method.
When init or loop returns false, application will be stopped.
|
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().
|
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::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().
|
pure virtual |
Initializes application.
|
virtual |
Executes application logic loop.
References components.