1 // Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 #ifndef VSOMEIP_V3_SD_ENTRY_IMPL_HPP
7 #define VSOMEIP_V3_SD_ENTRY_IMPL_HPP
8 
9 #include <memory>
10 #include <vector>
11 
12 #include <vsomeip/primitive_types.hpp>
13 #include <vsomeip/internal/serializable.hpp>
14 
15 #include "enumeration_types.hpp"
16 #include "message_element_impl.hpp"
17 
18 #define VSOMEIP_MAX_OPTION_RUN    2
19 
20 namespace vsomeip_v3 {
21 
22 class deserializer;
23 
24 namespace sd {
25 
26 class option_impl;
27 class message_impl;
28 
29 class entry_impl: public message_element_impl {
30 public:
31     virtual ~entry_impl();
32 
33     // public interface
34     entry_type_e get_type() const;
35 
36     service_t get_service() const;
37     void set_service(service_t _service);
38 
39     instance_t get_instance() const;
40     void set_instance(instance_t _instance);
41 
42     major_version_t get_major_version() const;
43     void set_major_version(major_version_t _major_version);
44 
45     ttl_t get_ttl() const;
46     void set_ttl(ttl_t _ttl);
47 
48     const std::vector<uint8_t> & get_options(uint8_t _run) const;
49     void assign_option(const std::shared_ptr<option_impl> &_option);
50 
51     bool is_service_entry() const;
52     bool is_eventgroup_entry() const;
53 
54     void set_type(entry_type_e _type);
55 
56     virtual bool serialize(vsomeip_v3::serializer *_to) const;
57     virtual bool deserialize(vsomeip_v3::deserializer *_from);
58 
59     uint8_t get_num_options(uint8_t _run) const;
60 
61 protected:
62     entry_type_e type_;
63     service_t service_;
64     instance_t instance_;
65     major_version_t major_version_;
66     ttl_t ttl_;
67 
68     std::vector<uint8_t> options_[VSOMEIP_MAX_OPTION_RUN];
69 
70     uint8_t num_options_[VSOMEIP_MAX_OPTION_RUN];
71     std::uint8_t index1_;
72     std::uint8_t index2_;
73 
74     entry_impl();
75     entry_impl(const entry_impl &_entry);
76 };
77 
78 } // namespace sd
79 } // namespace vsomeip_v3
80 
81 #endif // VSOMEIP_V3_SD_ENTRY_IMPL_HPP
82