| 2428 | } |
| 2429 | |
| 2430 | bool |
| 2431 | DataReaderImpl::filter_sample(const DataSampleHeader& header) |
| 2432 | { |
| 2433 | const SystemTimePoint now = SystemTimePoint::now(); |
| 2434 | |
| 2435 | // Expire historic data if QoS indicates VOLATILE. |
| 2436 | if (!always_get_history_ && header.historic_sample_ |
| 2437 | && qos_.durability.kind == DDS::VOLATILE_DURABILITY_QOS) { |
| 2438 | if (DCPS_debug_level >= 8) { |
| 2439 | ACE_DEBUG((LM_DEBUG, |
| 2440 | ACE_TEXT("(%P|%t) DataReaderImpl::filter_sample: ") |
| 2441 | ACE_TEXT("Discarded historic data.\n"))); |
| 2442 | } |
| 2443 | |
| 2444 | return true; // Data filtered. |
| 2445 | } |
| 2446 | |
| 2447 | // The LIFESPAN_DURATION_FLAG is set when sample data is sent |
| 2448 | // with a non-default LIFESPAN duration value. |
| 2449 | if (header.lifespan_duration_) { |
| 2450 | // Finite lifespan. Check if data has expired. |
| 2451 | |
| 2452 | const DDS::Time_t expiration_dds_time = { |
| 2453 | header.source_timestamp_sec_ + header.lifespan_duration_sec_, |
| 2454 | header.source_timestamp_nanosec_ + header.lifespan_duration_nanosec_ |
| 2455 | }; |
| 2456 | const SystemTimePoint expiration_time(expiration_dds_time); |
| 2457 | |
| 2458 | // We assume that the publisher host's clock and subcriber host's |
| 2459 | // clock are synchronized (allowed by the spec). |
| 2460 | if (now >= expiration_time) { |
| 2461 | if (DCPS_debug_level >= 8) { |
| 2462 | const TimeDuration diff(now - expiration_time); |
| 2463 | ACE_DEBUG((LM_DEBUG, |
| 2464 | ACE_TEXT("(%P|%t) Received data ") |
| 2465 | ACE_TEXT("expired by %d seconds, %d microseconds.\n"), |
| 2466 | diff.value().sec(), |
| 2467 | diff.value().usec())); |
| 2468 | } |
| 2469 | |
| 2470 | return true; // Data filtered. |
| 2471 | } |
| 2472 | } |
| 2473 | |
| 2474 | return false; |
| 2475 | } |
| 2476 | |
| 2477 | bool |
| 2478 | DataReaderImpl::ownership_filter_instance(const SubscriptionInstance_rch& instance, |