c++ : how to discover any subscribed topics and topics properties name and type

4 posts / 0 new
Last post
Offline
Last seen: 2 years 6 months ago
Joined: 07/01/2021
Posts: 3
c++ : how to discover any subscribed topics and topics properties name and type

hi
according to documentation, we can find any data writer that able to publish a topic. this ability is possible by subscribing to the "PublicationBuiltinTopicData" topic.
into the "PublicationBuiltinTopicData" topic just we can find topic_name and now we need to find the discovered topic properties name and properties type.
is there any way to access from topic_name to topic_variables?

Organization:
Howard's picture
Offline
Last seen: 1 day 15 hours ago
Joined: 11/29/2012
Posts: 565

The type_code is a member of PublicationBuiltinTopicData.

To learn about TypeCodes, please start here:

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/api/connext_dds/api_cpp/group__DDSTypeCodeModule.html

Then you would use the TypeCodes with the DynamicData API to create DataReaders for the discovered datatype.  See Section 3.8 of the Users Manual. And the API docs here:

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/api/connext_dds/api_cpp/group__DDSDynamicDataModule.html

Offline
Last seen: 2 years 6 months ago
Joined: 07/01/2021
Posts: 3

thank you, Howard
the TypeCodes is not in to the "PublicationBuiltinTopicData" class . the "PublicationBuiltinTopicData" has "type" method and "type" method returns "DynamicType" and do not return "Type_Code" variable and "DDS_TypeCode" object.

the "Type_Code" method is a member of the "DDS_PublicationBuiltinTopicData" class. and "DDS_PublicationBuiltinTopicData" is a part of CPP API.

my new problem is that when I add "RTI_CPP" compilation definition the compiler makes some error and can not compile my application .bellow is the compilation errors :

 

-->  /Applications/DDS/rti_connext_dds-6.0.0/include/ndds/ndds_config_c.h:309: error: could not convert ‘{NDDS_CONFIG_LOG_VERBOSITY_ERROR, NDDS_CONFIG_LOG_CATEGORY_ALL, NDDS_CONFIG_LOG_PRINT_FORMAT_DEFAULT, 0, 0, -1, -1}’ from ‘<brace---enclosed initializer list>’ to ‘const native_type’ {aka ‘const DDS_LoggingQosPolicy’}
--> /Applications/DDS/rti_connext_dds-6.0.0/include/ndds/dds_c/dds_c_dynamicdata.h:107: error: could not convert ‘{0, -1, 1024, 1, DDS_DYNAMIC_DATA_STRING_ENCODING_UTF_8_KIND, 0}’ from ‘<brace-enclosed initializer list>’ to ‘DDS_DynamicDataProperty_t’
--> /Applications/DDS/rti_connext_dds-6.0.0/include/ndds/dds_c/dds_c_dynamicdata.h:153: error: could not convert ‘{0, 4294967295, 4294967295, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘DDS_DynamicDataTypeSerializationProperty_t’
/Applications/DDS/rti_connext_dds-6.0.0/include/ndds/hpp/rti/core/xtypes/DynamicDataProperty.hpp: In static member function ‘static void rti::core::DynamicDataTypeSerializationPropertyNativeAdapter::initialize(rti::core::PODNativeAdapter<DDS_DynamicDataTypeSerializationProperty_t>::native_type&)’:
/Applications/DDS/rti_connext_dds-6.0.0/include/ndds/dds_c/dds_c_dynamicdata.h:153:3: error: could not convert ‘{0, 4294967295, 4294967295, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘DDS_DynamicDataTypeSerializationProperty_t’
  153 |   }
      |   ^
      |   |
      |   <brace-enclosed initializer list>
/Applications/DDS/rti_connext_dds-6.0.0/include/ndds/hpp/rti/core/xtypes/DynamicDataProperty.hpp:53:13: note: in expansion of macro ‘DDS_DynamicDataTypeSerializationProperty_t_INITIALIZER’
   53 |             DDS_DynamicDataTypeSerializationProperty_t_INITIALIZER;
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Howard's picture
Offline
Last seen: 1 day 15 hours ago
Joined: 11/29/2012
Posts: 565

What programming language are you using?  Traditional C++ aka C++98?  Modern C++ aka C++11?  C?  You should not mix programming languages and try to invoke Modern C++ in a Traditional C++ or C application.

Traditional C++:

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/api/connext_dds/api_cpp/structDDS__PublicationBuiltinTopicData.html#aa1f6f4832c3fee58fcaa9cb7789

Modern C++:

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/api/connext_dds/api_cpp2/classdds_1_1topic_1_1PublicationBuiltinTopicData.html#aa4af5c32e3bc413bd263b709c367631d

It returns a DynamicType, which IS what you actually need.  In Traditional C++, you would have to use the TypeCode to create DynamicData, in ModernC++, you use a DynamicType to create DynamicData.

Please see this doc page for everything related to Dynamic Data and Types

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/api/connext_dds/api_cpp2/group__DDSXTypesModule.html

and this specifically

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/api/connext_dds/api_cpp2/classdds_1_1core_1_1xtypes_1_1DynamicData.html