summaryrefslogtreecommitdiff
path: root/implementation/routing/src/eventgroupinfo.cpp
blob: 0d098e4361c121e43c0104fa4fd98e4a7e14d9d8 (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
// Copyright (C) 2014-2015 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/.

#include <vsomeip/constants.hpp>

#include "../include/eventgroupinfo.hpp"

namespace vsomeip {

eventgroupinfo::eventgroupinfo()
        : major_(DEFAULT_MAJOR), ttl_(DEFAULT_TTL), is_multicast_(false) {
}

eventgroupinfo::eventgroupinfo(major_version_t _major, ttl_t _ttl)
        : major_(_major), ttl_(_ttl), is_multicast_(false) {
}

eventgroupinfo::~eventgroupinfo() {
}

major_version_t eventgroupinfo::get_major() const {
    return major_;
}

void eventgroupinfo::set_major(major_version_t _major) {
    major_ = _major;
}

ttl_t eventgroupinfo::get_ttl() const {
    return ttl_;
}

void eventgroupinfo::set_ttl(ttl_t _ttl) {
    ttl_ = _ttl;
}

bool eventgroupinfo::is_multicast() const {
    return is_multicast_;
}

bool eventgroupinfo::get_multicast(boost::asio::ip::address &_address,
        uint16_t &_port) const {
    if (is_multicast_) {
        _address = address_;
        _port = port_;
    }
    return is_multicast_;
}

void eventgroupinfo::set_multicast(const boost::asio::ip::address &_address,
        uint16_t _port) {
    address_ = _address;
    port_ = _port;
    is_multicast_ = true;
}

const std::set<std::shared_ptr<event> > eventgroupinfo::get_events() const {
    return events_;
}

void eventgroupinfo::add_event(std::shared_ptr<event> _event) {
    events_.insert(_event);
}

void eventgroupinfo::remove_event(std::shared_ptr<event> _event) {
    events_.erase(_event);
}

const std::set<std::shared_ptr<endpoint_definition> > eventgroupinfo::get_targets() const {
    return targets_;
}

bool eventgroupinfo::add_target(std::shared_ptr<endpoint_definition> _target) {
    std::size_t its_size = targets_.size();
    targets_.insert(_target);
    return (its_size != targets_.size());
}

bool eventgroupinfo::remove_target(
        std::shared_ptr<endpoint_definition> _target) {
    std::size_t its_size = targets_.size();
    targets_.erase(_target);
    return (its_size != targets_.size());
}

void eventgroupinfo::clear_targets() {
    targets_.clear();
}

}  // namespace vsomeip