Skip to content

Commit

Permalink
Add setter API for SupportedModesManager
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 committed Aug 2, 2024
1 parent fb1d2d8 commit a416b48
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ModeSelect {
* This implementation statically defines the options.
*/

class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::SupportedModesManager
class StaticSupportedModesManager : public SupportedModesManager
{
using ModeOptionStructType = Structs::ModeOptionStruct::Type;
using storage_value_type = const ModeOptionStructType;
Expand All @@ -52,7 +52,7 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp
static const EndpointSpanPair supportedOptionsByEndpoints[MATTER_DM_MODE_SELECT_CLUSTER_SERVER_ENDPOINT_COUNT];

public:
static const StaticSupportedModesManager instance;
static StaticSupportedModesManager instance;

SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override;

Expand All @@ -61,13 +61,13 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp

~StaticSupportedModesManager(){};

StaticSupportedModesManager() {}
StaticSupportedModesManager() {
ModeSelect::setSupportedModesManager(&instance);
}

static inline const StaticSupportedModesManager & getStaticSupportedModesManagerInstance() { return instance; }
};

const SupportedModesManager * getSupportedModesManager();

} // namespace ModeSelect
} // namespace Clusters
} // namespace app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const StaticSupportedModesManager::EndpointSpanPair
EndpointSpanPair(1, Span<storage_value_type>(StaticSupportedModesManager::coffeeOptions)) // Options for Endpoint 1
};

const StaticSupportedModesManager StaticSupportedModesManager::instance = StaticSupportedModesManager();
StaticSupportedModesManager StaticSupportedModesManager::instance = StaticSupportedModesManager();

SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeOptionsProvider(EndpointId endpointId) const
{
Expand Down Expand Up @@ -76,8 +76,3 @@ Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointI
ChipLogProgress(Zcl, "Cannot find the mode %u", mode);
return Status::InvalidCommand;
}

const ModeSelect::SupportedModesManager * ModeSelect::getSupportedModesManager()
{
return &StaticSupportedModesManager::instance;
}
11 changes: 11 additions & 0 deletions src/app/clusters/mode-select-server/mode-select-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ using BootReasonType = GeneralDiagnostics::BootReasonEnum;

static InteractionModel::Status verifyModeValue(const EndpointId endpointId, const uint8_t newMode);

ModeSelect::SupportedModesManager *sSupportedModesManager = nullptr;

const SupportedModesManager * ModeSelect::getSupportedModesManager()
{
return sSupportedModesManager;
}

void ModeSelect::setSupportedModesManager(ModeSelect::SupportedModesManager * aSupportedModesManager)
{
sSupportedModesManager = aSupportedModesManager;
}
namespace {

inline bool areStartUpModeAndCurrentModeNonVolatile(EndpointId endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class SupportedModesManager
{

using ModeOptionStructType = Structs::ModeOptionStruct::Type;

public:
/**
* A class that can return the supported ModeOptions for a specific endpoint.
Expand Down Expand Up @@ -80,10 +79,13 @@ class SupportedModesManager
const ModeOptionStructType ** dataPtr) const = 0;

virtual ~SupportedModesManager() {}

};

const SupportedModesManager * getSupportedModesManager();

void setSupportedModesManager(SupportedModesManager * aSupportedModesManager);

} // namespace ModeSelect
} // namespace Clusters
} // namespace app
Expand Down

0 comments on commit a416b48

Please sign in to comment.