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 <commits@restyled.io>
diff --git a/src/app/clusters/mode-base-server/mode-base-server.cpp b/src/app/clusters/mode-base-server/mode-base-server.cpp
index b5b8a40..cb55bc2 100644
--- a/src/app/clusters/mode-base-server/mode-base-server.cpp
+++ b/src/app/clusters/mode-base-server/mode-base-server.cpp
@@ -23,7 +23,6 @@
 #include <app/clusters/on-off-server/on-off-server.h>
 #include <app/reporting/reporting.h>
 #include <app/util/attribute-storage.h>
-#include <app/util/config.h>
 #include <platform/DiagnosticDataProvider.h>
 
 using namespace chip;
@@ -52,7 +51,7 @@
 
 Instance::~Instance()
 {
-    UnregisterInstance();
+    UnregisterThisInstance();
     chip::app::InteractionModelEngine::GetInstance()->UnregisterCommandHandler(this);
     unregisterAttributeAccessOverride(this);
 }
@@ -69,7 +68,7 @@
 
     ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->RegisterCommandHandler(this));
     VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE);
-    RegisterInstance();
+    RegisterThisInstance();
     ReturnErrorOnFailure(mDelegate->Init());
 
     // If the StartUpMode is set, the CurrentMode attribute SHALL be set to the StartUpMode value, when the server is powered up.
@@ -350,7 +349,7 @@
     return CHIP_ERROR_INCORRECT_STATE;
 }
 
-void Instance::RegisterInstance()
+void Instance::RegisterThisInstance()
 {
     if (!gModeBaseAliasesInstances.Contains(this))
     {
@@ -358,7 +357,7 @@
     }
 }
 
-void Instance::UnregisterInstance()
+void Instance::UnregisterThisInstance()
 {
     gModeBaseAliasesInstances.Remove(this);
 }
diff --git a/src/app/clusters/mode-base-server/mode-base-server.h b/src/app/clusters/mode-base-server/mode-base-server.h
index 10a2a97..ef88ee8 100644
--- a/src/app/clusters/mode-base-server/mode-base-server.h
+++ b/src/app/clusters/mode-base-server/mode-base-server.h
@@ -124,11 +124,12 @@
 private:
     Delegate * mDelegate;
 
-    EndpointId mEndpointId{};
-    ClusterId mClusterId{};
+    EndpointId mEndpointId;
+    ClusterId mClusterId;
 
     // Attribute data store
-    uint8_t mCurrentMode;
+    uint8_t mCurrentMode = 0; // This is a temporary value and may not be valid. We will change this to the value of the first
+                              // mode in the list at the start of the Init function to ensure that it represents a valid mode.
     DataModel::Nullable<uint8_t> mStartUpMode;
     DataModel::Nullable<uint8_t> mOnMode;
     uint32_t mFeature;
@@ -146,14 +147,14 @@
     CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;
 
     /**
-     * Register this ModeBase instance.
+     * Register this ModeBase instance in gModeBaseAliasesInstances.
      */
-    void RegisterInstance();
+    void RegisterThisInstance();
 
     /**
-     * Unregister this ModeBase instance.
+     * Unregister this ModeBase instance in gModeBaseAliasesInstances.
      */
-    void UnregisterInstance();
+    void UnregisterThisInstance();
 
     /**
      * Internal change-to-mode command handler function.