Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
auterion::Subscription< S, DataType > Class Template Reference

A template class for managing subscriptions to data coming from the vehicle. More...

#include <auterion_sdk/system_state/system_state.hpp>

Public Member Functions

 Subscription (const std::shared_ptr< SubscriptionImpl< S, DataType >> &impl)
 
void onUpdate (std::function< void(DataType)> callback)
 Regsiters a callback function to be called when the data is updated. More...
 
void subscribe (std::function< void(DataType)> callback)
 Activates the subscription process and registers a callback function if provided. More...
 
DataType last () const
 Retrieves the last received data. More...
 
bool isLastValid () const
 Checks if the last received data is valid. More...
 

Detailed Description

template<SubscriptionType S, typename DataType>
class auterion::Subscription< S, DataType >

A template class for managing subscriptions to data coming from the vehicle.

Template Parameters
SThe type of subscription as the enum value of SubscriptionType.
DataTypeThe type of data being subscribed to.
See also
SystemState for usage example

Member Function Documentation

◆ isLastValid()

template<SubscriptionType S, typename DataType >
bool auterion::Subscription< S, DataType >::isLastValid ( ) const

Checks if the last received data is valid.

Returns
True if the last received data is valid, false otherwise.

◆ last()

template<SubscriptionType S, typename DataType >
DataType auterion::Subscription< S, DataType >::last ( ) const

Retrieves the last received data.

Returns
The last received data.

◆ onUpdate()

template<SubscriptionType S, typename DataType >
void auterion::Subscription< S, DataType >::onUpdate ( std::function< void(DataType)>  callback)

Regsiters a callback function to be called when the data is updated.

This method does not start the subscription process itself.

Parameters
callbackCallback function to handle data updates.
Exceptions
auterion::InvalidArgumentExceptionif the callback function is nullptr.

◆ subscribe()

template<SubscriptionType S, typename DataType >
void auterion::Subscription< S, DataType >::subscribe ( std::function< void(DataType)>  callback)

Activates the subscription process and registers a callback function if provided.

If a callback function is provided, it registers it for data updates. If the callback is nullptr, only activates the subscription process.

Parameters
callbackCallback function to handle data updates.

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