Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / Linux / 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 Linux platforms.
22  */
23
24 #pragma once
25
26 #include <platform/internal/GenericConfigurationManagerImpl.h>
27
28 #include <platform/Linux/PosixConfig.h>
29
30 namespace chip {
31 namespace DeviceLayer {
32
33 /**
34  * Concrete implementation of the ConfigurationManager singleton object for the Linux 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();
54     CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf);
55     bool _CanFactoryReset();
56     void _InitiateFactoryReset();
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();
65     friend ConfigurationManagerImpl & ConfigurationMgrImpl();
66
67     static ConfigurationManagerImpl sInstance;
68
69     // ===== Private members reserved for use by this class only.
70
71     static void DoFactoryReset(intptr_t arg);
72 };
73
74 /**
75  * Returns the public interface of the ConfigurationManager singleton object.
76  *
77  * chip applications should use this to access features of the ConfigurationManager object
78  * that are common to all platforms.
79  */
80 inline ConfigurationManager & ConfigurationMgr()
81 {
82     return ConfigurationManagerImpl::sInstance;
83 }
84
85 /**
86  * Returns the platform-specific implementation of the ConfigurationManager singleton object.
87  *
88  * chip applications can use this to gain access to features of the ConfigurationManager
89  * that are specific to the ESP32 platform.
90  */
91 inline ConfigurationManagerImpl & ConfigurationMgrImpl()
92 {
93     return ConfigurationManagerImpl::sInstance;
94 }
95
96 } // namespace DeviceLayer
97 } // namespace chip