Apollo
11.0
自动驾驶开放平台
sub_listener.h
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2018 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
17
#ifndef CYBER_TRANSPORT_RTPS_SUB_LISTENER_H_
18
#define CYBER_TRANSPORT_RTPS_SUB_LISTENER_H_
19
20
#include <functional>
21
#include <iostream>
22
#include <memory>
23
#include <mutex>
24
#include <string>
25
26
#include "
cyber/transport/message/message_info.h
"
27
#include "
cyber/transport/rtps/underlay_message.h
"
28
#include "
cyber/transport/rtps/underlay_message_type.h
"
29
#include "fastrtps/Domain.h"
30
#include "fastrtps/subscriber/SampleInfo.h"
31
#include "fastrtps/subscriber/Subscriber.h"
32
#include "fastrtps/subscriber/SubscriberListener.h"
33
34
namespace
apollo
{
35
namespace
cyber {
36
namespace
transport {
37
38
class
SubListener;
39
using
SubListenerPtr
= std::shared_ptr<SubListener>;
40
41
class
SubListener
:
public
eprosima::fastrtps::SubscriberListener {
42
public
:
43
using
NewMsgCallback
= std::function<void(
44
uint64_t channel_id,
const
std::shared_ptr<std::string>& msg_str,
45
const
MessageInfo
& msg_info)>;
46
47
explicit
SubListener
(
const
NewMsgCallback
& callback);
48
virtual
~SubListener
();
49
50
void
onNewDataMessage
(eprosima::fastrtps::Subscriber* sub);
51
void
onSubscriptionMatched
(eprosima::fastrtps::Subscriber* sub,
52
eprosima::fastrtps::MatchingInfo& info);
// NOLINT
53
54
private
:
55
NewMsgCallback
callback_;
56
MessageInfo
msg_info_;
57
std::mutex mutex_;
58
};
59
60
}
// namespace transport
61
}
// namespace cyber
62
}
// namespace apollo
63
64
#endif
// CYBER_TRANSPORT_RTPS_SUB_LISTENER_H_
apollo::cyber::transport::MessageInfo
Definition
message_info.h:30
apollo::cyber::transport::SubListener
Definition
sub_listener.h:41
apollo::cyber::transport::SubListener::NewMsgCallback
std::function< void(uint64_t channel_id, const std::shared_ptr< std::string > &msg_str, const MessageInfo &msg_info)> NewMsgCallback
Definition
sub_listener.h:45
apollo::cyber::transport::SubListener::onSubscriptionMatched
void onSubscriptionMatched(eprosima::fastrtps::Subscriber *sub, eprosima::fastrtps::MatchingInfo &info)
Definition
sub_listener.cc:78
apollo::cyber::transport::SubListener::onNewDataMessage
void onNewDataMessage(eprosima::fastrtps::Subscriber *sub)
Definition
sub_listener.cc:32
apollo::cyber::transport::SubListener::~SubListener
virtual ~SubListener()
Definition
sub_listener.cc:30
message_info.h
apollo::cyber::transport::SubListenerPtr
std::shared_ptr< SubListener > SubListenerPtr
Definition
sub_listener.h:39
apollo
class register implement
Definition
arena_queue.h:37
underlay_message.h
underlay_message_type.h
cyber
transport
rtps
sub_listener.h