blob: 00f2b57382e48124062615e5f996d70dbc5333dd (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// Copyright (C) 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_REMOTE_SUBSCRIPTION_HPP_
#define VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_
#include <atomic>
#include <map>
#include <mutex>
#include <set>
#include <vsomeip/primitive_types.hpp>
#include "../../endpoints/include/endpoint_definition.hpp"
#include "types.hpp"
#include <vsomeip/export.hpp>
namespace vsomeip_v3 {
class eventgroupinfo;
const remote_subscription_id_t PENDING_SUBSCRIPTION_ID(0);
class remote_subscription {
public:
VSOMEIP_EXPORT remote_subscription();
VSOMEIP_EXPORT ~remote_subscription();
bool operator==(const remote_subscription &_other) const;
bool equals(const std::shared_ptr<remote_subscription> &_other) const;
VSOMEIP_EXPORT void reset(const std::set<client_t> &_clients);
VSOMEIP_EXPORT bool is_initial() const;
VSOMEIP_EXPORT void set_initial(const bool _is_initial);
VSOMEIP_EXPORT bool force_initial_events() const;
VSOMEIP_EXPORT void set_force_initial_events(const bool _force_initial_events);
remote_subscription_id_t get_id() const;
void set_id(const remote_subscription_id_t _id);
std::shared_ptr<remote_subscription> get_parent() const;
void set_parent(const std::shared_ptr<remote_subscription> &_parent);
VSOMEIP_EXPORT std::shared_ptr<eventgroupinfo> get_eventgroupinfo() const;
VSOMEIP_EXPORT void set_eventgroupinfo(const std::shared_ptr<eventgroupinfo> &_info);
VSOMEIP_EXPORT ttl_t get_ttl() const;
VSOMEIP_EXPORT void set_ttl(const ttl_t _ttl);
uint16_t get_reserved() const;
void set_reserved(const uint16_t _reserved);
uint8_t get_counter() const;
void set_counter(uint8_t _counter);
VSOMEIP_EXPORT std::set<client_t> get_clients() const;
bool has_client() const;
bool has_client(const client_t _client) const;
void remove_client(const client_t _client);
VSOMEIP_EXPORT remote_subscription_state_e get_client_state(const client_t _client) const;
void set_client_state(const client_t _client,
remote_subscription_state_e _state);
void set_all_client_states(remote_subscription_state_e _state);
std::chrono::steady_clock::time_point get_expiration(const client_t _client) const;
VSOMEIP_EXPORT std::shared_ptr<endpoint_definition> get_subscriber() const;
VSOMEIP_EXPORT void set_subscriber(const std::shared_ptr<endpoint_definition> &_subscriber);
VSOMEIP_EXPORT std::shared_ptr<endpoint_definition> get_reliable() const;
VSOMEIP_EXPORT void set_reliable(const std::shared_ptr<endpoint_definition> &_reliable);
VSOMEIP_EXPORT std::shared_ptr<endpoint_definition> get_unreliable() const;
VSOMEIP_EXPORT void set_unreliable(const std::shared_ptr<endpoint_definition> &_unreliable);
VSOMEIP_EXPORT bool is_pending() const;
bool is_acknowledged() const;
std::set<client_t> update(const std::set<client_t> &_clients,
const std::chrono::steady_clock::time_point &_timepoint,
const bool _is_subscribe);
VSOMEIP_EXPORT std::uint32_t get_answers() const;
void set_answers(const std::uint32_t _answers);
private:
std::atomic<remote_subscription_id_t> id_;
std::atomic<bool> is_initial_;
std::atomic<bool> force_initial_events_;
std::weak_ptr<remote_subscription> parent_;
std::weak_ptr<eventgroupinfo> eventgroupinfo_;
major_version_t major_;
ttl_t ttl_;
std::uint16_t reserved_;
std::uint8_t counter_;
std::map<client_t,
std::pair<remote_subscription_state_e,
std::chrono::steady_clock::time_point
>
> clients_;
// The endpoint that sent(!) the subscription
std::shared_ptr<endpoint_definition> subscriber_;
// The endpoints defined by the endpoint options
std::shared_ptr<endpoint_definition> reliable_;
std::shared_ptr<endpoint_definition> unreliable_;
// Number of acknowledgements that must be sent
// for the subscriptions. This is usally 1, but
// may be larger if a matching subscription arrived
// before the subscription could be acknowledged
std::uint32_t answers_;
mutable std::mutex mutex_;
};
} // namespace vsomeip_v3
#endif // VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_
|