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 #ifndef WIFI_DIRECT_SCHEDULER_FACTORY_H 17 #define WIFI_DIRECT_SCHEDULER_FACTORY_H 18 19 #include <memory> 20 #include <wifi_direct_scheduler.h> 21 22 namespace OHOS::SoftBus { 23 class WifiDirectScheduler; 24 class WifiDirectSchedulerFactory { 25 public: GetInstance()26 static WifiDirectSchedulerFactory& GetInstance() 27 { 28 static WifiDirectSchedulerFactory instance; 29 return instance; 30 } 31 GetScheduler()32 WifiDirectScheduler& GetScheduler() 33 { 34 if (scheduler_ == nullptr) { 35 return WifiDirectScheduler::GetInstance(); 36 } 37 return *scheduler_; 38 } 39 Register(const std::shared_ptr<WifiDirectScheduler> & scheduler)40 void Register(const std::shared_ptr<WifiDirectScheduler> &scheduler) 41 { 42 scheduler_ = scheduler; 43 } 44 45 private: 46 std::shared_ptr<WifiDirectScheduler> scheduler_ = nullptr; 47 }; 48 } 49 #endif 50