Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 2.15 KB

examples.rst

File metadata and controls

51 lines (38 loc) · 2.15 KB

Dynamic HelloWorld Examples

These are complete working examples that make use of dynamic types. You can explore them to find how this feature connects to the rest of Fast DDS, and learn how to integrate it in your own application.

DynamicHelloWorldExample

This example is in folder examples/cpp/dds/DynamicHelloWorldExample of the Fast DDS GitHub repository. It shows the use of DynamicType generation to provide the |TopicDataType|. This example is compatible with the classic HelloWorldExample.

As a quick reference, the following piece of code shows how the HelloWorld type is created using DynamicTypes:

.. literalinclude:: /../code/CodeTester.cpp
   :language: c++
   :start-after: //DYNAMIC_HELLO_WORLD_API
   :end-before: //!--
   :dedent: 8


DDSDynamicHelloWorldExample

This example uses the DDS API, and can be retrieve from folder examples/cpp/dds/DynamicHelloWorldExample of the Fast DDS GitHub repository. It shows a publisher that loads a type from an XML file, and shares it during discovery. The subscriber discovers the type using :ref:`discovery-time-data-typing`, and registers the discovered type on the |DomainParticipantListener::on_type_discovery-api| listener function.

TypeLookupService

This example uses the DDS API, and it is located in folder examples/cpp/dds/TypeLookupService of the Fast DDS GitHub repository. It is very similar to DDSDynamicHelloWorldExample, but the shared type is complex enough to require the TypeLookup Service due to the dependency of inner struct types. Specifically, it uses the |DomainParticipant::register_remote_type-api| approach with a callback.