|
| 1 | +/* |
| 2 | + * |
| 3 | + * Copyright (c) 2019 Google LLC. |
| 4 | + * All rights reserved. |
| 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 | +#ifndef SOFTWARE_UPDATE_MANAGER_IMPL_H |
| 20 | +#define SOFTWARE_UPDATE_MANAGER_IMPL_H |
| 21 | + |
| 22 | +#if WEAVE_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER |
| 23 | + |
| 24 | +#include <Weave/DeviceLayer/internal/GenericSoftwareUpdateManagerImpl.h> |
| 25 | +#include <Weave/DeviceLayer/internal/GenericSoftwareUpdateManagerImpl_BDX.h> |
| 26 | + |
| 27 | +namespace nl { |
| 28 | +namespace Weave { |
| 29 | +namespace DeviceLayer { |
| 30 | + |
| 31 | +/** |
| 32 | + * Concrete implementation of the SoftwareUpdateManager singleton object for the |
| 33 | + * ESP32 platforms. |
| 34 | + */ |
| 35 | +class SoftwareUpdateManagerImpl final |
| 36 | + : public SoftwareUpdateManager, |
| 37 | + public Internal::GenericSoftwareUpdateManagerImpl<SoftwareUpdateManagerImpl>, |
| 38 | + public Internal::GenericSoftwareUpdateManagerImpl_BDX<SoftwareUpdateManagerImpl> |
| 39 | +{ |
| 40 | + // Allow the SoftwareUpdateManager interface class to delegate method calls to |
| 41 | + // the implementation methods provided by this class. |
| 42 | + friend class SoftwareUpdateManager; |
| 43 | + |
| 44 | + // Allow the GenericSoftwareUpdateManagerImpl base class to access helper methods |
| 45 | + // and types defined on this class. |
| 46 | + friend class Internal::GenericSoftwareUpdateManagerImpl<SoftwareUpdateManagerImpl>; |
| 47 | + |
| 48 | + // Allow the GenericSoftwareUpdateManagerImpl_BDX base class to access helper methods |
| 49 | + // and types defined on this class. |
| 50 | + friend class Internal::GenericSoftwareUpdateManagerImpl_BDX<SoftwareUpdateManagerImpl>; |
| 51 | + |
| 52 | +public: |
| 53 | + |
| 54 | + // ===== Members for internal use by the following friends. |
| 55 | + |
| 56 | + friend ::nl::Weave::DeviceLayer::SoftwareUpdateManager & SoftwareUpdateMgr(void); |
| 57 | + friend SoftwareUpdateManagerImpl & SoftwareUpdateMgrImpl(void); |
| 58 | + |
| 59 | + static SoftwareUpdateManagerImpl sInstance; |
| 60 | + |
| 61 | +private: |
| 62 | + // ===== Members that implement the SoftwareUpdateManager abstract interface. |
| 63 | + |
| 64 | + WEAVE_ERROR _Init(void); |
| 65 | + |
| 66 | +}; |
| 67 | + |
| 68 | +/** |
| 69 | + * Returns a reference to the public interface of the SoftwareUpdateManager singleton object. |
| 70 | + * |
| 71 | + * Internal components should use this to access features of the SoftwareUpdateManager object |
| 72 | + * that are common to all platforms. |
| 73 | + */ |
| 74 | +inline SoftwareUpdateManager & SoftwareUpdateMgr(void) |
| 75 | +{ |
| 76 | + return SoftwareUpdateManagerImpl::sInstance; |
| 77 | +} |
| 78 | + |
| 79 | +/** |
| 80 | + * Returns the platform-specific implementation of the SoftwareUpdateManager singleton object. |
| 81 | + * |
| 82 | + * Internal components can use this to gain access to features of the SoftwareUpdateManager |
| 83 | + * that are specific to the ESP32 platform. |
| 84 | + */ |
| 85 | +inline SoftwareUpdateManagerImpl & SoftwareUpdateMgrImpl(void) |
| 86 | +{ |
| 87 | + return SoftwareUpdateManagerImpl::sInstance; |
| 88 | +} |
| 89 | + |
| 90 | +} // namespace DeviceLayer |
| 91 | +} // namespace Weave |
| 92 | +} // namespace nl |
| 93 | + |
| 94 | +#endif // WEAVE_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER |
| 95 | +#endif // SOFTWARE_UPDATE_MANAGER_IMPL_H |
0 commit comments