Apollo 10.0
自动驾驶开放平台
notifier_factory.cc
浏览该文件的文档.
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
18
19#include <string>
20
22#include "cyber/common/log.h"
25
26namespace apollo {
27namespace cyber {
28namespace transport {
29
30using common::GlobalData;
31
33 std::string notifier_type(ConditionNotifier::Type());
34 auto& g_conf = GlobalData::Instance()->Config();
35 if (g_conf.has_transport_conf() && g_conf.transport_conf().has_shm_conf() &&
36 g_conf.transport_conf().shm_conf().has_notifier_type()) {
37 notifier_type = g_conf.transport_conf().shm_conf().notifier_type();
38 }
39
40 ADEBUG << "notifier type: " << notifier_type;
41
42 if (notifier_type == MulticastNotifier::Type()) {
43 return CreateMulticastNotifier();
44 } else if (notifier_type == ConditionNotifier::Type()) {
45 return CreateConditionNotifier();
46 }
47
48 AINFO << "unknown notifier, we use default notifier: " << notifier_type;
49 return CreateConditionNotifier();
50}
51
52auto NotifierFactory::CreateConditionNotifier() -> NotifierPtr {
53 return ConditionNotifier::Instance();
54}
55
56auto NotifierFactory::CreateMulticastNotifier() -> NotifierPtr {
57 return MulticastNotifier::Instance();
58}
59
60} // namespace transport
61} // namespace cyber
62} // namespace apollo
#define ADEBUG
Definition log.h:41
#define AINFO
Definition log.h:42
NotifierBase * NotifierPtr
class register implement
Definition arena_queue.h:37