Apollo  6.0
Open source self driving car software
fuel_monitor_manager.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 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 <memory>
20 #include <string>
21 #include <unordered_map>
22 
23 #include <boost/thread/shared_mutex.hpp>
24 
25 #include "cyber/common/macros.h"
28 
33 namespace apollo {
34 namespace dreamview {
35 
36 using FuelMonitorMap =
37  std::unordered_map<std::string, std::unique_ptr<FuelMonitor>>;
38 
40  public:
41  void RegisterFuelMonitor(const std::string& mode,
42  std::unique_ptr<FuelMonitor>&& fuel_monitor);
43 
44  void SetCurrentMode(const std::string& mode);
45 
46  // Getter
48 
49  private:
50  std::unordered_map<std::string, FuelMonitorMap> monitors_;
51  FuelMonitorMap* current_monitors_ = nullptr;
52  std::string current_mode_;
53  // Mutex to protect concurrent access to current_progress_json_.
54  // NOTE: Use boost until we have std version of rwlock support.
55  boost::shared_mutex mutex_;
56 
58 };
59 
60 } // namespace dreamview
61 } // namespace apollo
Definition: fuel_monitor_manager.h:39
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
void SetCurrentMode(const std::string &mode)
std::unordered_map< std::string, std::unique_ptr< FuelMonitor > > FuelMonitorMap
Definition: fuel_monitor_manager.h:37
void RegisterFuelMonitor(const std::string &mode, std::unique_ptr< FuelMonitor > &&fuel_monitor)