Apollo 10.0
自动驾驶开放平台
subscriber.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_SUBSCRIBER_H
17#define CYBER_TRANSPORT_RTPS_SUBSCRIBER_H
18
19#include <functional>
20#include <memory>
21#include <string>
22
23#include "cyber/base/macros.h"
24
25#include "fastdds/dds/domain/DomainParticipant.hpp"
26#include "fastdds/dds/domain/DomainParticipantFactory.hpp"
27#include "fastdds/dds/subscriber/DataReader.hpp"
28#include "fastdds/dds/subscriber/DataReaderListener.hpp"
29#include "fastdds/dds/subscriber/Subscriber.hpp"
30#include "fastdds/dds/topic/Topic.hpp"
31#include "fastdds/dds/topic/TypeSupport.hpp"
32
33#include "cyber/proto/qos_profile.pb.h"
34
35#include "cyber/common/log.h"
41
42namespace apollo {
43namespace cyber {
44namespace transport {
46 public:
47 Subscriber(const std::string& name, const proto::QosProfile& qos,
48 eprosima::fastdds::dds::DomainParticipant* participant,
49 const rtps::subsciber_callback& callback);
50 virtual ~Subscriber();
51
52 bool Init();
53 void Shutdown();
54
55 private:
56 Subscriber(const Subscriber&) = delete;
57 Subscriber& operator=(const Subscriber&) = delete;
58 bool EnsureCreateTopic(const std::string& channel_name);
59
60 std::string channel_name_;
62 std::atomic<bool> shutdown_;
64
65 eprosima::fastdds::dds::SubscriberListener* subscriber_listener_;
66 eprosima::fastdds::dds::DomainParticipant* participant_;
67 eprosima::fastdds::dds::Subscriber* subscriber_;
68 eprosima::fastdds::dds::Topic* topic_;
69 eprosima::fastdds::dds::DataReader* reader_;
70};
71} // namespace transport
72} // namespace cyber
73} // namespace apollo
74
75#endif // CYBER_TRANSPORT_RTPS_SUBSCRIBER_H
std::function< void(const std::shared_ptr< std::string > &msg_str, uint64_t channel_id, const MessageInfo &msg_info)> subsciber_callback
Definition common_type.h:30
class register implement
Definition arena_queue.h:37