Apollo 10.0
自动驾驶开放平台
publisher.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#ifndef CYBER_TRANSPORT_RTPS_PUBLISHER_H
17#define CYBER_TRANSPORT_RTPS_PUBLISHER_H
18
19#include <memory>
20#include <string>
21
22#include "fastdds/dds/domain/DomainParticipant.hpp"
23#include "fastdds/dds/domain/DomainParticipantFactory.hpp"
24#include "fastdds/dds/publisher/DataWriter.hpp"
25#include "fastdds/dds/publisher/DataWriterListener.hpp"
26#include "fastdds/dds/publisher/Publisher.hpp"
27#include "fastdds/dds/topic/Topic.hpp"
28#include "fastdds/dds/topic/TypeSupport.hpp"
29#include "cyber/proto/qos_profile.pb.h"
30#include "cyber/base/macros.h"
31#include "cyber/common/log.h"
35
36namespace apollo {
37namespace cyber {
38namespace transport {
39
40class Publisher;
41using PublisherPtr = std::shared_ptr<Publisher>;
42class Publisher {
43 public:
44 Publisher(const std::string& channel_name, const proto::QosProfile& qos,
45 eprosima::fastdds::dds::DomainParticipant* participant);
46 virtual ~Publisher();
47
48 bool Init();
49 bool Write(const UnderlayMessage& msg, bool is_topo_msg = false);
50 bool Write(const UnderlayMessage& msg, const MessageInfo& msg_info,
51 bool is_topo_msg = false);
52 void Shutdown();
53
54 private:
55 Publisher(const Publisher&) = delete;
56 Publisher& operator=(const Publisher&) = delete;
57 bool EnsureCreateTopic(const std::string& channel_name);
58
59 std::string channel_name_;
61 std::atomic<bool> shutdown_;
62
63 eprosima::fastdds::dds::DomainParticipant* participant_;
64 eprosima::fastdds::dds::Publisher* publisher_;
65 eprosima::fastdds::dds::Topic* topic_;
66 eprosima::fastdds::dds::DataWriter* writer_;
67};
68
69} // namespace transport
70} // namespace cyber
71} // namespace apollo
72
73#endif // CYBER_TRANSPORT_RTPS_PUBLISHER_H
bool Write(const UnderlayMessage &msg, bool is_topo_msg=false)
Definition publisher.cc:66
This class represents the structure UnderlayMessage defined by the user in the IDL file.
std::shared_ptr< Publisher > PublisherPtr
Definition publisher.h:41
class register implement
Definition arena_queue.h:37