Skip to content

Commit

Permalink
Fix the fake platform's implementation of ConfigurationManagerImpl. (#…
Browse files Browse the repository at this point in the history
…11638)

* Move the global methods to the implementation.
* Add ConfigurationManagerImpl::GetDefaultInstance, which is required by tests.
  • Loading branch information
harimau-qirex authored and pull[bot] committed Nov 14, 2023
1 parent 57ade85 commit 3949784
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/platform/fake/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ assert(chip_device_platform == "fake")
static_library("fake") {
sources = [
"CHIPDevicePlatformEvent.h",
"ConfigurationManagerImpl.cpp",
"ConfigurationManagerImpl.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
Expand Down
30 changes: 30 additions & 0 deletions src/platform/fake/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -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 <platform/ConfigurationManager.h>

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
11 changes: 3 additions & 8 deletions src/platform/fake/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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

0 comments on commit 3949784

Please sign in to comment.