1 /* 2 * Copyright (c) 2021 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_SETTINGS_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_SETTINGS_H 18 19 #include <string> 20 #include <unordered_map> 21 22 #include "base/utils/macros.h" 23 24 namespace OHOS::Ace { 25 26 struct ACE_FORCE_EXPORT Settings { 27 public: 28 Settings() = default; 29 ~Settings() = default; 30 SetUsingSharedRuntimeSettings31 void SetUsingSharedRuntime(bool useSharedRuntime) 32 { 33 usingSharedRuntime = useSharedRuntime; 34 usePlatformAsUIThread = useSharedRuntime; 35 } 36 SetCustomParamsSettings37 void SetCustomParams(const std::string& key, const std::string& value) 38 { 39 customParams_[key] = value; 40 } 41 GetCustomParamsSettings42 const std::string& GetCustomParams(const std::string& key) 43 { 44 static std::string empty; 45 auto it = customParams_.find(key); 46 if (it != customParams_.end()) { 47 return it->second; 48 } 49 return empty; 50 } 51 52 bool usingSharedRuntime = false; 53 bool usePlatformAsUIThread = false; 54 bool useUIAsJSThread = false; 55 56 private: 57 std::unordered_map<std::string, std::string> customParams_; 58 }; 59 60 } // namespace OHOS::Ace 61 62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_SETTINGS_H 63