| 468 | } |
| 469 | |
| 470 | bool |
| 471 | OpenDDS::DCPS::DataDurabilityCache::insert( |
| 472 | DDS::DomainId_t domain_id, |
| 473 | char const * topic_name, |
| 474 | char const * type_name, |
| 475 | SendStateDataSampleList & the_data, |
| 476 | DDS::DurabilityServiceQosPolicy const & qos) |
| 477 | { |
| 478 | if (the_data.size() == 0) |
| 479 | return true; // Nothing to cache. |
| 480 | |
| 481 | // Apply DURABILITY_SERVICE QoS HISTORY and RESOURCE_LIMITS related |
| 482 | // settings prior to data insertion into the cache. |
| 483 | int depth = qos.history_kind == DDS::KEEP_ALL_HISTORY_QOS |
| 484 | ? qos.max_samples_per_instance |
| 485 | : qos.history_depth; |
| 486 | |
| 487 | if (depth == DDS::LENGTH_UNLIMITED) |
| 488 | depth = 0x7fffffff; |
| 489 | |
| 490 | // Iterator to first DataSampleElement to be copied. |
| 491 | SendStateDataSampleList::iterator element(the_data.begin()); |
| 492 | |
| 493 | if (depth < 0) |
| 494 | return false; // Should never occur. |
| 495 | |
| 496 | else if (depth == 0) |
| 497 | return true; // Nothing else to do. Discard all data. |
| 498 | |
| 499 | else if (the_data.size() > depth) { |
| 500 | // N.B. Dropping data samples does not take into account |
| 501 | // those samples which are not actually persisted (i.e. |
| 502 | // samples with the coherent_sample_ flag set). The spec |
| 503 | // does not provide any guidance in this case, therefore |
| 504 | // we opt for the simplest solution and assume that there |
| 505 | // are no change sets when calculating the number of |
| 506 | // samples to drop. |
| 507 | |
| 508 | // Drop "old" samples. Only keep the "depth" most recent |
| 509 | // samples, i.e. those found at the tail end of the |
| 510 | // SendStateDataSampleList. |
| 511 | ssize_t const advance_amount = the_data.size() - depth; |
| 512 | std::advance(element, advance_amount); |
| 513 | } |
| 514 | |
| 515 | // ----------- |
| 516 | |
| 517 | // Copy samples to the domain/topic/type-specific cache. |
| 518 | |
| 519 | key_type const key(domain_id, |
| 520 | topic_name, |
| 521 | type_name, |
| 522 | this->allocator_.get()); |
| 523 | SendStateDataSampleList::iterator the_end(the_data.end()); |
| 524 | sample_list_type * sample_list = 0; |
| 525 | |
| 526 | typedef DurabilityQueue<sample_data_type> data_queue_type; |
| 527 | data_queue_type ** slot = 0; |
nothing calls this directly
no test coverage detected