Create an Application ===================== .. highlight:: c The rest of this guide will walk you through the steps to create an application and will provide example code snippets. It assumes that you have defined your types (see :doc:`definedatatype`) and have used *rtiddsgen* to generate their support code (see :doc:`generatesupportcode`). Registry Configuration ---------------------- The :link_connextmicro_dds_api_c_up_one:`DomainParticipantFactory `, in addition to its standard role of creating and deleting *DomainParticipants*, contains the RT Registry that a new application registers with some necessary components. The |me| architecture defines a run-time (RT) component interface that provides a generic framework for organizing and extending functionality of an application. An RT component is created and deleted (only available in |me_micro|) with an RT component factory. Each RT component factory must be registered within an RT registry in order for its components to be usable by an application. |me| automatically registers components that provide necessary functionality. These include components for DDS *Writers* and *Readers*, the RTPS protocol, and the UDP transport. In addition, every DDS application must register three components: - **Writer History**. Queue of written samples of a *DataWriter*. Must be registered with the name "wh". - **Reader History**. Queue of received samples of a *DataReader*. Must be registered with the name "rh". - **Discovery (DPSE)**. Discovery component with static (DPSE) endpoint discovery. Example source: - Get the RT Registry from the :link_connextmicro_dds_api_c_up_one:`DomainParticipantFactory ` singleton: :: DDS_DomainParticipantFactory *factory = NULL; RT_Registry_T *registry = NULL; factory = DDS_DomainParticipantFactory_get_instance(); registry = DDS_DomainParticipantFactory_get_registry(factory); - Register the Writer History and Reader History components with the registry: :: /* Register Writer History */ if (!RT_Registry_register(registry, "wh", WHSM_HistoryFactory_get_interface(), NULL, NULL)) { /* failure */ } /* Register Reader History */ if (!RT_Registry_register(registry, "rh", RHSM_HistoryFactory_get_interface(), NULL, NULL)) { /* failure */ } Only one discovery component can be registered. Each has its own properties that can be configured upon registration. Please note that only DPSE can be registered in |me_cert|. Each has its own properties that can be configured upon registration. - Register :link_connextmicro_dds_api_c_up_one:`DPSE ` for dynamic participant, static endpoint discovery: :: struct DPSE_DiscoveryPluginProperty discovery_plugin_properties = DPSE_DiscoveryPluginProperty_INITIALIZER; /* Configure properties */ discovery_plugin_properties.participant_liveliness_assert_period.sec = 5; discovery_plugin_properties.participant_liveliness_assert_period.nanosec = 0; discovery_plugin_properties.participant_liveliness_lease_duration.sec = 30; discovery_plugin_properties.participant_liveliness_lease_duration.nanosec = 0; /* Register DPSE with updated properties */ if (!RT_Registry_register(registry, "dpse", DPSE_DiscoveryFactory_get_interface(), &discovery_plugin_properties._parent, NULL)) { printf("failed to register dpse\n"); goto done; }