Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / Darwin / ConfigurationManagerImpl.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 /**
19  *    @file
20  *          Provides an implementation of the ConfigurationManager object
21  *          for Darwin platforms.
22  */
23
24 #pragma once
25
26 #include <platform/internal/GenericConfigurationManagerImpl.h>
27
28 #include <platform/Darwin/PosixConfig.h>
29
30 namespace chip {
31 namespace DeviceLayer {
32
33 /**
34  * Concrete implementation of the ConfigurationManager singleton object for the Darwin platform.
35  */
36 class ConfigurationManagerImpl final : public ConfigurationManager,
37                                        public Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>,
38                                        private Internal::PosixConfig
39 {
40     // Allow the ConfigurationManager interface class to delegate method calls to
41     // the implementation methods provided by this class.
42     friend class ConfigurationManager;
43
44     // Allow the GenericConfigurationManagerImpl base class to access helper methods and types
45     // defined on this class.
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47     friend class Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>;
48 #endif
49
50 private:
51     // ===== Members that implement the ConfigurationManager public interface.
52
53     CHIP_ERROR _Init(void);
54     CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf);
55     bool _CanFactoryReset(void);
56     void _InitiateFactoryReset(void);
57     CHIP_ERROR _ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
58     CHIP_ERROR _WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value);
59
60     // NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>.
61
62     // ===== Members for internal use by the following friends.
63
64     friend ConfigurationManager & ConfigurationMgr(void);
65     friend ConfigurationManagerImpl & ConfigurationMgrImpl(void);
66
67     static ConfigurationManagerImpl sInstance;
68 };
69
70 /**
71  * Returns the public interface of the ConfigurationManager singleton object.
72  *
73  * chip applications should use this to access features of the ConfigurationManager object
74  * that are common to all platforms.
75  */
76 inline ConfigurationManager & ConfigurationMgr(void)
77 {
78     return ConfigurationManagerImpl::sInstance;
79 }
80
81 /**
82  * Returns the platform-specific implementation of the ConfigurationManager singleton object.
83  *
84  * chip applications can use this to gain access to features of the ConfigurationManager
85  * that are specific to the ESP32 platform.
86  */
87 inline ConfigurationManagerImpl & ConfigurationMgrImpl(void)
88 {
89     return ConfigurationManagerImpl::sInstance;
90 }
91
92 } // namespace DeviceLayer
93 } // namespace chip