summaryrefslogtreecommitdiff
path: root/implementation/service_discovery/include/message_impl.hpp
blob: 1d658a5fb6cc7bec8bec0f83ca4b14370d7ba37f (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
93
// 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/.

#ifndef VSOMEIP_SD_MESSAGE_IMPL_HPP
#define VSOMEIP_SD_MESSAGE_IMPL_HPP

#include <memory>
#include <vector>

#include <vsomeip/message.hpp>

#include "../include/primitive_types.hpp"
#include "../../message/include/message_base_impl.hpp"

#  if _MSC_VER >= 1300
/*
* Diamond inheritance is used for the vsomeip::message_base base class.
* The Microsoft compiler put warning (C4250) using a desired c++ feature: "Delegating to a sister class"
* A powerful technique that arises from using virtual inheritance is to delegate a method from a class in another class
* by using a common abstract base class. This is also called cross delegation.
*/
#    pragma warning( disable : 4250 )
#  endif

namespace vsomeip {
namespace sd {

class entry_impl;
class eventgroupentry_impl;
class serviceentry_impl;

class option_impl;
class configuration_option_impl;
class ipv4_option_impl;
class ipv6_option_impl;
class load_balancing_option_impl;
class protection_option_impl;

class message_impl: public vsomeip::message, public vsomeip::message_base_impl {
public:
    message_impl();
    virtual ~message_impl();

    length_t get_length() const;
    void set_length(length_t _length);

    bool get_reboot_flag() const;
    void set_reboot_flag(bool _is_set);

    bool get_unicast_flag() const;
    void set_unicast_flag(bool _is_set);

    std::shared_ptr<eventgroupentry_impl> create_eventgroup_entry();
    std::shared_ptr<serviceentry_impl> create_service_entry();

    std::shared_ptr<configuration_option_impl> create_configuration_option();
    std::shared_ptr<ipv4_option_impl> create_ipv4_option(bool _is_multicast);
    std::shared_ptr<ipv6_option_impl> create_ipv6_option(bool _is_multicast);
    std::shared_ptr<load_balancing_option_impl> create_load_balancing_option();
    std::shared_ptr<protection_option_impl> create_protection_option();

    const std::vector<std::shared_ptr<entry_impl> > & get_entries() const;
    const std::vector<std::shared_ptr<option_impl> > & get_options() const;

    int16_t get_option_index(const std::shared_ptr<option_impl> &_option) const;
    uint32_t get_options_length();

    std::shared_ptr<payload> get_payload() const;
    void set_payload(std::shared_ptr<payload> _payload);

    bool serialize(vsomeip::serializer *_to) const;
    bool deserialize(vsomeip::deserializer *_from);

    length_t get_someip_length() const;

private:
    entry_impl * deserialize_entry(vsomeip::deserializer *_from);
    option_impl * deserialize_option(vsomeip::deserializer *_from);

private:
    flags_t flags_;
    uint32_t options_length_;

    std::vector<std::shared_ptr<entry_impl> > entries_;
    std::vector<std::shared_ptr<option_impl> > options_;
};

} // namespace sd
} // namespace vsomeip

#endif // VSOMEIP_INTERNAL_SD_MESSAGE_IMPL_HPP