1 /* 2 * Copyright (c) 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 SHAREDDATAMANAGER_H 17 #define SHAREDDATAMANAGER_H 18 19 #include <mutex> 20 #include <set> 21 22 enum class BrightnessMode { MANUAL = 0, AUTO, BRIGHTNESSMODE_MAX }; 23 24 enum class ChargeState { NOCHARGE = 0, CHARGING, CHARGESTATE_MAX }; 25 26 enum class SharedDataType { 27 BRIGHTNESS_VALUE, 28 BRIGHTNESS_MODE, 29 KEEP_SCREEN_ON, 30 BATTERY_STATUS, 31 BATTERY_LEVEL, 32 HEARTBEAT_VALUE, 33 SUMSTEP_VALUE, 34 VOLUME_VALUE, 35 PRESSURE_VALUE, 36 WEARING_STATE, 37 LANGUAGE, 38 LONGITUDE, 39 LATITUDE, 40 LAN, 41 REGION 42 }; 43 44 class SharedDataManager { 45 public: 46 using Checker = void (*)(); 47 48 const static int POSITIONPRECISION = 11; 49 50 // add a data change check function of the template class to automatically,remove duplicates 51 static void AddChecker(const Checker checker); 52 53 // to perform the check, it needs to be polled for 100ms 54 static void CheckTick(); 55 56 private: 57 static std::set<Checker> checkers; 58 static std::mutex mutex; 59 }; 60 61 #endif // SHAREDDATAMANAGER_H 62