Apollo 10.0
自动驾驶开放平台
apollo::cyber::transport::Participant类 参考

#include <participant.h>

apollo::cyber::transport::Participant 的协作图:

Public 成员函数

 Participant (const std::string &name, int send_port, eprosima::fastdds::dds::DomainParticipantListener *listener=nullptr)
 
virtual ~Participant ()
 
void Shutdown ()
 
bool Init ()
 
auto CreatePublisher (const std::string &channel_name, const proto::QosProfile &qos) -> std::shared_ptr< transport::Publisher >
 
auto CreateSubscriber (const std::string &channel_name, const proto::QosProfile &qos, const rtps::subsciber_callback &callback=nullptr) -> std::shared_ptr< Subscriber >
 
bool is_shutdown () const
 

详细描述

在文件 participant.h50 行定义.

构造及析构函数说明

◆ Participant()

apollo::cyber::transport::Participant::Participant ( const std::string &  name,
int  send_port,
eprosima::fastdds::dds::DomainParticipantListener *  listener = nullptr 
)

在文件 participant.cc42 行定义.

45 : shutdown_(false),
46 name_(name),
47 send_port_(send_port),
48 listener_(listener),
49 type_support_(new UnderlayMessageType()),
50 participant_(nullptr) {}

◆ ~Participant()

apollo::cyber::transport::Participant::~Participant ( )
virtual

在文件 participant.cc52 行定义.

52{}

成员函数说明

◆ CreatePublisher()

auto apollo::cyber::transport::Participant::CreatePublisher ( const std::string &  channel_name,
const proto::QosProfile qos 
) -> std::shared_ptr<transport::Publisher>

在文件 participant.cc71 行定义.

73 {
74 if (!participant_) {
75 AWARN << "DDSParticipant already released when the publisher created, "
76 "channel:"
77 << channel_name;
78 return nullptr;
79 }
80 auto publisher_ptr =
81 std::make_shared<transport::Publisher>(channel_name, qos, participant_);
82
83 RETURN_VAL_IF(!publisher_ptr->Init(), nullptr);
84 std::lock_guard<std::mutex> lock(publisher_mutex_);
85 publisher_map_.emplace(channel_name, publisher_ptr);
86 return publisher_ptr;
87}
#define RETURN_VAL_IF(condition, val)
Definition log.h:114
#define AWARN
Definition log.h:43

◆ CreateSubscriber()

auto apollo::cyber::transport::Participant::CreateSubscriber ( const std::string &  channel_name,
const proto::QosProfile qos,
const rtps::subsciber_callback callback = nullptr 
) -> std::shared_ptr<Subscriber>

在文件 participant.cc24 行定义.

27 {
28 if (!participant_) {
29 AWARN << "DDSParticipant already released when the subscriber created, "
30 "channel:"
31 << channel_name;
32 return nullptr;
33 }
34 auto subscriber_ptr = std::make_shared<transport::Subscriber>(
35 channel_name, qos, participant_, callback);
36 RETURN_VAL_IF(!subscriber_ptr->Init(), nullptr);
37 std::lock_guard<std::mutex> lock(subscriber_mutex_);
38 subscriber_map_.emplace(channel_name, subscriber_ptr);
39 return subscriber_ptr;
40}

◆ Init()

bool apollo::cyber::transport::Participant::Init ( )

在文件 participant.cc54 行定义.

54 {
55 return CreateParticipant(name_, send_port_, listener_);
56}

◆ is_shutdown()

bool apollo::cyber::transport::Participant::is_shutdown ( ) const
inline

在文件 participant.h68 行定义.

68{ return shutdown_.load(); }

◆ Shutdown()

void apollo::cyber::transport::Participant::Shutdown ( )

在文件 participant.cc58 行定义.

58 {
59 if (shutdown_.exchange(true)) {
60 return;
61 }
62
63 publisher_map_.clear();
64 subscriber_map_.clear();
65 if (listener_ != nullptr) {
66 delete listener_;
67 listener_ = nullptr;
68 }
69}

该类的文档由以下文件生成: