1 // Copyright (C) 2014-2018 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_MESSAGE_IMPL_HPP_ 7 #define VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ 8 9 #include <atomic> 10 #include <memory> 11 #include <mutex> 12 #include <vector> 13 14 #include <vsomeip/message.hpp> 15 16 #include "../include/primitive_types.hpp" 17 #include "../../message/include/message_base_impl.hpp" 18 #include "../../endpoints/include/endpoint_definition.hpp" 19 20 # if _MSC_VER >= 1300 21 /* 22 * Diamond inheritance is used for the vsomeip::message_base base class. 23 * The Microsoft compiler put warning (C4250) using a desired c++ feature: "Delegating to a sister class" 24 * A powerful technique that arises from using virtual inheritance is to delegate a method from a class in another class 25 * by using a common abstract base class. This is also called cross delegation. 26 */ 27 # pragma warning( disable : 4250 ) 28 # endif 29 30 namespace vsomeip_v3 { 31 namespace sd { 32 33 class entry_impl; 34 class eventgroupentry_impl; 35 class serviceentry_impl; 36 37 class option_impl; 38 class configuration_option_impl; 39 class ipv4_option_impl; 40 class ipv6_option_impl; 41 class load_balancing_option_impl; 42 class protection_option_impl; 43 class selective_option_impl; 44 45 class message_impl 46 : public vsomeip_v3::message, public vsomeip_v3::message_base_impl { 47 public: 48 typedef std::vector<std::shared_ptr<entry_impl>> entries_t; 49 typedef std::vector<std::shared_ptr<option_impl>> options_t; 50 struct forced_initial_events_t { 51 std::shared_ptr<vsomeip_v3::endpoint_definition> target_; 52 vsomeip_v3::service_t service_; 53 vsomeip_v3::instance_t instance_; 54 vsomeip_v3::eventgroup_t eventgroup_; 55 }; 56 message_impl(); 57 virtual ~message_impl(); 58 59 length_t get_length() const; 60 void set_length(length_t _length); 61 62 length_t get_size() const; 63 64 bool get_reboot_flag() const; 65 void set_reboot_flag(bool _is_set); 66 67 bool get_unicast_flag() const; 68 void set_unicast_flag(bool _is_set); 69 70 bool has_entry() const; 71 bool has_option() const; 72 73 const entries_t & get_entries() const; 74 const options_t & get_options() const; 75 76 bool add_entry_data(const std::shared_ptr<entry_impl> &_entry, 77 const std::vector<std::shared_ptr<option_impl> > &_options, 78 const std::shared_ptr<entry_impl> &_other = nullptr); 79 80 std::shared_ptr<option_impl> find_option( 81 const std::shared_ptr<option_impl> &_option) const; 82 83 int16_t get_option_index(const std::shared_ptr<option_impl> &_option) const; 84 std::shared_ptr<option_impl> get_option(int16_t _index) const; 85 uint32_t get_options_length(); 86 87 std::shared_ptr<payload> get_payload() const; 88 void set_payload(std::shared_ptr<payload> _payload); 89 90 uint8_t get_check_result() const; 91 void set_check_result(uint8_t _check_result); 92 bool is_valid_crc() const; 93 94 bool serialize(vsomeip_v3::serializer *_to) const; 95 bool deserialize(vsomeip_v3::deserializer *_from); 96 97 length_t get_someip_length() const; 98 99 void forced_initial_events_add(forced_initial_events_t _entry); 100 const std::vector<forced_initial_events_t> forced_initial_events_get(); 101 102 void set_initial_events_required(bool _initial_events_required); 103 bool initial_events_required() const; 104 105 uid_t get_uid() const; 106 gid_t get_gid() const; 107 108 private: 109 entry_impl * deserialize_entry(vsomeip_v3::deserializer *_from); 110 option_impl * deserialize_option(vsomeip_v3::deserializer *_from); 111 112 private: 113 flags_t flags_; 114 uint32_t options_length_; 115 116 entries_t entries_; 117 options_t options_; 118 119 std::mutex message_mutex_; 120 121 std::uint32_t current_message_size_; 122 }; 123 124 } // namespace sd 125 } // namespace vsomeip_v3 126 127 #endif // VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ 128