在fastdds中查看participantQos.name
时间: 2024-05-08 09:21:49 浏览: 4
在 Fast DDS 中查看 Participant QoS 的名称可以使用以下代码:
```cpp
#include <fastrtps/participant/Participant.h>
#include <fastrtps/qos/ParticipantQos.h>
int main() {
// Create a Participant
eprosima::fastrtps::ParticipantAttributes participant_attributes;
eprosima::fastrtps::Participant* participant = eprosima::fastrtps::Domain::createParticipant(participant_attributes);
// Get the Participant QoS
eprosima::fastrtps::ParticipantQos participant_qos;
participant->get_qos(participant_qos);
// Get the name from the Participant QoS
std::string name = participant_qos.name().to_string();
// Print the name
std::cout << "Participant name: " << name << std::endl;
// Delete the Participant
eprosima::fastrtps::Domain::removeParticipant(participant);
return 0;
}
```
这个代码创建了一个 Fast DDS 参与者,并获取了参与者的 QoS,然后从 QoS 中获取了名称并打印出来。