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 RUNTIME_CONFIG_H 17 #define RUNTIME_CONFIG_H 18 19 #include <memory> 20 #include <mutex> 21 22 #include "iprocess_communicator.h" 23 #include "iprocess_system_api_adapter.h" 24 #include "store_types.h" 25 namespace DistributedDB { 26 class RuntimeConfig final { 27 public: 28 DB_API RuntimeConfig() = default; 29 DB_API ~RuntimeConfig() = default; 30 31 DB_API static DBStatus SetProcessLabel(const std::string &appId, const std::string &userId); 32 33 DB_API static DBStatus SetProcessCommunicator(const std::shared_ptr<IProcessCommunicator> &inCommunicator); 34 35 DB_API static DBStatus SetPermissionCheckCallback(const PermissionCheckCallbackV2 &callback); 36 37 DB_API static DBStatus SetPermissionCheckCallback(const PermissionCheckCallbackV3 &callback); 38 39 DB_API static DBStatus SetProcessSystemAPIAdapter(const std::shared_ptr<IProcessSystemApiAdapter> &adapter); 40 41 DB_API static void Dump(int fd, const std::vector<std::u16string> &args); 42 43 DB_API static DBStatus SetSyncActivationCheckCallback(const SyncActivationCheckCallback &callback); 44 45 DB_API static DBStatus NotifyUserChanged(); 46 47 DB_API static DBStatus SetSyncActivationCheckCallback(const SyncActivationCheckCallbackV2 &callback); 48 49 DB_API static DBStatus SetPermissionConditionCallback(const PermissionConditionCallback &callback); 50 51 DB_API static bool IsProcessSystemApiAdapterValid(); 52 53 private: 54 static std::mutex communicatorMutex_; 55 static std::mutex multiUserMutex_; 56 static std::shared_ptr<IProcessCommunicator> processCommunicator_; 57 }; 58 } // namespace DistributedDB 59 60 #endif // RUNTIME_CONFIG_H