| 366 | } |
| 367 | |
| 368 | DDS::ReturnCode_t DynamicDataImpl::clear_value(DDS::MemberId id) |
| 369 | { |
| 370 | ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, DDS::RETCODE_ERROR); |
| 371 | const TypeKind this_tk = type_->get_kind(); |
| 372 | if (is_primitive(this_tk) || this_tk == TK_ENUM) { |
| 373 | if (id != MEMBER_ID_INVALID) { |
| 374 | return DDS::RETCODE_BAD_PARAMETER; |
| 375 | } |
| 376 | return clear_value_i(id, type_); |
| 377 | } |
| 378 | |
| 379 | switch (this_tk) { |
| 380 | case TK_BITMASK: |
| 381 | return set_boolean_value(id, false); |
| 382 | case TK_ARRAY: { |
| 383 | const DDS::UInt32 bound = bound_total(type_desc_); |
| 384 | if (!check_index_from_id(this_tk, id, bound)) { |
| 385 | return DDS::RETCODE_BAD_PARAMETER; |
| 386 | } |
| 387 | DDS::DynamicType_var elem_type = get_base_type(type_desc_->element_type()); |
| 388 | return clear_value_i(id, elem_type); |
| 389 | } |
| 390 | case TK_STRING8: |
| 391 | #ifdef DDS_HAS_WCHAR |
| 392 | case TK_STRING16: |
| 393 | #endif |
| 394 | case TK_SEQUENCE: { |
| 395 | // Shift subsequent elements to the left (XTypes spec 7.5.2.11.3). |
| 396 | const CORBA::ULong size = get_sequence_item_count(); |
| 397 | if (id >= size) { |
| 398 | return DDS::RETCODE_BAD_PARAMETER; |
| 399 | } |
| 400 | |
| 401 | DDS::DynamicType_var elem_type = get_base_type(type_desc_->element_type()); |
| 402 | erase_member(id); |
| 403 | for (CORBA::ULong i = id_to_index(id) + 1; i < size; ++i) { |
| 404 | const DDS::MemberId curr_id = index_to_id(i); |
| 405 | const DDS::MemberId prev_id = index_to_id(i - 1); |
| 406 | const_single_iterator single_it = container_.single_map_.find(curr_id); |
| 407 | if (single_it != container_.single_map_.end()) { |
| 408 | container_.single_map_.insert(std::make_pair(prev_id, single_it->second)); |
| 409 | container_.single_map_.erase(curr_id); |
| 410 | continue; |
| 411 | } |
| 412 | const_sequence_iterator seq_it = container_.sequence_map_.find(curr_id); |
| 413 | if (seq_it != container_.sequence_map_.end()) { |
| 414 | container_.sequence_map_.insert(std::make_pair(prev_id, seq_it->second)); |
| 415 | container_.sequence_map_.erase(curr_id); |
| 416 | continue; |
| 417 | } |
| 418 | const_complex_iterator complex_it = container_.complex_map_.find(curr_id); |
| 419 | if (complex_it != container_.complex_map_.end()) { |
| 420 | container_.complex_map_.insert(std::make_pair(prev_id, complex_it->second)); |
| 421 | container_.complex_map_.erase(curr_id); |
| 422 | continue; |
| 423 | } |
| 424 | // Since the backing store is read-only, we can't shift its elements. Instead, |
| 425 | // copy (and shift) the elements that are missing in the container from the backing store. |
nothing calls this directly
no test coverage detected