MCPcopy Create free account
hub / github.com/COVESA/vsomeip / add_entry_data

Method add_entry_data

implementation/service_discovery/src/message_impl.cpp:96–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96bool 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
146bool message_impl::has_entry() const {
147 return (0 < entries_.size());

Callers 2

construct_subscriptionFunction · 0.45
construct_offerFunction · 0.45

Calls 3

set_owning_messageMethod · 0.80
assign_optionMethod · 0.80
get_sizeMethod · 0.45

Tested by

no test coverage detected