summaryrefslogtreecommitdiff
path: root/implementation/service_discovery/include/remote_subscription_ack.hpp
blob: 7b2b63576ecbc8f8d93c59c15e21f771334c6f53 (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
// Copyright (C) 2021 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_REMOTE_SUBSCRIPTION_ACK_HPP_
#define VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_

#include <memory>
#include <mutex>
#include <set>

namespace vsomeip_v3 {

class remote_subscription;

namespace sd {

class message_impl;

class remote_subscription_ack {
public:
    remote_subscription_ack(const boost::asio::ip::address &_address);

    // The complete flag signals whether or not all subscribes
    // of a message have been inserted.
    bool is_complete() const;
    void complete();

    // The done flag signals whether or not all subscribes
    // have been processed.
    bool is_done() const;
    void done();

    std::vector<std::shared_ptr<message_impl> > get_messages() const;
    std::shared_ptr<message_impl> get_current_message() const;
    std::shared_ptr<message_impl> add_message();

    boost::asio::ip::address get_target_address() const;

    bool is_pending() const;

    std::set<std::shared_ptr<remote_subscription> > get_subscriptions() const;
    void add_subscription(
            const std::shared_ptr<remote_subscription> &_subscription);
    bool has_subscription() const;

    std::unique_lock<std::recursive_mutex> get_lock();

private:
    std::recursive_mutex mutex_;
    std::vector<std::shared_ptr<message_impl> > messages_;
    bool is_complete_;
    bool is_done_;

    const boost::asio::ip::address target_address_;

    std::set<std::shared_ptr<remote_subscription> > subscriptions_;
};

} // namespace sd
} // namespace vsomeip_v3

#endif // VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_