| 94 | } |
| 95 | |
| 96 | bool message_impl::add_entry_data(const std::shared_ptr<entry_impl>& _entry, const std::vector<std::shared_ptr<option_impl>>& _options, |
| 97 | const std::shared_ptr<entry_impl>& _other) { |
| 98 | std::uint32_t its_entry_size = VSOMEIP_SOMEIP_SD_ENTRY_SIZE; |
| 99 | std::map<const std::shared_ptr<option_impl>, bool> its_options; |
| 100 | |
| 101 | if (_other) { |
| 102 | its_entry_size += VSOMEIP_SOMEIP_SD_ENTRY_SIZE; |
| 103 | } |
| 104 | |
| 105 | // TODO: Check whether it is possible to express the options |
| 106 | // by the two runs. If there are more than two options, it |
| 107 | // might be necessary to copy an option, which then increases |
| 108 | // the size... |
| 109 | |
| 110 | for (const std::shared_ptr<option_impl>& its_option : _options) { |
| 111 | const auto its_existing_option = find_option(its_option); |
| 112 | if (!its_existing_option) { |
| 113 | its_entry_size += its_option->get_size(); |
| 114 | its_options[its_option] = true; |
| 115 | } else { |
| 116 | its_options[its_existing_option] = false; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if (current_message_size_ + its_entry_size > VSOMEIP_MAX_UDP_SD_PAYLOAD) |
| 121 | return false; |
| 122 | |
| 123 | entries_.push_back(_entry); |
| 124 | _entry->set_owning_message(this); |
| 125 | for (const auto& its_option : its_options) { |
| 126 | if (its_option.second) { |
| 127 | options_.push_back(its_option.first); |
| 128 | its_option.first->set_owning_message(this); |
| 129 | } |
| 130 | _entry->assign_option(its_option.first); |
| 131 | } |
| 132 | |
| 133 | if (_other) { |
| 134 | entries_.push_back(_other); |
| 135 | _other->set_owning_message(this); |
| 136 | for (const auto& its_option : its_options) { |
| 137 | _other->assign_option(its_option.first); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | current_message_size_ += its_entry_size; |
| 142 | |
| 143 | return true; |
| 144 | } |
| 145 | |
| 146 | bool message_impl::has_entry() const { |
| 147 | return (0 < entries_.size()); |
no test coverage detected