1 // Copyright (C) 2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 #ifndef VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_
7 #define VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_
8 
9 #include <memory>
10 #include <mutex>
11 #include <set>
12 
13 namespace vsomeip_v3 {
14 
15 class remote_subscription;
16 
17 namespace sd {
18 
19 class message_impl;
20 
21 class remote_subscription_ack {
22 public:
23     remote_subscription_ack(const boost::asio::ip::address &_address);
24 
25     // The complete flag signals whether or not all subscribes
26     // of a message have been inserted.
27     bool is_complete() const;
28     void complete();
29 
30     // The done flag signals whether or not all subscribes
31     // have been processed.
32     bool is_done() const;
33     void done();
34 
35     std::vector<std::shared_ptr<message_impl> > get_messages() const;
36     std::shared_ptr<message_impl> get_current_message() const;
37     std::shared_ptr<message_impl> add_message();
38 
39     boost::asio::ip::address get_target_address() const;
40 
41     bool is_pending() const;
42 
43     std::set<std::shared_ptr<remote_subscription> > get_subscriptions() const;
44     void add_subscription(
45             const std::shared_ptr<remote_subscription> &_subscription);
46     bool has_subscription() const;
47 
48     std::unique_lock<std::recursive_mutex> get_lock();
49 
50 private:
51     std::recursive_mutex mutex_;
52     std::vector<std::shared_ptr<message_impl> > messages_;
53     bool is_complete_;
54     bool is_done_;
55 
56     const boost::asio::ip::address target_address_;
57 
58     std::set<std::shared_ptr<remote_subscription> > subscriptions_;
59 };
60 
61 } // namespace sd
62 } // namespace vsomeip_v3
63 
64 #endif // VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_
65