• 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 NETMANAGER_BASE_NETINTERFACE_H
17 #define NETMANAGER_BASE_NETINTERFACE_H
18 
19 #include <map>
20 
21 #include "net_interface_callback_observer.h"
22 #include "event_manager.h"
23 
24 namespace OHOS::NetManagerStandard {
25 class NetInterface final {
26 public:
27     uint64_t moduleId_ = 0;
28 
29 public:
30     NetInterface();
31     ~NetInterface() = default;
32 
33     [[nodiscard]] sptr<NetInterfaceCallbackObserver> GetObserver() const;
34 
35     [[nodiscard]] std::shared_ptr<EventManager> GetEventManager() const;
36 
37     static NetInterface *MakeNetInterface(std::shared_ptr<EventManager>& eventManager);
38 
39     static void DeleteNetInterface(NetInterface *netInterface);
40 
41 private:
42     sptr<NetInterfaceCallbackObserver> observer_;
43 
44     std::shared_ptr<EventManager> manager_{nullptr};
45 
46     explicit NetInterface(std::shared_ptr<EventManager>& eventManager);
47 };
48 
49 extern std::map<NetInterfaceCallbackObserver *, NetInterface *> NET_INTERFACES;
50 extern std::shared_mutex g_netInterfacesMutex;
51 } // namespace OHOS::NetManagerStandard
52 
53 #endif /* NETMANAGER_BASE_NETINTERFACE_H */
54