Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / Darwin / ConnectivityManagerImpl.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2018 Nest Labs, Inc.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 #pragma once
20
21 #include <platform/ConnectivityManager.h>
22 #include <platform/internal/GenericConnectivityManagerImpl.h>
23 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
24 #include <platform/internal/GenericConnectivityManagerImpl_BLE.h>
25 #else
26 #include <platform/internal/GenericConnectivityManagerImpl_NoBLE.h>
27 #endif
28 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
29 #include <platform/internal/GenericConnectivityManagerImpl_Thread.h>
30 #else
31 #include <platform/internal/GenericConnectivityManagerImpl_NoThread.h>
32 #endif
33 #include <platform/internal/GenericConnectivityManagerImpl_NoWiFi.h>
34
35 namespace chip {
36 namespace Inet {
37 class IPAddress;
38 } // namespace Inet
39 } // namespace chip
40
41 namespace chip {
42 namespace DeviceLayer {
43
44 /**
45  * Concrete implementation of the ConnectivityManager singleton object for Darwin platforms.
46  */
47 class ConnectivityManagerImpl final : public ConnectivityManager,
48 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
49                                       public Internal::GenericConnectivityManagerImpl_BLE<ConnectivityManagerImpl>,
50 #else
51                                       public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
52 #endif
53 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
54                                       public Internal::GenericConnectivityManagerImpl_Thread<ConnectivityManagerImpl>,
55 #else
56                                       public Internal::GenericConnectivityManagerImpl_NoThread<ConnectivityManagerImpl>,
57 #endif
58                                       public Internal::GenericConnectivityManagerImpl_NoWiFi<ConnectivityManagerImpl>,
59                                       public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>
60 {
61     // Allow the ConnectivityManager interface class to delegate method calls to
62     // the implementation methods provided by this class.
63     friend class ConnectivityManager;
64
65 private:
66     // ===== Members that implement the ConnectivityManager abstract interface.
67
68     bool _HaveIPv4InternetConnectivity(void);
69     bool _HaveIPv6InternetConnectivity(void);
70     bool _HaveServiceConnectivity(void);
71     CHIP_ERROR _Init(void);
72     void _OnPlatformEvent(const ChipDeviceEvent * event);
73
74     // ===== Members for internal use by the following friends.
75
76     friend ConnectivityManager & ConnectivityMgr(void);
77     friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);
78
79     static ConnectivityManagerImpl sInstance;
80 };
81
82 inline bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void)
83 {
84     return false;
85 }
86
87 inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void)
88 {
89     return false;
90 }
91
92 inline bool ConnectivityManagerImpl::_HaveServiceConnectivity(void)
93 {
94     return _HaveServiceConnectivityViaThread();
95 }
96
97 /**
98  * Returns the public interface of the ConnectivityManager singleton object.
99  *
100  * chip applications should use this to access features of the ConnectivityManager object
101  * that are common to all platforms.
102  */
103 inline ConnectivityManager & ConnectivityMgr(void)
104 {
105     return ConnectivityManagerImpl::sInstance;
106 }
107
108 /**
109  * Returns the platform-specific implementation of the ConnectivityManager singleton object.
110  *
111  * chip applications can use this to gain access to features of the ConnectivityManager
112  * that are specific to the Darwin platform.
113  */
114 inline ConnectivityManagerImpl & ConnectivityMgrImpl(void)
115 {
116     return ConnectivityManagerImpl::sInstance;
117 }
118
119 } // namespace DeviceLayer
120 } // namespace chip