Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
communication_group_server.h
1#ifndef COMMUNICATION_GROUP_SERVER_H
2#define COMMUNICATION_GROUP_SERVER_H
3
4#include <stdint.h>
5#include <functional>
6#include <future>
7#include <vector>
8
9namespace ara
10{
11 namespace com
12 {
13 namespace cg
14 {
17 template <typename R>
18 using ResponseHandler = std::function<void(uint32_t, R)>;
19
23 template <typename T, typename R>
25 {
26 private:
27 ResponseHandler<R> mResponseHandler;
28 std::vector<uint32_t> mClients;
29
30 public:
33 explicit CommunicationGroupServer(ResponseHandler<R> responseHandler) : mResponseHandler{responseHandler}
34 {
35 }
36
37 ~CommunicationGroupServer() noexcept = default;
38
42 std::future<void> Broadcast(const T &msg) const;
43
48 std::future<void> Message(uint32_t clientID, const T &msg) const;
49
53 void Response(uint32_t clientID, const R &responseMsg)
54 {
55 mResponseHandler(clientID, responseMsg);
56 }
57
60 std::future<std::vector<uint32_t>> ListClients() const;
61 };
62 }
63 }
64}
65
66#endif
Communication group server skeleton.
Definition: communication_group_server.h:25
std::future< void > Message(uint32_t clientID, const T &msg) const
Send a request message to a specific client.
CommunicationGroupServer(ResponseHandler< R > responseHandler)
Constructor.
Definition: communication_group_server.h:33
std::future< std::vector< uint32_t > > ListClients() const
List all the subscribed clients.
std::future< void > Broadcast(const T &msg) const
Broadcast a request message to all the clients.
void Response(uint32_t clientID, const R &responseMsg)
Receive a response message from a client.
Definition: communication_group_server.h:53