Apollo 10.0
自动驾驶开放平台
interval_pool.h
浏览该文件的文档.
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
28namespace apollo {
29namespace data {
30
31struct Interval {
32 uint64_t begin_time;
33 uint64_t end_time;
34};
35
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;
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
The intervals collection class that organizes the intervals
void SetIntervalEventLogFilePath(const std::string &path, const std::string &task_id)
void AddInterval(const Interval &interval)
bool MessageFallIntoRange(const uint64_t msg_time)
Interval GetNextInterval() const
void LogIntervalEvent(const std::string &name, const std::string &description, const uint64_t msg_time, const uint64_t backward_time, const uint64_t forward_time) const
#define DECLARE_SINGLETON(classname)
Definition macros.h:52
class register implement
Definition arena_queue.h:37