collator.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_SENSOR_INTERNAL_COLLATOR_H_
00018 #define CARTOGRAPHER_SENSOR_INTERNAL_COLLATOR_H_
00019 
00020 #include <functional>
00021 #include <memory>
00022 #include <vector>
00023 
00024 #include "absl/container/flat_hash_map.h"
00025 #include "absl/container/flat_hash_set.h"
00026 #include "cartographer/sensor/collator_interface.h"
00027 #include "cartographer/sensor/data.h"
00028 #include "cartographer/sensor/internal/ordered_multi_queue.h"
00029 
00030 namespace cartographer {
00031 namespace sensor {
00032 
00033 class Collator : public CollatorInterface {
00034  public:
00035   Collator() {}
00036 
00037   Collator(const Collator&) = delete;
00038   Collator& operator=(const Collator&) = delete;
00039 
00040   void AddTrajectory(
00041       int trajectory_id,
00042       const absl::flat_hash_set<std::string>& expected_sensor_ids,
00043       const Callback& callback) override;
00044 
00045   void FinishTrajectory(int trajectory_id) override;
00046 
00047   void AddSensorData(int trajectory_id, std::unique_ptr<Data> data) override;
00048 
00049   void Flush() override;
00050 
00051   absl::optional<int> GetBlockingTrajectoryId() const override;
00052 
00053  private:
00054   // Queue keys are a pair of trajectory ID and sensor identifier.
00055   OrderedMultiQueue queue_;
00056 
00057   // Map of trajectory ID to all associated QueueKeys.
00058   absl::flat_hash_map<int, std::vector<QueueKey>> queue_keys_;
00059 };
00060 
00061 }  // namespace sensor
00062 }  // namespace cartographer
00063 
00064 #endif  // CARTOGRAPHER_SENSOR_INTERNAL_COLLATOR_H_


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35