1 /*
2  * Copyright (C) 2021-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 OHOS_WIFI_NETWORK_SELECTOR_FACTORY_H
17 #define OHOS_WIFI_NETWORK_SELECTOR_FACTORY_H
18 
19 #include <memory>
20 #include <optional>
21 #include "network_selector_impl.h"
22 #include "wifi_errcode.h"
23 
24 namespace OHOS::Wifi {
25 enum class NetworkSelectType {
26     AUTO_CONNECT,
27     WIFI2WIFI
28 };
29 
30 class NetworkSelectorFactory {
31 public:
32     NetworkSelectorFactory();
33     using HandleFunc = std::unique_ptr<NetworkSelection::INetworkSelector> (NetworkSelectorFactory::*)();
34     using HandleFuncMap = std::map<int, HandleFunc>;
35 
36     /**
37      * get network selector by type
38      * @param networkSelectType
39      * @return the network selector
40      */
41     std::optional<std::unique_ptr<NetworkSelection::INetworkSelector>> GetNetworkSelector(
42         NetworkSelectType networkSelectType);
43 
44     /**
45      * the function to create autoConnect networkSelector
46      * @return the network selector
47      */
48     std::unique_ptr<NetworkSelection::INetworkSelector> CreateAutoConnectNetworkSelector();
49 
50     /**
51      * the function to create wifi2wifi networkSelector
52      * @return the network selector
53      */
54     std::unique_ptr<NetworkSelection::INetworkSelector> CreateWifi2WifiNetworkSelector();
55 private:
56     HandleFuncMap handleFuncMap;
57 };
58 }
59 
60 #endif
61