Apollo 10.0
自动驾驶开放平台
cyber_record_reader.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 "cyber/cyber.h"
21
22namespace apollo {
23namespace localization {
24namespace msf {
25
26using cyber::record::RecordReader;
27
29
31
33 const std::string &topic,
34 const std::function<void(const std::string &)> call_back) {
35 call_back_map_[topic] = call_back;
36 topics_.push_back(topic);
37}
38
39void CyberRecordReader::Read(const std::string &file_name) {
40 RecordReader reader(file_name);
42 while (reader.ReadMessage(&message)) {
43 auto itr = call_back_map_.find(message.channel_name);
44 if (itr != call_back_map_.end()) {
45 itr->second(message.content);
46 }
47 }
48}
49
50void CyberRecordReader::Read(const std::vector<std::string> &file_names) {
51 for (const std::string &file_name : file_names) {
52 Read(file_name);
53 }
54}
55
56} // namespace msf
57} // namespace localization
58} // namespace apollo
bool ReadMessage(RecordMessage *message, uint64_t begin_time=0, uint64_t end_time=std::numeric_limits< uint64_t >::max())
Read one message from reader.
void Subscribe(const std::string &topic, const std::function< void(const std::string &)> call_back)
void Read(const std::string &file_name)
class register implement
Definition arena_queue.h:37
Basic data struct of record message.
std::string content
The content of the message.
std::string channel_name
The channel name of the message.