• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     WIFI2WIFI_NONET,
29     WIFI2WIFI_QOE_BAD,
30     USER_CONNECT,
31 };
32 
33 class NetworkSelectorFactory {
34 public:
35     NetworkSelectorFactory();
36     using HandleFunc = std::unique_ptr<NetworkSelection::INetworkSelector> (NetworkSelectorFactory::*)();
37     using HandleFuncMap = std::map<int, HandleFunc>;
38 
39     /**
40      * get network selector by type
41      * @param networkSelectType
42      * @return the network selector
43      */
44     std::optional<std::unique_ptr<NetworkSelection::INetworkSelector>> GetNetworkSelector(
45         NetworkSelectType networkSelectType);
46 
47     /**
48      * the function to create autoConnect networkSelector
49      * @return the network selector
50      */
51     std::unique_ptr<NetworkSelection::INetworkSelector> CreateAutoConnectNetworkSelector();
52 
53     /**
54      * the function to create wifi2wifi networkSelector
55      * @return the network selector
56      */
57     std::unique_ptr<NetworkSelection::INetworkSelector> CreateWifi2WifiNetworkSelector();
58 
59     /**
60      * the function to create wifi2wifi no net networkSelector
61      * @return the network selector
62      */
63     std::unique_ptr<NetworkSelection::INetworkSelector> CreateWifi2WifiNoNetNetworkSelector();
64 
65     /**
66      * the function to create wifi2wifi qoes low networkSelector
67      * @return the network selector
68      */
69     std::unique_ptr<NetworkSelection::INetworkSelector> CreateWifi2WifiQoeSlowNetworkSelector();
70 private:
71     HandleFuncMap handleFuncMap;
72 };
73 }
74 
75 #endif
76