find_topics()

2 posts / 0 new
Last post
Offline
Last seen: 2 months 4 days ago
Joined: 08/03/2021
Posts: 6
find_topics()

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.

 

Organization:
Keywords:
Offline
Last seen: 2 weeks 1 day ago
Joined: 04/02/2013
Posts: 172

Hi,

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().