Class RTPSDomain

Class Documentation

class RTPSDomain

Class RTPSDomain,it manages the creation and destruction of RTPSParticipant RTPSWriter and RTPSReader. It stores a list of all created RTPSParticipant. It has only static methods.

Public Static Functions

static FASTDDS_EXPORTED_API void set_filewatch_thread_config (const fastdds::rtps::ThreadSettings &watch_thread, const fastdds::rtps::ThreadSettings &callback_thread)

Method to set the configuration of the threads created by the file watcher for the environment file. In order for these settings to take effect, this method must be called before the first call to createParticipant.

Parameters:
  • watch_thread – Settings for the thread watching the environment file.

  • callback_thread – Settings for the thread executing the callback when the environment file changed.

static FASTDDS_EXPORTED_API void stopAll ()

Method to shut down all RTPSParticipants, readers, writers, etc. It must be called at the end of the process to avoid memory leaks. It also shut downs the DomainRTPSParticipant.

Post:

After this call, all the pointers to RTPS entities are invalidated and their use may result in undefined behaviour.

static FASTDDS_EXPORTED_API RTPSParticipant * createParticipant (uint32_t domain_id, const RTPSParticipantAttributes &attrs, RTPSParticipantListener *plisten=nullptr)

Create a RTPSParticipant.

Warning

The returned pointer is invalidated after a call to removeRTPSParticipant() or stopAll(), so its use may result in undefined behaviour.

Parameters:
  • domain_id – DomainId to be used by the RTPSParticipant (80 by default).

  • attrsRTPSParticipant Attributes.

  • plisten – Pointer to the ParticipantListener.

Returns:

Pointer to the RTPSParticipant.

static FASTDDS_EXPORTED_API RTPSParticipant * createParticipant (uint32_t domain_id, bool enabled, const RTPSParticipantAttributes &attrs, RTPSParticipantListener *plisten=nullptr)

Create a RTPSParticipant.

Warning

The returned pointer is invalidated after a call to removeRTPSParticipant() or stopAll(), so its use may result in undefined behaviour.

Parameters:
Returns:

Pointer to the RTPSParticipant.

static RTPSParticipant *create_client_server_participant(uint32_t domain_id, bool enabled, const RTPSParticipantAttributes &attrs, RTPSParticipantListener *plisten = nullptr)

Create a RTPSParticipant as default server or client if ROS_MASTER_URI environment variable is set. It also configures ROS 2 Easy Mode IP if ROS2_EASY_MODE_URI environment variable is set and it was empty in the input attributes.

Warning

The returned pointer is invalidated after a call to removeRTPSParticipant() or stopAll(), so its use may result in undefined behaviour.

Parameters:
Returns:

Pointer to the RTPSParticipant.

static FASTDDS_EXPORTED_API RTPSWriter * createRTPSWriter (RTPSParticipant *p, WriterAttributes &watt, WriterHistory *hist, WriterListener *listen=nullptr)

Create a RTPSWriter in a participant.

Warning

The returned pointer is invalidated after a call to removeRTPSWriter() or stopAll(), so its use may result in undefined behaviour.

Parameters:
Returns:

Pointer to the created RTPSWriter.

static FASTDDS_EXPORTED_API RTPSWriter * createRTPSWriter (RTPSParticipant *p, const EntityId_t &entity_id, WriterAttributes &watt, WriterHistory *hist, WriterListener *listen=nullptr)

Create a RTPSWriter in a participant.

Warning

The returned pointer is invalidated after a call to removeRTPSWriter() or stopAll(), so its use may result in undefined behaviour.

Parameters:
  • p – Pointer to the RTPSParticipant.

  • entity_id – Specific entity id to use for the created writer.

  • watt – Writer Attributes.

  • hist – Pointer to the WriterHistory.

  • listen – Pointer to the WriterListener.

Returns:

Pointer to the created RTPSWriter.

static FASTDDS_EXPORTED_API bool removeRTPSWriter (RTPSWriter *writer)

Remove a RTPSWriter.

Parameters:

writer – Pointer to the writer you want to remove.

Returns:

True if correctly removed.

static FASTDDS_EXPORTED_API RTPSReader * createRTPSReader (RTPSParticipant *p, ReaderAttributes &ratt, ReaderHistory *hist, ReaderListener *listen=nullptr)

Create a RTPSReader in a participant.

Warning

The returned pointer is invalidated after a call to removeRTPSReader() or stopAll(), so its use may result in undefined behaviour.

Parameters:
Returns:

Pointer to the created RTPSReader.

static FASTDDS_EXPORTED_API RTPSReader * createRTPSReader (RTPSParticipant *p, ReaderAttributes &ratt, const std::shared_ptr< IPayloadPool > &payload_pool, ReaderHistory *hist, ReaderListener *listen=nullptr)

Create a RTPReader in a participant using a custom payload pool.

Warning

The returned pointer is invalidated after a call to removeRTPSReader() or stopAll(), so its use may result in undefined behaviour.

Parameters:
Returns:

Pointer to the created RTPSReader.

static FASTDDS_EXPORTED_API RTPSReader * createRTPSReader (RTPSParticipant *p, const EntityId_t &entity_id, ReaderAttributes &ratt, const std::shared_ptr< IPayloadPool > &payload_pool, ReaderHistory *hist, ReaderListener *listen=nullptr)

Create a RTPSReader in a participant using a custom payload pool.

Warning

The returned pointer is invalidated after a call to removeRTPSReader() or stopAll(), so its use may result in undefined behaviour.

Parameters:
Returns:

Pointer to the created RTPSReader.

static FASTDDS_EXPORTED_API bool removeRTPSReader (RTPSReader *reader)

Remove a RTPSReader.

Parameters:

reader – Pointer to the reader you want to remove.

Returns:

True if correctly removed.

static FASTDDS_EXPORTED_API bool removeRTPSParticipant (RTPSParticipant *p)

Remove a RTPSParticipant and delete all its associated Writers, Readers, resources, etc.

Parameters:

p[in] Pointer to the RTPSParticipant;

Returns:

True if correct.

static FASTDDS_EXPORTED_API bool get_library_settings (fastdds::LibrarySettings &library_settings)

Get the library settings.

Parameters:

library_settingsLibrarySettings reference where the settings are returned.

Returns:

True.

static FASTDDS_EXPORTED_API bool set_library_settings (const fastdds::LibrarySettings &library_settings)

Set the library settings-.

Parameters:

library_settingsLibrarySettings to be set.

Returns:

False if there is any RTPSParticipant already created. True if correctly set.