summaryrefslogtreecommitdiff
path: root/implementation/service_discovery/src/subscription.cpp
blob: 10e4a1c7adfffc7ff91d7a4057437e43b5e9a3ca (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-2017 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 "../include/subscription.hpp"

namespace vsomeip {
namespace sd {

subscription::subscription(major_version_t _major, ttl_t _ttl,
        std::shared_ptr<endpoint> _reliable,
        std::shared_ptr<endpoint> _unreliable,
        subscription_type_e _subscription_type,
        uint8_t _counter,
        std::chrono::steady_clock::time_point _expiration)
        : major_(_major), ttl_(_ttl),
          reliable_(_reliable), unreliable_(_unreliable),
          is_acknowledged_(true),
          tcp_connection_established_(false),
          subscription_type_(_subscription_type),
          counter_(_counter),
          expiration_(_expiration) {
}

subscription::~subscription() {
}

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

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

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

std::shared_ptr<endpoint> subscription::get_endpoint(bool _reliable) const {
    return (_reliable ? reliable_ : unreliable_);
}

void subscription::set_endpoint(std::shared_ptr<endpoint> _endpoint,
        bool _reliable) {
    if (_reliable)
        reliable_ = _endpoint;
    else
        unreliable_ = _endpoint;
}

bool subscription::is_acknowledged() const {
    return is_acknowledged_;
}

void subscription::set_acknowledged(bool _is_acknowledged) {
    is_acknowledged_ = _is_acknowledged;
}

bool subscription::is_tcp_connection_established() const {
    return tcp_connection_established_;
}
void subscription::set_tcp_connection_established(bool _is_established) {
    tcp_connection_established_ = _is_established;
}

subscription_type_e subscription::get_subscription_type() const {
    return subscription_type_;
}

uint8_t subscription::get_counter() const {
    return counter_;
}

std::chrono::steady_clock::time_point subscription::get_expiration() const {
    return expiration_;
}

void subscription::set_expiration(std::chrono::steady_clock::time_point _expiration) {
    expiration_ = _expiration;
}

} // namespace sd
} // namespace vsomeip