summaryrefslogtreecommitdiff
path: root/implementation/routing/include/eventgroupinfo.hpp
blob: 7e832a1a5e58bad6d4c47e768c06a239f45e72d6 (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
// Copyright (C) 2014-2016 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_EVENTGROUPINFO_HPP
#define VSOMEIP_EVENTGROUPINFO_HPP

#include <chrono>
#include <list>
#include <memory>
#include <set>

#include <boost/asio/ip/address.hpp>

#include <vsomeip/export.hpp>
#include <vsomeip/primitive_types.hpp>

namespace vsomeip {

class endpoint_definition;
class event;

class eventgroupinfo {
public:
    struct target_t {
        std::shared_ptr<endpoint_definition> endpoint_;
        std::chrono::high_resolution_clock::time_point expiration_;

        bool operator==(const target_t &_other) const {
            return (endpoint_ == _other.endpoint_);
        }
    };

    VSOMEIP_EXPORT eventgroupinfo();
    VSOMEIP_EXPORT eventgroupinfo(major_version_t _major, ttl_t _ttl);
    VSOMEIP_EXPORT ~eventgroupinfo();

    VSOMEIP_EXPORT major_version_t get_major() const;
    VSOMEIP_EXPORT void set_major(major_version_t _major);

    VSOMEIP_EXPORT ttl_t get_ttl() const;
    VSOMEIP_EXPORT void set_ttl(ttl_t _ttl);

    VSOMEIP_EXPORT bool is_multicast() const;
    VSOMEIP_EXPORT bool get_multicast(boost::asio::ip::address &_address,
            uint16_t &_port) const;
    VSOMEIP_EXPORT void set_multicast(const boost::asio::ip::address &_address,
            uint16_t _port);

    VSOMEIP_EXPORT const std::set<std::shared_ptr<event> > get_events() const;
    VSOMEIP_EXPORT void add_event(std::shared_ptr<event> _event);
    VSOMEIP_EXPORT void remove_event(std::shared_ptr<event> _event);

    VSOMEIP_EXPORT const std::list<target_t> get_targets() const;
    VSOMEIP_EXPORT uint32_t get_unreliable_target_count();

    VSOMEIP_EXPORT bool add_target(const target_t &_target);
    VSOMEIP_EXPORT bool add_target(const target_t &_target, const target_t &_subscriber);
    VSOMEIP_EXPORT bool update_target(
            const std::shared_ptr<endpoint_definition> &_target,
            const std::chrono::high_resolution_clock::time_point &_expiration);
    VSOMEIP_EXPORT bool remove_target(
            const std::shared_ptr<endpoint_definition> &_target);
    VSOMEIP_EXPORT void clear_targets();

    VSOMEIP_EXPORT void add_multicast_target(const target_t &_multicast_target);
    VSOMEIP_EXPORT void clear_multicast_targets();
    VSOMEIP_EXPORT const std::list<target_t> get_multicast_targets() const;

private:
    major_version_t major_;
    ttl_t ttl_;

    boost::asio::ip::address address_;
    uint16_t port_;

    std::set<std::shared_ptr<event> > events_;
    std::list<target_t> targets_;
    std::list<target_t> multicast_targets_;
};

} // namespace vsomeip

#endif // VSOMEIP_EVENTGROUPINFO_HPP