2.3. Participant¶
-
class
eprosima::is::sh::fastdds
::
Participant
¶ This class represents a FastDDS DomainParticipant within the Integration Service framework.
It includes a mapping of the topic names to their corresponding Dynamic Type representation, and also mappings to identify each topic with its type.
This class inherits from Fast DDS DomainParticipantListener class to scan for state changes on the DDS participant created by this Integration Service is::SystemHandle.
Public Functions
-
Participant
()¶ Construct a new Participant, with default values.
- Exceptions
DDSMiddlewareException
: If the DomainParticipant could not be created.
-
Participant
(const YAML::Node &config)¶ Construct a new Participant object with the user-provided parameters in the YAML configuration file.
file_path
: Specifies the path to the XML profile that will be used to configure the DomainParticipant. More information on how to write these XML profiles can be found here.profile_name
: Provide a name to search for within the profiles defined in the XML that corresponds to the configuration profile that we want this Participant to be configured with.
- Parameters
[in] config
: The configuration provided by the user. It must contain two keys in the YAML map:
- Exceptions
DDSMiddlewareException
: If the XML profile was incorrect and, thus, the DomainParticipant could not be created.
-
~Participant
()¶ Destroy the Participant object.
-
void
build_participant
(const fastdds::dds::DomainId_t &domain_id = 0)¶ Construct a Fast DDS DomainParticipant, given its DDS domain ID.
- Parameters
[in] domain_id
: The DDS domain ID for this participant.
- Exceptions
DDSMiddlewareException
: If the DomainParticipant could not be created.
-
fastdds::dds::DomainParticipant *
get_dds_participant
() const¶ Get the associate FastDDS DomainParticipant attribute.
- Return
The DDS participant.
-
void
register_dynamic_type
(const std::string &topic_name, const std::string &type_name, fastrtps::types::DynamicTypeBuilder *builder)¶ Register a Dynamic Type within the types map. Also, register the associated DDS topic.
- Parameters
[in] topic_name
: The topic name to be associated to the Dynamic Type.[in] type_name
: The type name to be registered in the factory.[in] builder
: A class that represents a builder for the desired Dynamic Type.
- Exceptions
DDSMiddlewareException
: If the type could not be registered.
-
fastrtps::types::DynamicData *
create_dynamic_data
(const std::string &topic_name) const¶ Create an empty dynamic data object for the specified topic.
- Return
The empty DynamicData for the required topic.
- Parameters
[in] topic_name
: The topic name.
- Exceptions
DDSMiddlewareException
: if the topic was not found or the type was not registered previously.
-
void
delete_dynamic_data
(fastrtps::types::DynamicData *data) const¶ Delete a certain dynamic data from the DomainParticipant database.
- Parameters
[in] data
: The dynamic data to be deleted.
-
const fastrtps::types::DynamicType *
get_dynamic_type
(const std::string &name) const¶ Get the dynamic type pointer associated to a certain key.
- Return
The pointer to the dynamic type if found, or
nullptr
otherwise.- Parameters
[in] name
: The key to find within the types map.
-
const std::string &
get_topic_type
(const std::string &topic) const¶ Get the type name associated to a certain topic.
- Return
A const reference to the topic type’s name.
- Parameters
[in] topic
: The topic whose type is wanted to be retrieved.
-
void
associate_topic_to_dds_entity
(fastdds::dds::Topic *topic, fastdds::dds::DomainEntity *entity)¶ Register a topic into the topics map.
- Note
This method is a workaround until
fastdds::dds::DomainParticipant::find_topic
gets implemented.- Parameters
[in] topic
: The name of the topic to register.[in] entity
: A pointer to the entity to be registered.
-
bool
dissociate_topic_from_dds_entity
(fastdds::dds::Topic *topic, fastdds::dds::DomainEntity *entity)¶ Unregister a topic from the topics map.
- Note
This method is a workaround until
fastdds::dds::DomainParticipant::find_topic
gets implemented.- Parameters
[in] topic
: The name of the topic to unregister.[in] entity
: A pointer to the entity to be unregistered.
-