Skip to content

Commit 80ce709

Browse files
committed
use getters instead of extern
1 parent 154ae8d commit 80ce709

4 files changed

+17
-7
lines changed

examples/chef/common/chef-rvc-mode-delegate.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::T
3737
using namespace chip::app::Clusters::RvcRunMode;
3838

3939
static std::unique_ptr<RvcRunModeDelegate> gRvcRunModeDelegate;
40-
std::unique_ptr<ModeBase::Instance> gRvcRunModeInstance;
40+
static std::unique_ptr<ModeBase::Instance> gRvcRunModeInstance;
41+
42+
chip::app::Clusters::ModeBase::Instance * getRvcRunModeInstance()
43+
{
44+
return gRvcRunModeInstance.get();
45+
}
4146

4247
CHIP_ERROR RvcRunModeDelegate::Init()
4348
{
@@ -63,15 +68,15 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
6368
if (currentMode != RvcRunMode::ModeIdle)
6469
{ // Stop existing cycle when going from cleaning/mapping to idle.
6570
ChipLogProgress(DeviceLayer, "Stopping RVC cycle: %d", currentMode);
66-
gRvcOperationalStateDelegate->HandleStopStateCallback(err);
71+
getRvcOperationalStateDelegate()->HandleStopStateCallback(err);
6772
}
6873
}
6974
else
7075
{
7176
if (currentMode == RvcRunMode::ModeIdle)
7277
{ // Start a new cycle when going from idle to clening/mapping.
7378
ChipLogProgress(DeviceLayer, "Starting new RVC cycle: %d", NewMode);
74-
gRvcOperationalStateDelegate->HandleStartStateCallback(err);
79+
getRvcOperationalStateDelegate()->HandleStartStateCallback(err);
7580
}
7681
}
7782
if (err.IsEqual(OperationalState::GenericOperationalError(to_underlying(OperationalState::ErrorStateEnum::kNoError))))

examples/chef/common/chef-rvc-mode-delegate.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void Shutdown();
123123
} // namespace chip
124124

125125
#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
126-
extern std::unique_ptr<chip::app::Clusters::ModeBase::Instance> gRvcRunModeInstance;
126+
chip::app::Clusters::ModeBase::Instance * getRvcRunModeInstance();
127127

128128
chip::Protocols::InteractionModel::Status chefRvcRunModeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
129129
const EmberAfAttributeMetadata * attributeMetadata,

examples/chef/common/chef-rvc-operational-state-delegate.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ using chip::Protocols::InteractionModel::Status;
3232
#include <chef-rvc-mode-delegate.h>
3333
#endif // MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
3434

35-
std::unique_ptr<RvcOperationalStateDelegate> gRvcOperationalStateDelegate;
35+
static std::unique_ptr<RvcOperationalStateDelegate> gRvcOperationalStateDelegate;
3636
static std::unique_ptr<RvcOperationalState::Instance> gRvcOperationalStateInstance;
3737

38+
RvcOperationalStateDelegate * getRvcOperationalStateDelegate()
39+
{
40+
return gRvcOperationalStateDelegate.get();
41+
}
42+
3843
static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data);
3944

4045
DataModel::Nullable<uint32_t> RvcOperationalStateDelegate::GetCountdownTime()
@@ -234,7 +239,7 @@ static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data
234239
gRvcOperationalStateDelegate->mCountdownTime.SetNull();
235240

236241
#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
237-
gRvcRunModeInstance->UpdateCurrentMode(RvcRunMode::ModeIdle);
242+
getRvcRunModeInstance()->UpdateCurrentMode(RvcRunMode::ModeIdle);
238243
#endif // MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
239244
}
240245
}

examples/chef/common/chef-rvc-operational-state-delegate.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void Shutdown();
122122
} // namespace app
123123
} // namespace chip
124124

125-
extern std::unique_ptr<chip::app::Clusters::RvcOperationalState::RvcOperationalStateDelegate> gRvcOperationalStateDelegate;
125+
chip::app::Clusters::RvcOperationalState::RvcOperationalStateDelegate * getRvcOperationalStateDelegate();
126126

127127
chip::Protocols::InteractionModel::Status chefRvcOperationalStateWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
128128
const EmberAfAttributeMetadata * attributeMetadata,

0 commit comments

Comments
 (0)