Apollo 10.0
自动驾驶开放平台
segment_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 <memory>
20#include <string>
21
23#include "cyber/common/log.h"
26
27namespace apollo {
28namespace cyber {
29namespace transport {
30
32
33auto SegmentFactory::CreateSegment(uint64_t channel_id) -> SegmentPtr {
34 std::string segment_type(XsiSegment::Type());
35 auto& shm_conf = GlobalData::Instance()->Config();
36 if (shm_conf.has_transport_conf() &&
37 shm_conf.transport_conf().has_shm_conf() &&
38 shm_conf.transport_conf().shm_conf().has_shm_type()) {
39 segment_type = shm_conf.transport_conf().shm_conf().shm_type();
40 }
41
42 ADEBUG << "segment type: " << segment_type;
43
44 if (segment_type == PosixSegment::Type()) {
45 return std::make_shared<PosixSegment>(channel_id);
46 }
47
48 return std::make_shared<XsiSegment>(channel_id);
49}
50
51} // namespace transport
52} // namespace cyber
53} // namespace apollo
static SegmentPtr CreateSegment(uint64_t channel_id)
#define ADEBUG
Definition log.h:41
std::shared_ptr< Segment > SegmentPtr
Definition segment.h:34
class register implement
Definition arena_queue.h:37