1 /* 2 * Copyright (c) 2024 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 #include "input_windows_manager_mock.h" 17 18 namespace OHOS { 19 namespace MMI { 20 21 std::shared_ptr<IInputWindowsManager> IInputWindowsManager::instance_; 22 std::mutex IInputWindowsManager::mutex_; 23 GetInstance()24std::shared_ptr<IInputWindowsManager> IInputWindowsManager::GetInstance() 25 { 26 if (instance_ == nullptr) { 27 std::lock_guard<std::mutex> lock(mutex_); 28 if (instance_ == nullptr) { 29 instance_ = InputWindowsManagerMock::GetInstance(); 30 } 31 } 32 return instance_; 33 } 34 35 std::shared_ptr<InputWindowsManagerMock> InputWindowsManagerMock::instance_; 36 std::mutex InputWindowsManagerMock::mutex_; 37 GetInstance()38std::shared_ptr<InputWindowsManagerMock> InputWindowsManagerMock::GetInstance() 39 { 40 if (instance_ == nullptr) { 41 std::lock_guard<std::mutex> lock(mutex_); 42 if (instance_ == nullptr) { 43 instance_ = std::make_shared<InputWindowsManagerMock>(); 44 } 45 } 46 return instance_; 47 } 48 } // namespace MMI 49 } // namespace OHOS 50