Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
ara::exec::StateServer Class Reference

A class to handle the state client requests at the EM side. More...

#include <state_server.h>

Public Member Functions

 StateServer (com::someip::rpc::RpcServer *rpcServer, std::set< std::pair< std::string, std::string > > &&functionGroupStates, std::map< std::string, std::string > &&initialStates)
 Constructor. More...
 
bool TryGetState (std::string functionGroup, std::string &state)
 Try to get the state of a function group. More...
 
void SetNotifier (std::string functionGroup, std::function< void()> callback)
 Set a notifier at the state changed of a function group. More...
 
bool Initialized () const noexcept
 Indicate whether or not EM has been initialized. More...
 

Detailed Description

A class to handle the state client requests at the EM side.

See also
StateClient
Note
The class is not part of the ARA standard.

Constructor & Destructor Documentation

◆ StateServer()

ara::exec::StateServer::StateServer ( com::someip::rpc::RpcServer rpcServer,
std::set< std::pair< std::string, std::string > > &&  functionGroupStates,
std::map< std::string, std::string > &&  initialStates 
)

Constructor.

Parameters
rpcServerRPC server abstraction layer
functionGroupStatesFunction groups and their possible states combination
initialStatesInitial states of the function groups
Exceptions
std::invalid_argumentThrows when an initial state refers to an invalid function group
std::logic_errorThrows when a function group lacks of the initial state

Member Function Documentation

◆ Initialized()

bool ara::exec::StateServer::Initialized ( ) const
noexcept

Indicate whether or not EM has been initialized.

Returns
True if EM is initialized; otherwise false
Remarks
The function call is atomic.

◆ SetNotifier()

void ara::exec::StateServer::SetNotifier ( std::string  functionGroup,
std::function< void()>  callback 
)

Set a notifier at the state changed of a function group.

Parameters
functionGroupFunction group of interest
callbackCallback to be invoked at the state change
Exceptions
std::out_of_rangeThrows when the function group does not exist

◆ TryGetState()

bool ara::exec::StateServer::TryGetState ( std::string  functionGroup,
std::string &  state 
)

Try to get the state of a function group.

Parameters
[in]functionGroupFunction group name
[out]stateFunction group state
Returns
True if the function group exits; otherwise false
Remarks
The function is thread-safe.