• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 DISTRIBUTEDDATAMGR_NETWORK_DELEGATE_H
17 #define DISTRIBUTEDDATAMGR_NETWORK_DELEGATE_H
18 
19 #include <memory>
20 #include <mutex>
21 
22 #include "executor_pool.h"
23 #include "visibility.h"
24 
25 namespace OHOS {
26 namespace DistributedData {
27 class NetworkDelegate {
28 public:
29     enum NetworkType {
30         NONE,
31         CELLULAR,
32         WIFI,
33         ETHERNET,
34         OTHER
35     };
36     API_EXPORT virtual ~NetworkDelegate() = default;
37     API_EXPORT static NetworkDelegate *GetInstance();
38     API_EXPORT static bool RegisterNetworkInstance(NetworkDelegate *instance);
39     virtual bool IsNetworkAvailable() = 0;
40     virtual void RegOnNetworkChange() = 0;
41     virtual void BindExecutor(std::shared_ptr<ExecutorPool> executors) = 0;
42     virtual NetworkType GetNetworkType(bool retrieve = false) = 0;
43 
44 private:
45     static NetworkDelegate *instance_;
46 };
47 } // namespace DistributedKv
48 } // namespace OHOS
49 #endif // DISTRIBUTEDDATAMGR_NETWORK_DELEGATE_H