3 posts / 0 new
Last post
Last seen: 10 months 1 week ago
Joined: 08/03/2021
Posts: 6

Using the DDS Modern C++ API 6.1.0

I'm trying to use rti::topic::find_topics() to get all the local topics from my local domain participant but I can't get the correct syntax.

The following throws the runtime exception: Can't create an AnyTopic from a native topic. Try a typed Topic<T> instead

    std::vector<dds::topic::AnyTopic> topics;
    uint32_t topicCount = rti::topic::find_topics(participant, std::back_inserter(topics));

While this gives a various compilation errors:

    std::vector<dds::topic::Topic<dds::core::xtypes::DynamicData>> topics;
    uint32_t topicCount = rti::topic::find_topics(participant, std::back_inserter(topics));

Are there any concrete examples of rti::topic::find_topics() with DynamicData available?

I've been unable to find any.


Last seen: 2 weeks 9 hours ago
Joined: 04/02/2013
Posts: 179


You have to use 

topic = dds::topic::find<dds::topic::Topic<dds::core::xtypes::DynamicData>>(participant, topic_name).

There is a limitation when the topic is created from an XML file that causes the exception you saw in find_topics().

Last seen: 1 month 2 days ago
Joined: 05/26/2022
Posts: 1

I get an error when attempting to use the line above.

dds::topic::find<dds::topic::Topic<dds::core::xtypes::DynamicData>>(participant, "MyTopic");

error: ‘find’ is not a member of ‘dds::topic’

I also attempted to use it how its defined in tthe API reference:

dds::topic::Topic::find(participant, "MyTopic");

But this also results in an error:

dds::topic::Topic::find(participant, "MyTopic");

error: ‘template<class T, template<class Q> class DELEGATE> class dds::topic::Topic’ used without template arguments

dds::topic::Topic<dds::topic::Topic<dds::core::xtypes::DynamicData>>::find(participant, "MyTopic");

error: ‘find’ is not a member of ‘dds::topic::Topic<dds::topic::Topic<rti::core::xtypes::DynamicDataImpl> >’

What is the correct usage for this call?