• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
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 #ifndef THERMAL_UTILS_THERMAL_FILES_H_
18 #define THERMAL_UTILS_THERMAL_FILES_H_
19 
20 #include <string>
21 #include <unordered_map>
22 
23 namespace android {
24 namespace hardware {
25 namespace thermal {
26 namespace V2_0 {
27 namespace implementation {
28 
29 class ThermalFiles {
30   public:
31     ThermalFiles() = default;
32     ~ThermalFiles() = default;
33     ThermalFiles(const ThermalFiles &) = delete;
34     void operator=(const ThermalFiles &) = delete;
35 
36     std::string getThermalFilePath(std::string_view thermal_name) const;
37     // Returns true if add was successful, false otherwise.
38     bool addThermalFile(std::string_view thermal_name, std::string_view path);
39     // If thermal_name is not found in the thermal names to path map, this will set
40     // data to empty and return false. If the thermal_name is found and its content
41     // is read, this function will fill in data accordingly then return true.
42     bool readThermalFile(std::string_view thermal_name, std::string *data) const;
getNumThermalFiles()43     size_t getNumThermalFiles() const { return thermal_name_to_path_map_.size(); }
44 
45   private:
46     std::unordered_map<std::string, std::string> thermal_name_to_path_map_;
47 };
48 
49 }  // namespace implementation
50 }  // namespace V2_0
51 }  // namespace thermal
52 }  // namespace hardware
53 }  // namespace android
54 
55 #endif  // THERMAL_UTILS_THERMAL_FILES_H_
56