| 230 | } |
| 231 | |
| 232 | bool TopicImpl::check_data_representation(const DDS::DataRepresentationIdSeq& qos_ids, bool is_data_writer) |
| 233 | { |
| 234 | if (!type_support_) { |
| 235 | return true; |
| 236 | } |
| 237 | DDS::DataRepresentationIdSeq type_allowed_reprs; |
| 238 | type_support_->representations_allowed_by_type(type_allowed_reprs); |
| 239 | //default for blank annotation is to allow all types of data representation |
| 240 | if (type_allowed_reprs.length() == 0) { |
| 241 | return true; |
| 242 | } |
| 243 | if (qos_ids.length() == 0) { |
| 244 | if (log_level >= LogLevel::Notice) { |
| 245 | ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: TopicImpl::check_data_representation: " |
| 246 | "representation qos is blank.\n")); |
| 247 | } |
| 248 | return false; |
| 249 | } |
| 250 | //Data Writer will only use the 1st QoS declared |
| 251 | if (is_data_writer) { |
| 252 | DDS::DataRepresentationId_t id = qos_ids[0]; |
| 253 | for (CORBA::ULong j = 0; j < type_allowed_reprs.length(); ++j) { |
| 254 | if (id == type_allowed_reprs[j]) { |
| 255 | return true; |
| 256 | } |
| 257 | } |
| 258 | } else { // if data reader compare both lists for a compatible QoS |
| 259 | for (CORBA::ULong i = 0; i < qos_ids.length(); ++i) { |
| 260 | for (CORBA::ULong j = 0; j < type_allowed_reprs.length(); ++j) { |
| 261 | if (qos_ids[i] == type_allowed_reprs[j]) { |
| 262 | return true; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | if (log_level >= LogLevel::Notice) { |
| 268 | ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: TopicImpl::check_data_representation: " |
| 269 | "none of the data representation QoS: %C is allowed by the " |
| 270 | "topic type IDL annotations: %C\n", repr_seq_to_string(qos_ids, is_data_writer).c_str(), repr_seq_to_string(type_allowed_reprs).c_str())); |
| 271 | } |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | } // namespace DCPS |
| 276 | } // namespace OpenDDS |
no test coverage detected