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

trying to create a dynamic data reader #183

Open
husnaini798 opened this issue Jul 4, 2023 · 0 comments
Open

trying to create a dynamic data reader #183

husnaini798 opened this issue Jul 4, 2023 · 0 comments

Comments

@husnaini798
Copy link

husnaini798 commented Jul 4, 2023

Hi,
I am currently having this issue in creating a DataReader for DynamicData. Though, it seems to create the reader2. But when I try to do

dds::sub::LoanedSamples<dds::core::xtypes::detail::DynamicData> samples2 = reader2.take();
or
dds::sub::LoanedSamples<dds::core::xtypes::detail::DynamicData> samples2 = reader2.select().state(dds::sub::status::SampleState::any()).read();

I get this error

In file included from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/Sample.hpp:22,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/org/opensplice/sub/AnyDataReaderDelegate.hpp:36,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/org/opensplice/sub/SubscriberDelegate.hpp:39,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/Subscriber.hpp:23,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/Subscriber.hpp:23,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/TAnyDataReader.hpp:22,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/TAnyDataReaderImpl.hpp:32,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/AnyDataReader.hpp:24,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/AnyDataReader.hpp:22,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/TQuery.hpp:24,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/Query.hpp:30,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/Query.hpp:22,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/Manipulators.hpp:28,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/DataReader.hpp:28,
                 from /opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/DataReader.hpp:21,
                 from /home/lnic/dev/platform-services.sean-OSPLAlarmsDynRmv/alarms/rule-evaluator/dynamic-topic-ospl.h:15,
                 from /home/lnic/dev/platform-services.sean-OSPLAlarmsDynRmv/alarms/rule-evaluator/dynamic-topic-ospl.cpp:1:
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/Sample.hpp: In instantiation of ‘class dds::sub::detail::Sample<dds::core::xtypes::detail::DynamicData>’:
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/core/Value.hpp:189:7:   required from ‘class dds::core::Value<dds::sub::detail::Sample<dds::core::xtypes::detail::DynamicData> >’
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/TSample.hpp:66:17:   required from ‘class dds::sub::Sample<dds::core::xtypes::detail::DynamicData, dds::sub::detail::Sample>’
/usr/include/c++/9/bits/stl_vector.h:333:35:   required from ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = dds::sub::Sample<dds::core::xtypes::detail::DynamicData, dds::sub::detail::Sample>; _Alloc = std::allocator<dds::sub::Sample<dds::core::xtypes::detail::DynamicData, dds::sub::detail::Sample> >]’
/usr/include/c++/9/bits/stl_vector.h:484:7:   required from ‘dds::sub::detail::LoanedSamples<T>::LoanedSamples() [with T = dds::core::xtypes::detail::DynamicData]’
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/LoanedSamplesImpl.hpp:40:57:   required from ‘dds::sub::LoanedSamples<T, DELEGATE>::LoanedSamples() [with T = dds::core::xtypes::detail::DynamicData; DELEGATE = dds::sub::detail::LoanedSamples]’
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/TDataReaderImpl.hpp:705:32:   required from ‘dds::sub::LoanedSamples<T> dds::sub::detail::DataReader<T>::take() [with T = dds::core::xtypes::detail::DynamicData]’
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/TDataReaderImpl.hpp:424:35:   required from ‘dds::sub::LoanedSamples<T> dds::sub::DataReader<T, DELEGATE>::take() [with T = dds::core::xtypes::detail::DynamicData; DELEGATE = dds::sub::detail::DataReader]’
/home/lnic/dev/platform-services.sean-OSPLAlarmsDynRmv/alarms/rule-evaluator/dynamic-topic-ospl.cpp:407:105:   required from here
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/Sample.hpp:124:7: error: ‘dds::sub::detail::Sample<T>::data_’ has incomplete type
  124 |     T data_;
      |       ^~~~~
In file included from /home/lnic/dev/platform-services.sean-OSPLAlarmsDynRmv/alarms/rule-evaluator/dynamic-topic-ospl.cpp:3:
/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/core/xtypes/detail/DynamicData.hpp:27:15: note: forward declaration of ‘class dds::core::xtypes::detail::DynamicData’
   27 |         class DynamicData;

The code that I am trying to use, with the headers included, looks like this below

#include "/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/core/xtypes/detail/DynamicData.hpp"
#include "/opt/HDE/x86_64.linux/include/dcps/C++/isocpp2/dds/sub/detail/LoanedSamples.hpp"

dds::topic::qos::TopicQos topicQos1
                 = dp.default_topic_qos()
                     << dds::core::policy::Durability::Transient()
                     << dds::core::policy::Reliability::Reliable();


//dds::sub::qos::DataReaderQos qs;
dds::sub::Subscriber subi(dp);
                if (topicVal == dds::core::null)
                    topicVal = dds::topic::Topic<dds::core::xtypes::detail::DynamicData>(dp, sample.data().topic_name(), sample.data().type_name(), topicQos1);//subi.default_datareader_qos().topic_qos() );//topicQos1 );//dds::core::QosProvider::Default().topic_qos());
                //reader1 = dds::sub::DataReader<dds::core::xtypes::detail::DynamicData>(subi, topicVal, topicQos1);//QosProvider::Default().datareader_qos("XXXXXXX::" + topicQos));
        dds::sub::DataReader<dds::core::xtypes::detail::DynamicData>  reader2(subi, topicVal, topicQos1);

                dds::sub::LoanedSamples<dds::core::xtypes::detail::DynamicData> samples2 = reader2.take();//select().state(dds::sub::status::SampleState::any()).read();;//reader1.read();//.select().state(dds::sub::status::SampleState::not_read()).take();;//reader1.take();

Now I can do the LoanedSample on ParticipantBuiltInTopicData like so

                    dds::sub::DataReader<dds::topic::ParticipantBuiltinTopicData> participantReader(dds::core::null);

            dds::sub::LoanedSamples<dds::topic::ParticipantBuiltinTopicData> samples = participantReader.take();
            for (dds::sub::LoanedSamples<dds::topic::ParticipantBuiltinTopicData>::const_iterator sample = samples.begin();
                sample < samples.end(); ++sample)
            {
   }

but cannot seem to do

                dds::sub::LoanedSamples<dds::core::xtypes::detail::DynamicData> samples2 = reader2.take();

Could anyone please assist?

Thanks.

Kind Regards,
Husnain Malik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant