From 2352204b64d7e7125fc74753789126b6ca7b7e7b Mon Sep 17 00:00:00 2001 From: Andy Salisbury Date: Wed, 10 Nov 2021 12:55:58 -0500 Subject: [PATCH] Fix the fake platform's implementation of ConfigurationManagerImpl. (#11638) * Move the global methods to the implementation. * Add ConfigurationManagerImpl::GetDefaultInstance, which is required by tests. --- src/platform/fake/BUILD.gn | 1 + .../fake/ConfigurationManagerImpl.cpp | 30 +++++++++++++++++++ src/platform/fake/ConfigurationManagerImpl.h | 11 ++----- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/platform/fake/ConfigurationManagerImpl.cpp diff --git a/src/platform/fake/BUILD.gn b/src/platform/fake/BUILD.gn index 93d4425e604f66..9c4d008f11300f 100644 --- a/src/platform/fake/BUILD.gn +++ b/src/platform/fake/BUILD.gn @@ -21,6 +21,7 @@ assert(chip_device_platform == "fake") static_library("fake") { sources = [ "CHIPDevicePlatformEvent.h", + "ConfigurationManagerImpl.cpp", "ConfigurationManagerImpl.h", "ConnectivityManagerImpl.cpp", "ConnectivityManagerImpl.h", diff --git a/src/platform/fake/ConfigurationManagerImpl.cpp b/src/platform/fake/ConfigurationManagerImpl.cpp new file mode 100644 index 00000000000000..abfaecbbe6dd44 --- /dev/null +++ b/src/platform/fake/ConfigurationManagerImpl.cpp @@ -0,0 +1,30 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * limitations under the License. + */ + +#include + +namespace chip { +namespace DeviceLayer { + +ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() +{ + static ConfigurationManagerImpl sInstance; + return sInstance; +} + +ConfigurationManager & ConfigurationMgr() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + +void SetConfigurationMgr(ConfigurationManager * configurationManager) {} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index cee37e551605a1..4d4cce0a0b9397 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -29,6 +29,9 @@ class ConfigurationManagerImpl : public ConfigurationManager { public: virtual ~ConfigurationManagerImpl() = default; + // NOTE: This method is required by the tests. + // This returns an instance of this class. + static ConfigurationManagerImpl & GetDefaultInstance(); private: CHIP_ERROR Init() override { return CHIP_NO_ERROR; } @@ -105,13 +108,5 @@ class ConfigurationManagerImpl : public ConfigurationManager // NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>. }; -ConfigurationManager & ConfigurationMgr() -{ - static ConfigurationManagerImpl sInstance; - return sInstance; -} - -void SetConfigurationMgr(ConfigurationManagerImpl * configurationManager) {} - } // namespace DeviceLayer } // namespace chip