Apollo  6.0
Open source self driving car software
interval_pool.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 
17 #pragma once
18 
19 #include <map>
20 #include <set>
21 #include <string>
22 #include <unordered_map>
23 #include <vector>
24 
25 #include "absl/strings/str_cat.h"
26 #include "cyber/common/macros.h"
27 
28 namespace apollo {
29 namespace data {
30 
31 struct Interval {
32  uint64_t begin_time;
33  uint64_t end_time;
34 };
35 
40 class IntervalPool {
41  public:
42  void AddInterval(const Interval& interval);
43  void AddInterval(const uint64_t begin_time, const uint64_t end_time);
44  void ReorgIntervals();
45  bool MessageFallIntoRange(const uint64_t msg_time);
46  void Reset();
47  void PrintIntervals() const;
48  Interval GetNextInterval() const;
49  void SetIntervalEventLogFilePath(const std::string& path,
50  const std::string& task_id) {
51  interval_event_log_file_path_ = absl::StrCat(path, "_", task_id);
52  }
53  void LogIntervalEvent(const std::string& name, const std::string& description,
54  const uint64_t msg_time, const uint64_t backward_time,
55  const uint64_t forward_time) const;
56 
57  private:
58  std::vector<Interval> pool_;
59  std::vector<Interval>::iterator pool_iter_;
60  std::set<uint64_t> accu_end_values_;
61  std::string interval_event_log_file_path_;
62 
64 };
65 
66 } // namespace data
67 } // namespace apollo
uint64_t end_time
Definition: interval_pool.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void SetIntervalEventLogFilePath(const std::string &path, const std::string &task_id)
Definition: interval_pool.h:49
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
uint64_t begin_time
Definition: interval_pool.h:32
The intervals collection class that organizes the intervals.
Definition: interval_pool.h:40
Definition: interval_pool.h:31