Skip to content

Commit 1535252

Browse files
hicklinrestyled-commits
authored andcommitted
Reorder mode base and op state (#28573)
* Reordered Mode Base functions. * Moved generic OpState cluster objects into one header file. * Reordered OperationalStateServer functions. * Moved OpState delegate in the server header file. * Updated the TestOperationalStateDelegate inctludes following the operational state delegate change in location. * Renamed TestOperationalStateDelegate.cpp -> src/app/tests/TestOperationalStateClusterObjects.cpp * Restyled by clang-format * Minor corrections following revision. * Moved the initialization of the mCurrentMode attribute from the constructor. * Restyled by clang-format * Improved the name of private Mode Base register functions. * Reverted change in the ifdef in the mode base init method. This was accendentally changed during a merge. --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 5124a64 commit 1535252

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/app/clusters/mode-base-server/mode-base-server.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <app/clusters/on-off-server/on-off-server.h>
2424
#include <app/reporting/reporting.h>
2525
#include <app/util/attribute-storage.h>
26-
#include <app/util/config.h>
2726
#include <platform/DiagnosticDataProvider.h>
2827

2928
using namespace chip;
@@ -52,7 +51,7 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClus
5251

5352
Instance::~Instance()
5453
{
55-
UnregisterInstance();
54+
UnregisterThisInstance();
5655
chip::app::InteractionModelEngine::GetInstance()->UnregisterCommandHandler(this);
5756
unregisterAttributeAccessOverride(this);
5857
}
@@ -69,7 +68,7 @@ CHIP_ERROR Instance::Init()
6968

7069
ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->RegisterCommandHandler(this));
7170
VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE);
72-
RegisterInstance();
71+
RegisterThisInstance();
7372
ReturnErrorOnFailure(mDelegate->Init());
7473

7574
// If the StartUpMode is set, the CurrentMode attribute SHALL be set to the StartUpMode value, when the server is powered up.
@@ -350,15 +349,15 @@ CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & attributePath, Attr
350349
return CHIP_ERROR_INCORRECT_STATE;
351350
}
352351

353-
void Instance::RegisterInstance()
352+
void Instance::RegisterThisInstance()
354353
{
355354
if (!gModeBaseAliasesInstances.Contains(this))
356355
{
357356
gModeBaseAliasesInstances.PushBack(this);
358357
}
359358
}
360359

361-
void Instance::UnregisterInstance()
360+
void Instance::UnregisterThisInstance()
362361
{
363362
gModeBaseAliasesInstances.Remove(this);
364363
}

src/app/clusters/mode-base-server/mode-base-server.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface
124124
private:
125125
Delegate * mDelegate;
126126

127-
EndpointId mEndpointId{};
128-
ClusterId mClusterId{};
127+
EndpointId mEndpointId;
128+
ClusterId mClusterId;
129129

130130
// Attribute data store
131-
uint8_t mCurrentMode;
131+
uint8_t mCurrentMode = 0; // This is a temporary value and may not be valid. We will change this to the value of the first
132+
// mode in the list at the start of the Init function to ensure that it represents a valid mode.
132133
DataModel::Nullable<uint8_t> mStartUpMode;
133134
DataModel::Nullable<uint8_t> mOnMode;
134135
uint32_t mFeature;
@@ -146,14 +147,14 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface
146147
CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;
147148

148149
/**
149-
* Register this ModeBase instance.
150+
* Register this ModeBase instance in gModeBaseAliasesInstances.
150151
*/
151-
void RegisterInstance();
152+
void RegisterThisInstance();
152153

153154
/**
154-
* Unregister this ModeBase instance.
155+
* Unregister this ModeBase instance in gModeBaseAliasesInstances.
155156
*/
156-
void UnregisterInstance();
157+
void UnregisterThisInstance();
157158

158159
/**
159160
* Internal change-to-mode command handler function.

0 commit comments

Comments
 (0)