1 /* 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CALCULATION_CONFIG_PARSER_H 17 #define CALCULATION_CONFIG_PARSER_H 18 19 #include <vector> 20 #include <cJSON.h> 21 22 namespace OHOS { 23 namespace DisplayPowerMgr { 24 struct PointXy { 25 float x{-1.0f}; 26 float y{-1.0f}; 27 }; 28 struct PointXyz { 29 float x{-1.0f}; 30 float y{-1.0f}; 31 float z{-1.0f}; 32 }; 33 namespace CalculationConfig { 34 struct Data { 35 // default value 36 float defaultBrightness{35.0f}; 37 std::vector<PointXy> defaultPoints{ 38 { 0.0f, 5.0f }, { 5.0f, 17.0f }, { 20.0f, 30.0f }, 39 { 50.0f, 36.0f }, { 200.0f, 45.0f }, { 400.0f, 54.0f }, 40 { 1000.0f, 81.0f }, { 2000.0f, 123.0f }, { 7000.0f, 255.0f } 41 }; 42 }; 43 } 44 class CalculationConfigParser { 45 public: 46 CalculationConfigParser() = default; 47 virtual ~CalculationConfigParser() = default; 48 CalculationConfigParser(const CalculationConfigParser&) = delete; 49 CalculationConfigParser& operator=(const CalculationConfigParser&) = delete; 50 CalculationConfigParser(CalculationConfigParser&&) = delete; 51 CalculationConfigParser& operator=(CalculationConfigParser&&) = delete; 52 53 static bool ParseConfig(int displayId, CalculationConfig::Data& data); 54 static bool ParseConfigJsonRoot(int displayId, const std::string& fileContent, CalculationConfig::Data& data); 55 static void PrintConfig(int displayId, const CalculationConfig::Data& data); 56 }; 57 } // namespace DisplayPowerMgr 58 } // namespace OHOS 59 #endif // CALCULATION_CONFIG_PARSER_H 60