Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
someip_sd_agent.h
1#ifndef SOMEIP_SD_AGENT_H
2#define SOMEIP_SD_AGENT_H
3
4#include <future>
5#include "../../helper/finite_state_machine.h"
6#include "../../helper/network_layer.h"
7#include "./someip_sd_message.h"
8
9namespace ara
10{
11 namespace com
12 {
13 namespace someip
14 {
15 namespace sd
16 {
19 template <typename T>
21 {
22 protected:
25
27 std::future<void> Future;
28
31
34 virtual void StartAgent(T state) = 0;
35
38 virtual void StopAgent() = 0;
39
40 public:
45 {
46 }
47
49 void Start()
50 {
51 // Valid future means the timer is not expired yet.
52 if (Future.valid())
53 {
54 throw std::logic_error(
55 "The state has been already activated.");
56 }
57 else
58 {
59 T _state = GetState();
60 StartAgent(_state);
61 }
62 }
63
66 T GetState() const noexcept
67 {
68 return StateMachine.GetState();
69 }
70
72 void Join()
73 {
74 // If the future is valid, block unitl its result becomes avialable after the timer expiration.
75 if (Future.valid())
76 {
77 Future.get();
78 }
79 }
80
83 void Stop()
84 {
85 StopAgent();
86 }
87
88 virtual ~SomeIpSdAgent() noexcept = default;
89 };
90 }
91 }
92 }
93}
94
95#endif
Finite State Machine (FMS) controller.
Definition: finite_state_machine.h:20
SOME/IP service discovery agent (i.e., a server or a client)
Definition: someip_sd_agent.h:21
void Join()
Join to the timer's thread.
Definition: someip_sd_agent.h:72
T GetState() const noexcept
Get the current server state.
Definition: someip_sd_agent.h:66
virtual void StartAgent(T state)=0
Start the service discovery agent.
SomeIpSdAgent(helper::NetworkLayer< SomeIpSdMessage > *networkLayer)
Constructor.
Definition: someip_sd_agent.h:43
std::future< void > Future
Agent running state future object.
Definition: someip_sd_agent.h:27
void Stop()
Stop the service discovery agent.
Definition: someip_sd_agent.h:83
helper::FiniteStateMachine< T > StateMachine
Agent's FSM.
Definition: someip_sd_agent.h:24
virtual void StopAgent()=0
Stop the service discovery agent.
helper::NetworkLayer< SomeIpSdMessage > * CommunicationLayer
Network communication abstraction layer.
Definition: someip_sd_agent.h:30
void Start()
Start the service discovery agent.
Definition: someip_sd_agent.h:49