Apollo
10.0
自动驾驶开放平台
livox_obserable_binder.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 APOLLO_LIVOX_OBSERABLE_BINDER_H
17
#define APOLLO_LIVOX_OBSERABLE_BINDER_H
18
19
#include <functional>
20
#include <memory>
21
#include <utility>
22
23
#include "
cyber/cyber.h
"
24
25
namespace
apollo
{
26
namespace
drivers {
27
namespace
lidar {
28
29
template
<
typename
... FuncArgs>
30
class
LivoxObserableBinder
{
31
public
:
32
using
FuncType
= std::shared_ptr<std::function<void(FuncArgs...)>>;
33
static
void
Callback
(FuncArgs... args);
34
35
static
void
RegisterCallback
(
FuncType
func);
36
37
static
FuncType
func_cb_
;
38
};
39
40
template
<
typename
... FuncArgs>
41
void
LivoxObserableBinder<FuncArgs...>::Callback
(FuncArgs... args) {
42
if
(func_cb_) {
43
(*func_cb_)(std::forward<FuncArgs>(args)...);
44
}
else
{
45
AERROR
<<
"Binder callback is empty"
;
46
}
47
}
48
49
template
<
typename
... FuncArgs>
50
void
LivoxObserableBinder<FuncArgs...>::RegisterCallback
(
51
LivoxObserableBinder::FuncType
func) {
52
func_cb_ = std::move(func);
53
}
54
55
template
<
typename
... FuncArgs>
56
std::shared_ptr<std::function<void(FuncArgs...)>>
57
LivoxObserableBinder
<FuncArgs...>::func_cb_ =
nullptr
;
58
59
}
// namespace lidar
60
}
// namespace drivers
61
}
// namespace apollo
62
#endif
// APOLLO_LIVOX_OBSERABLE_BINDER_H
apollo::drivers::lidar::LivoxObserableBinder
Definition
livox_obserable_binder.h:30
apollo::drivers::lidar::LivoxObserableBinder::Callback
static void Callback(FuncArgs... args)
Definition
livox_obserable_binder.h:41
apollo::drivers::lidar::LivoxObserableBinder::FuncType
std::shared_ptr< std::function< void(FuncArgs...)> > FuncType
Definition
livox_obserable_binder.h:32
apollo::drivers::lidar::LivoxObserableBinder::func_cb_
static FuncType func_cb_
Definition
livox_obserable_binder.h:37
apollo::drivers::lidar::LivoxObserableBinder::RegisterCallback
static void RegisterCallback(FuncType func)
Definition
livox_obserable_binder.h:50
cyber.h
AERROR
#define AERROR
Definition
log.h:44
apollo
class register implement
Definition
arena_queue.h:37
modules
drivers
lidar
livox
component
livox_obserable_binder.h