collator.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
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 namespace cartographer {
20 namespace sensor {
21 
23  const int trajectory_id,
24  const std::unordered_set<string>& expected_sensor_ids,
25  const Callback callback) {
26  for (const auto& sensor_id : expected_sensor_ids) {
27  const auto queue_key = QueueKey{trajectory_id, sensor_id};
28  queue_.AddQueue(queue_key,
29  [callback, sensor_id](std::unique_ptr<Data> data) {
30  callback(sensor_id, std::move(data));
31  });
32  queue_keys_[trajectory_id].push_back(queue_key);
33  }
34 }
35 
36 void Collator::FinishTrajectory(const int trajectory_id) {
37  for (const auto& queue_key : queue_keys_[trajectory_id]) {
38  queue_.MarkQueueAsFinished(queue_key);
39  }
40 }
41 
42 void Collator::AddSensorData(const int trajectory_id, const string& sensor_id,
43  std::unique_ptr<Data> data) {
44  queue_.Add(QueueKey{trajectory_id, sensor_id}, std::move(data));
45 }
46 
48 
51 }
52 
53 } // namespace sensor
54 } // namespace cartographer
std::function< void(const string &, std::unique_ptr< Data >)> Callback
Definition: collator.h:34
OrderedMultiQueue queue_
Definition: collator.h:67
std::unordered_map< int, std::vector< QueueKey > > queue_keys_
Definition: collator.h:70
void AddTrajectory(int trajectory_id, const std::unordered_set< string > &expected_sensor_ids, Callback callback)
Definition: collator.cc:22
void AddQueue(const QueueKey &queue_key, Callback callback)
void AddSensorData(int trajectory_id, const string &sensor_id, std::unique_ptr< Data > data)
Definition: collator.cc:42
void MarkQueueAsFinished(const QueueKey &queue_key)
void Add(const QueueKey &queue_key, std::unique_ptr< Data > data)
void FinishTrajectory(int trajectory_id)
Definition: collator.cc:36
int GetBlockingTrajectoryId() const
Definition: collator.cc:49


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:38