Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2020 Project CHIP Authors
4 : * Copyright (c) 2019 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 : /**
20 : * @file
21 : * Provides an generic implementation of ConnectivityManager features
22 : * for use on various platforms.
23 : */
24 :
25 : #pragma once
26 :
27 : namespace chip {
28 : namespace DeviceLayer {
29 : namespace Internal {
30 :
31 : /**
32 : * Provides a generic implementation of ConnectivityManager features that works on multiple platforms.
33 : *
34 : * This template contains implementations of select features from the ConnectivityManager abstract
35 : * interface that are suitable for use on all platforms. It is intended to be inherited (directly
36 : * or indirectly) by the ConnectivityManagerImpl class, which also appears as the template's ImplClass
37 : * parameter.
38 : */
39 : template <class ImplClass>
40 : class GenericConnectivityManagerImpl
41 : {
42 : public:
43 : // ===== Methods that implement the ConnectivityManager abstract interface.
44 :
45 : bool _IsUserSelectedModeActive();
46 : void _SetUserSelectedMode(bool val);
47 : uint16_t _GetUserSelectedModeTimeout();
48 : void _SetUserSelectedModeTimeout(uint16_t val);
49 : CHIP_ERROR _DisconnectNetwork();
50 :
51 : private:
52 : ImplClass * Impl() { return static_cast<ImplClass *>(this); }
53 : };
54 :
55 : template <class ImplClass>
56 : inline bool GenericConnectivityManagerImpl<ImplClass>::_IsUserSelectedModeActive()
57 : {
58 : return false;
59 : }
60 :
61 : template <class ImplClass>
62 : inline void GenericConnectivityManagerImpl<ImplClass>::_SetUserSelectedMode(bool val)
63 : {}
64 :
65 : template <class ImplClass>
66 : inline uint16_t GenericConnectivityManagerImpl<ImplClass>::_GetUserSelectedModeTimeout()
67 : {
68 : return 0;
69 : }
70 :
71 : template <class ImplClass>
72 : inline void GenericConnectivityManagerImpl<ImplClass>::_SetUserSelectedModeTimeout(uint16_t val)
73 : {}
74 :
75 : template <class ImplClass>
76 0 : inline CHIP_ERROR GenericConnectivityManagerImpl<ImplClass>::_DisconnectNetwork()
77 : {
78 0 : return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
79 : }
80 :
81 : } // namespace Internal
82 : } // namespace DeviceLayer
83 : } // namespace chip
|