Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DataReaderImpl to use a new DataReaderHistory class [12404] #2177

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set(${PROJECT_NAME}_source_files
fastrtps_deprecated/subscriber/SubscriberImpl.cpp
fastrtps_deprecated/subscriber/SubscriberHistory.cpp
fastdds/subscriber/DataReader.cpp
fastdds/subscriber/history/DataReaderHistory.cpp
fastdds/publisher/DataWriter.cpp
fastdds/subscriber/DataReaderImpl.cpp
fastdds/publisher/DataWriterImpl.cpp
Expand Down
44 changes: 2 additions & 42 deletions src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,6 @@ namespace eprosima {
namespace fastdds {
namespace dds {

static void sample_info_to_dds (
const SampleInfo_t& rtps_info,
SampleInfo* dds_info)
{
dds_info->sample_state = NOT_READ_SAMPLE_STATE;
dds_info->view_state = NOT_NEW_VIEW_STATE;
dds_info->disposed_generation_count = 0;
dds_info->no_writers_generation_count = 1;
dds_info->sample_rank = 0;
dds_info->generation_rank = 0;
dds_info->absoulte_generation_rank = 0;
dds_info->source_timestamp = rtps_info.sourceTimestamp;
dds_info->reception_timestamp = rtps_info.receptionTimestamp;
dds_info->instance_handle = rtps_info.iHandle;
dds_info->publication_handle = fastrtps::rtps::InstanceHandle_t(rtps_info.sample_identity.writer_guid());
dds_info->sample_identity = rtps_info.sample_identity;
dds_info->related_sample_identity = rtps_info.related_sample_identity;
dds_info->valid_data = rtps_info.sampleKind == eprosima::fastrtps::rtps::ALIVE ? true : false;

switch (rtps_info.sampleKind)
{
case eprosima::fastrtps::rtps::ALIVE:
dds_info->instance_state = ALIVE_INSTANCE_STATE;
break;
case eprosima::fastrtps::rtps::NOT_ALIVE_DISPOSED:
dds_info->instance_state = NOT_ALIVE_DISPOSED_INSTANCE_STATE;
break;
default:
//TODO [ILG] change this if the other kinds ever get implemented
dds_info->instance_state = ALIVE_INSTANCE_STATE;
break;
}
}

static bool collections_have_same_properties(
const LoanableCollection& data_values,
const SampleInfoSeq& sample_infos)
Expand Down Expand Up @@ -126,11 +92,7 @@ DataReaderImpl::DataReaderImpl(
, topic_(topic)
, qos_(&qos == &DATAREADER_QOS_DEFAULT ? subscriber_->get_default_datareader_qos() : qos)
#pragma warning (disable : 4355 )
, history_(topic_attributes(),
type_.get(),
qos_.get_readerqos(subscriber_->get_qos()),
type_->m_typeSize + 3, /* Possible alignment */
qos_.endpoint().history_memory_policy)
, history_(type, *topic, qos_)
, listener_(listener)
, reader_listener_(this)
, deadline_duration_us_(qos_.deadline().period.to_ns() * 1e-3)
Expand Down Expand Up @@ -681,10 +643,8 @@ ReturnCode_t DataReaderImpl::get_first_untaken_info(
return ReturnCode_t::RETCODE_NOT_ENABLED;
}

SampleInfo_t rtps_info;
if (history_.get_first_untaken_info(&rtps_info))
if (history_.get_first_untaken_info(*info))
{
sample_info_to_dds(rtps_info, info);
return ReturnCode_t::RETCODE_OK;
}
return ReturnCode_t::RETCODE_NO_DATA;
Expand Down
5 changes: 3 additions & 2 deletions src/cpp/fastdds/subscriber/DataReaderImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <fastdds/rtps/reader/ReaderListener.h>

#include <fastrtps/attributes/TopicAttributes.h>
#include <fastrtps/subscriber/SubscriberHistory.h>
#include <fastrtps/qos/LivelinessChangedStatus.h>
#include <fastrtps/types/TypesBase.h>

Expand All @@ -46,6 +45,8 @@
#include <fastdds/subscriber/SubscriberImpl.hpp>
#include <rtps/history/ITopicPayloadPool.h>

#include <fastdds/subscriber/history/DataReaderHistory.hpp>

using eprosima::fastrtps::types::ReturnCode_t;

namespace eprosima {
Expand Down Expand Up @@ -328,7 +329,7 @@ class DataReaderImpl
DataReaderQos qos_;

//!History
fastrtps::SubscriberHistory history_;
detail::DataReaderHistory history_;

//!Listener
DataReaderListener* listener_ = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
#include <fastdds/dds/topic/TypeSupport.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>

#include <fastrtps/subscriber/SubscriberHistory.h>
#include <fastrtps/types/TypesBase.h>

#include <fastdds/subscriber/DataReaderImpl.hpp>
#include <fastdds/subscriber/DataReaderImpl/DataReaderLoanManager.hpp>
#include <fastdds/subscriber/DataReaderImpl/StateFilter.hpp>
#include <fastdds/subscriber/DataReaderImpl/SampleInfoPool.hpp>
#include <fastdds/subscriber/DataReaderImpl/SampleLoanManager.hpp>
#include <fastdds/subscriber/history/DataReaderHistory.hpp>

#include <fastdds/rtps/common/CacheChange.h>
#include <fastdds/rtps/reader/RTPSReader.h>
Expand All @@ -51,7 +51,7 @@ namespace detail {
struct ReadTakeCommand
{
using ReturnCode_t = eprosima::fastrtps::types::ReturnCode_t;
using history_type = eprosima::fastrtps::SubscriberHistory;
using history_type = eprosima::fastdds::dds::detail::DataReaderHistory;
using CacheChange_t = eprosima::fastrtps::rtps::CacheChange_t;
using RTPSReader = eprosima::fastrtps::rtps::RTPSReader;
using WriterProxy = eprosima::fastrtps::rtps::WriterProxy;
Expand Down
Loading