Skip to content

Commit b4fc09e

Browse files
committed
Switch AtomicWriteState to enum class
1 parent 344e28c commit b4fc09e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

examples/thermostat/thermostat-common/include/atomic-write-manager.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ namespace app {
2828
namespace Clusters {
2929
namespace Thermostat {
3030

31-
enum AtomicWriteState
31+
enum class AtomicWriteState
3232
{
33-
kAtomicWriteState_Closed = 0,
34-
kAtomicWriteState_Open,
33+
Closed = 0,
34+
Open,
3535
};
3636

3737
class ThermostatAtomicWriteManager : public AtomicWriteManager
@@ -158,7 +158,7 @@ class ThermostatAtomicWriteManager : public AtomicWriteManager
158158

159159
struct AtomicWriteSession
160160
{
161-
AtomicWriteState state = kAtomicWriteState_Closed;
161+
AtomicWriteState state = AtomicWriteState::Closed;
162162
ScopedNodeId nodeId = ScopedNodeId();
163163
EndpointId endpointId = kInvalidEndpointId;
164164
};

examples/thermostat/thermostat-common/src/atomic-write-manager.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void ThermostatAtomicWriteManager::OnTimerExpired(EndpointId endpoint)
146146
{
147147

148148
auto atomicWriteState = mAtomicWriteSessions[i];
149-
if (atomicWriteState.state == kAtomicWriteState_Open && atomicWriteState.endpointId == endpoint)
149+
if (atomicWriteState.state == AtomicWriteState::Open && atomicWriteState.endpointId == endpoint)
150150
{
151151
if (mDelegate != nullptr)
152152
{
@@ -185,7 +185,7 @@ bool ThermostatAtomicWriteManager::InWrite(const std::optional<AttributeId> attr
185185

186186
if (ep < ArraySize(mAtomicWriteSessions))
187187
{
188-
inAtomicWrite = mAtomicWriteSessions[ep].state == kAtomicWriteState_Open;
188+
inAtomicWrite = mAtomicWriteSessions[ep].state == AtomicWriteState::Open;
189189
}
190190
return inAtomicWrite;
191191
}
@@ -352,7 +352,7 @@ bool ThermostatAtomicWriteManager::BeginWrite(chip::app::CommandHandler * comman
352352
DataModel::List<const AtomicAttributeStatusStruct::Type>(attributeStatuses.data(), attributeStatuses.size());
353353
if (status == Status::Success)
354354
{
355-
SetWriteState(endpoint, GetSourceScopedNodeId(commandObj), kAtomicWriteState_Open);
355+
SetWriteState(endpoint, GetSourceScopedNodeId(commandObj), AtomicWriteState::Open);
356356
timeout = std::min(timeoutRequest, timeout);
357357
response.timeout = MakeOptional(timeout.count());
358358
ScheduleTimer(endpoint, timeout);
@@ -481,15 +481,15 @@ bool ThermostatAtomicWriteManager::RollbackWrite(chip::app::CommandHandler * com
481481
void ThermostatAtomicWriteManager::ResetWrite(EndpointId endpoint)
482482
{
483483
ClearTimer(endpoint);
484-
SetWriteState(endpoint, ScopedNodeId(), kAtomicWriteState_Closed);
484+
SetWriteState(endpoint, ScopedNodeId(), AtomicWriteState::Closed);
485485
}
486486

487487
void ThermostatAtomicWriteManager::ResetWrite(FabricIndex fabricIndex)
488488
{
489489
for (size_t i = 0; i < ArraySize(mAtomicWriteSessions); ++i)
490490
{
491491
auto atomicWriteState = mAtomicWriteSessions[i];
492-
if (atomicWriteState.state == kAtomicWriteState_Open && atomicWriteState.nodeId.GetFabricIndex() == fabricIndex)
492+
if (atomicWriteState.state == AtomicWriteState::Open && atomicWriteState.nodeId.GetFabricIndex() == fabricIndex)
493493
{
494494
ResetWrite(atomicWriteState.endpointId);
495495
}

0 commit comments

Comments
 (0)