blob: adbd66ceb1a1af85304b5c4581816be237a4e30b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (C) 2014-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef VSOMEIP_V3_SD_SUBSCRIPTION_HPP_
#define VSOMEIP_V3_SD_SUBSCRIPTION_HPP_
#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <vsomeip/primitive_types.hpp>
#include <vsomeip/enumeration_types.hpp>
namespace vsomeip_v3 {
class endpoint;
class eventgroupinfo;
namespace sd {
enum class subscription_state_e : uint8_t {
ST_ACKNOWLEDGED = 0x00,
ST_NOT_ACKNOWLEDGED = 0x01,
ST_RESUBSCRIBING = 0x2,
ST_RESUBSCRIBING_NOT_ACKNOWLEDGED = 0x3,
ST_UNKNOWN = 0xFF
};
class subscription {
public:
subscription() = default;
~subscription() = default;
major_version_t get_major() const;
void set_major(major_version_t _major);
ttl_t get_ttl() const;
void set_ttl(ttl_t _ttl);
std::shared_ptr<endpoint> get_endpoint(bool _reliable) const;
void set_endpoint(const std::shared_ptr<endpoint>& _endpoint, bool _reliable);
bool is_selective() const;
void set_selective(const bool _is_selective);
subscription_state_e get_state(const client_t _client) const;
void set_state(const client_t _client, subscription_state_e _state);
bool is_tcp_connection_established() const;
void set_tcp_connection_established(bool _is_established);
bool is_udp_connection_established() const;
void set_udp_connection_established(bool _is_established);
bool add_client(const client_t _client);
bool remove_client(const client_t _client);
std::set<client_t> get_clients() const;
bool has_client() const;
bool has_client(const client_t _client) const;
void set_eventgroupinfo(const std::shared_ptr<eventgroupinfo> _info);
std::weak_ptr<eventgroupinfo> get_eventgroupinfo() const;
private:
major_version_t major_;
ttl_t ttl_;
std::shared_ptr<endpoint> reliable_;
std::shared_ptr<endpoint> unreliable_;
bool is_selective_;
bool tcp_connection_established_;
bool udp_connection_established_;
mutable std::mutex clients_mutex_;
std::map<client_t, subscription_state_e> clients_; // client-> is acknowledged?
std::weak_ptr<eventgroupinfo> eg_info_;
};
} // namespace sd
} // namespace vsomeip_v3
#endif // VSOMEIP_V3_SD_SUBSCRIPTION_HPP_
|