find_topics()

3 posts / 0 new
Last post
Offline
Last seen: 3 years 3 months 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: 1 month 2 weeks ago
Joined: 04/02/2013
Posts: 196

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

Offline
Last seen: 2 years 6 months 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: https://community.rti.com/static/documentation/connext-dds/6.1.1/doc/api/connext_dds/api_cpp2/classdds_1_1topic_1_1Topic.html#a7520cb8425f188b5e2f5e44edf8107d6

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?