diff --git a/docs/cluster_and_device_type_dev/cluster_and_device_type_dev.md b/docs/cluster_and_device_type_dev/cluster_and_device_type_dev.md index e016ea78b7b7bf..e2460ff5a0a2b2 100644 --- a/docs/cluster_and_device_type_dev/cluster_and_device_type_dev.md +++ b/docs/cluster_and_device_type_dev/cluster_and_device_type_dev.md @@ -107,9 +107,9 @@ ending in the cluster initialization code. EmberAfInitializeAttributes - ember attribute storage - for all attributes marked as “RAM” in the zap, sets defaults in the storage MatterPluginServerCallback - .h is a generated file, .cpp impl is done -in the server cluster code. Use this to setup the cluster and do attribute -overrides registerAttributeAccessOverride - use this if you want to handle -attribute reads and writes externally +in the server cluster code. Use this to setup the cluster and setup overrides in +chip::app::AttributeAccessInterfaceRegistry::Instance().Register - use this if +you want to handle attribute reads and writes externally Blue sections can be overridden. diff --git a/docs/upgrading.md b/docs/upgrading.md index 9a8c68987bec3b..5640c925aca5ec 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -69,10 +69,26 @@ independent of the InteractionModelEngine class. The following replacements exist: - `chip::app::InteractionModelEngine::RegisterCommandHandler` replaced by - `chip::app::CommandHandlerInterfaceRegistry::RegisterCommandHandler` + `chip::app::CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler` - `chip::app::InteractionModelEngine::UnregisterCommandHandler` replaced by - `chip::app::CommandHandlerInterfaceRegistry::UnregisterCommandHandler` + `chip::app::CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler` - `chip::app::InteractionModelEngine::FindCommandHandler` replaced by - `chip::app::CommandHandlerInterfaceRegistry::GetCommandHandler` + `chip::app::CommandHandlerInterfaceRegistry::Instance().GetCommandHandler` - `chip::app::InteractionModelEngine::UnregisterCommandHandlers` replaced by - `chip::app::CommandHandlerInterfaceRegistry::UnregisterAllCommandHandlersForEndpoint` + `chip::app::CommandHandlerInterfaceRegistry::Instance().UnregisterAllCommandHandlersForEndpoint` + +### AttributeAccessInterface registration and removal + +A new object exists for the attribute access interface registry, accessible as +`chip::app::AttributeHandlerInterfaceRegistry::Instance()` + +Replacements for methods are: + +- `registerAttributeAccessOverride` replaced by + `chip::app::AttributeAccessInterfaceRegistry::Instance().Register` +- `unregisterAttributeAccessOverride` replaced by + `chip::app::AttributeAccessInterfaceRegistry::Instance().Unregister` +- `unregisterAllAttributeAccessOverridesForEndpoint` replaced by + `chip::app::AttributeAccessInterfaceRegistry::Instance().UnregisterAllForEndpoint` +- `chip::app::GetAttributeAccessOverride` replaced by + `chip::app::AttributeAccessInterfaceRegistry::Instance().Get` diff --git a/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp index 41171d760d0048..90d1b9ebd115b0 100644 --- a/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp @@ -98,5 +98,5 @@ CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attr void MatterActionsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp index 9309b597db434f..e0fb68c95f647c 100644 --- a/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp @@ -173,6 +173,6 @@ void emberAfFanControlClusterInitCallback(EndpointId endpoint) { VerifyOrDie(mFanControlManager == nullptr); mFanControlManager = new FanControlManager(endpoint); - registerAttributeAccessOverride(mFanControlManager); + AttributeAccessInterfaceRegistry::Instance().Register(mFanControlManager); FanControl::SetDefaultDelegate(endpoint, mFanControlManager); } diff --git a/examples/bridge-app/asr/src/bridged-actions-stub.cpp b/examples/bridge-app/asr/src/bridged-actions-stub.cpp index 9e26bae9803fa1..73b7e8dd9877a0 100755 --- a/examples/bridge-app/asr/src/bridged-actions-stub.cpp +++ b/examples/bridge-app/asr/src/bridged-actions-stub.cpp @@ -97,5 +97,5 @@ CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attr void MatterActionsPluginServerInitCallback(void) { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp index 13ced6a2e1c7c6..768771555f3252 100644 --- a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp @@ -113,5 +113,5 @@ CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attr void MatterActionsPluginServerInitCallback(void) { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/examples/bridge-app/linux/bridged-actions-stub.cpp b/examples/bridge-app/linux/bridged-actions-stub.cpp index 00f6913b8012c5..580f4f2239bd1a 100644 --- a/examples/bridge-app/linux/bridged-actions-stub.cpp +++ b/examples/bridge-app/linux/bridged-actions-stub.cpp @@ -133,5 +133,5 @@ CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attr void MatterActionsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index c7e1dfb5a9c50b..d8446088a960a0 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -998,7 +998,7 @@ void ApplicationInit() } } - registerAttributeAccessOverride(&gPowerAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gPowerAttrAccess); } void ApplicationShutdown() {} diff --git a/examples/bridge-app/telink/src/DeviceCallbacks.cpp b/examples/bridge-app/telink/src/DeviceCallbacks.cpp index b0657e586fabc2..9e3273e7107472 100644 --- a/examples/bridge-app/telink/src/DeviceCallbacks.cpp +++ b/examples/bridge-app/telink/src/DeviceCallbacks.cpp @@ -101,5 +101,5 @@ CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attr void MatterActionsPluginServerInitCallback(void) { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/examples/chef/common/chef-fan-control-manager.cpp b/examples/chef/common/chef-fan-control-manager.cpp index 899892501bf4f1..b30f58db27aee7 100644 --- a/examples/chef/common/chef-fan-control-manager.cpp +++ b/examples/chef/common/chef-fan-control-manager.cpp @@ -141,6 +141,6 @@ void emberAfFanControlClusterInitCallback(EndpointId endpoint) { VerifyOrDie(!mFanControlManager); mFanControlManager = std::make_unique(endpoint); - registerAttributeAccessOverride(mFanControlManager.get()); + AttributeAccessInterfaceRegistry::Instance().Register(mFanControlManager.get()); FanControl::SetDefaultDelegate(endpoint, mFanControlManager.get()); } diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index 4f227b1f4a0436..46e1e35005ff70 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -32,7 +32,6 @@ #include "RpcServer.h" #endif -#include #include #include @@ -186,8 +185,8 @@ void ApplicationInit() ChipLogDetail(NotSpecified, "Fabric-Bridge: ApplicationInit()"); MatterEcosystemInformationPluginServerInitCallback(); - CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gAdministratorCommissioningCommandHandler); - registerAttributeAccessOverride(&gBridgedDeviceBasicInformationAttributes); + CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&gAdministratorCommissioningCommandHandler); + AttributeAccessInterfaceRegistry::Instance().Register(&gBridgedDeviceBasicInformationAttributes); #if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE InitRpcServer(kFabricBridgeServerPort); diff --git a/examples/log-source-app/linux/main.cpp b/examples/log-source-app/linux/main.cpp index 20ed1c54b5b215..d39e4431e86525 100644 --- a/examples/log-source-app/linux/main.cpp +++ b/examples/log-source-app/linux/main.cpp @@ -110,7 +110,7 @@ int main(int argc, char * argv[]) // Initialize device attestation config SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); - CommandHandlerInterfaceRegistry::RegisterCommandHandler(&GetLogProvider()); + CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&GetLogProvider()); chip::DeviceLayer::PlatformMgr().RunEventLoop(); diff --git a/examples/placeholder/linux/src/bridged-actions-stub.cpp b/examples/placeholder/linux/src/bridged-actions-stub.cpp index ea6e824738a857..d7abf17cd9106e 100644 --- a/examples/placeholder/linux/src/bridged-actions-stub.cpp +++ b/examples/placeholder/linux/src/bridged-actions-stub.cpp @@ -98,5 +98,5 @@ CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attr void MatterActionsPluginServerInitCallback(void) { - registerAttributeAccessOverride(&gAttrAccess); + chip::app::AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/examples/tv-app/android/java/AppImpl.cpp b/examples/tv-app/android/java/AppImpl.cpp index d04964ee5eb747..069d0f5185e62f 100644 --- a/examples/tv-app/android/java/AppImpl.cpp +++ b/examples/tv-app/android/java/AppImpl.cpp @@ -572,7 +572,7 @@ CHIP_ERROR InitVideoPlayerPlatform(jobject contentAppEndpointManager) { ContentAppCommandDelegate * delegate = new ContentAppCommandDelegate(contentAppEndpointManager, contentAppClusters[i].clusterId); - chip::app::CommandHandlerInterfaceRegistry::RegisterCommandHandler(delegate); + app::CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(delegate); ChipLogProgress(AppServer, "Registered command handler delegate for cluster %d", contentAppClusters[i].clusterId); } diff --git a/src/app/AttributeAccessInterface.h b/src/app/AttributeAccessInterface.h index 50e0812fb61c1a..f2985c4312b6b6 100644 --- a/src/app/AttributeAccessInterface.h +++ b/src/app/AttributeAccessInterface.h @@ -30,8 +30,8 @@ * endpoint or for all endpoints. * * Instances of AttributeAccessInterface that are registered via - * registerAttributeAccessOverride will be consulted before taking the normal - * attribute access codepath and can use that codepath as a fallback if desired. + * AttributeAccessInterfaceRegistry::Instance().Register will be consulted before taking the + * normal attribute access codepath and can use that codepath as a fallback if desired. */ namespace chip { namespace app { diff --git a/src/app/AttributeAccessInterfaceRegistry.cpp b/src/app/AttributeAccessInterfaceRegistry.cpp index b2c885fc4b2e2b..6af136699c3bdd 100644 --- a/src/app/AttributeAccessInterfaceRegistry.cpp +++ b/src/app/AttributeAccessInterfaceRegistry.cpp @@ -13,24 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "app/AttributeAccessInterface.h" #include #include -using namespace chip::app; - namespace { -AttributeAccessInterface * gAttributeAccessOverrides = nullptr; -AttributeAccessInterfaceCache gAttributeAccessInterfaceCache; +using chip::app::AttributeAccessInterface; // shouldUnregister returns true if the given AttributeAccessInterface should be // unregistered. template -void UnregisterMatchingAttributeAccessInterfaces(F shouldUnregister) +void UnregisterMatchingAttributeAccessInterfaces(F shouldUnregister, AttributeAccessInterface *& list_head) { AttributeAccessInterface * prev = nullptr; - AttributeAccessInterface * cur = gAttributeAccessOverrides; + AttributeAccessInterface * cur = list_head; while (cur) { AttributeAccessInterface * next = cur->GetNext(); @@ -43,7 +41,7 @@ void UnregisterMatchingAttributeAccessInterfaces(F shouldUnregister) } else { - gAttributeAccessOverrides = next; + list_head = next; } cur->SetNext(nullptr); @@ -60,22 +58,33 @@ void UnregisterMatchingAttributeAccessInterfaces(F shouldUnregister) } // namespace -void unregisterAttributeAccessOverride(AttributeAccessInterface * attrOverride) +namespace chip { +namespace app { + +AttributeAccessInterfaceRegistry & AttributeAccessInterfaceRegistry::Instance() +{ + static AttributeAccessInterfaceRegistry instance; + return instance; +} + +void AttributeAccessInterfaceRegistry::Unregister(AttributeAccessInterface * attrOverride) { - gAttributeAccessInterfaceCache.Invalidate(); - UnregisterMatchingAttributeAccessInterfaces([attrOverride](AttributeAccessInterface * entry) { return entry == attrOverride; }); + mAttributeAccessInterfaceCache.Invalidate(); + UnregisterMatchingAttributeAccessInterfaces([attrOverride](AttributeAccessInterface * entry) { return entry == attrOverride; }, + mAttributeAccessOverrides); } -void unregisterAllAttributeAccessOverridesForEndpoint(EmberAfDefinedEndpoint * definedEndpoint) +void AttributeAccessInterfaceRegistry::UnregisterAllForEndpoint(EndpointId endpointId) { + mAttributeAccessInterfaceCache.Invalidate(); UnregisterMatchingAttributeAccessInterfaces( - [endpoint = definedEndpoint->endpoint](AttributeAccessInterface * entry) { return entry->MatchesEndpoint(endpoint); }); + [endpointId](AttributeAccessInterface * entry) { return entry->MatchesEndpoint(endpointId); }, mAttributeAccessOverrides); } -bool registerAttributeAccessOverride(AttributeAccessInterface * attrOverride) +bool AttributeAccessInterfaceRegistry::Register(AttributeAccessInterface * attrOverride) { - gAttributeAccessInterfaceCache.Invalidate(); - for (auto * cur = gAttributeAccessOverrides; cur; cur = cur->GetNext()) + mAttributeAccessInterfaceCache.Invalidate(); + for (auto * cur = mAttributeAccessOverrides; cur; cur = cur->GetNext()) { if (cur->Matches(*attrOverride)) { @@ -83,20 +92,17 @@ bool registerAttributeAccessOverride(AttributeAccessInterface * attrOverride) return false; } } - attrOverride->SetNext(gAttributeAccessOverrides); - gAttributeAccessOverrides = attrOverride; + attrOverride->SetNext(mAttributeAccessOverrides); + mAttributeAccessOverrides = attrOverride; return true; } -namespace chip { -namespace app { - -app::AttributeAccessInterface * GetAttributeAccessOverride(EndpointId endpointId, ClusterId clusterId) +AttributeAccessInterface * AttributeAccessInterfaceRegistry::Get(EndpointId endpointId, ClusterId clusterId) { using CacheResult = AttributeAccessInterfaceCache::CacheResult; AttributeAccessInterface * cached = nullptr; - CacheResult result = gAttributeAccessInterfaceCache.Get(endpointId, clusterId, &cached); + CacheResult result = mAttributeAccessInterfaceCache.Get(endpointId, clusterId, &cached); switch (result) { case CacheResult::kDefinitelyUnused: @@ -106,17 +112,17 @@ app::AttributeAccessInterface * GetAttributeAccessOverride(EndpointId endpointId case CacheResult::kCacheMiss: default: // Did not cache yet, search set of AAI registered, and cache if found. - for (app::AttributeAccessInterface * cur = gAttributeAccessOverrides; cur; cur = cur->GetNext()) + for (app::AttributeAccessInterface * cur = mAttributeAccessOverrides; cur; cur = cur->GetNext()) { if (cur->Matches(endpointId, clusterId)) { - gAttributeAccessInterfaceCache.MarkUsed(endpointId, clusterId, cur); + mAttributeAccessInterfaceCache.MarkUsed(endpointId, clusterId, cur); return cur; } } // Did not find AAI registered: mark as definitely not using. - gAttributeAccessInterfaceCache.MarkUnused(endpointId, clusterId); + mAttributeAccessInterfaceCache.MarkUnused(endpointId, clusterId); } return nullptr; diff --git a/src/app/AttributeAccessInterfaceRegistry.h b/src/app/AttributeAccessInterfaceRegistry.h index f8452214cbf5f9..19cebd5edca594 100644 --- a/src/app/AttributeAccessInterfaceRegistry.h +++ b/src/app/AttributeAccessInterfaceRegistry.h @@ -16,39 +16,49 @@ #pragma once #include -#include +#include -/** - * Register an attribute access override. It will remain registered until the - * endpoint it's registered for is disabled (or until shutdown if it's - * registered for all endpoints) or until it is explicitly unregistered. - * Registration will fail if there is an already-registered override for the - * same set of attributes. - * - * @return false if there is an existing override that the new one would - * conflict with. In this case the override is not registered. - * @return true if registration was successful. - */ -bool registerAttributeAccessOverride(chip::app::AttributeAccessInterface * attrOverride); +namespace chip { +namespace app { -/** - * Unregister an attribute access override (for example if the object - * implementing AttributeAccessInterface is being destroyed). - */ -void unregisterAttributeAccessOverride(chip::app::AttributeAccessInterface * attrOverride); +class AttributeAccessInterfaceRegistry +{ +public: + /** + * Register an attribute access override. It will remain registered until the + * endpoint it's registered for is disabled (or until shutdown if it's + * registered for all endpoints) or until it is explicitly unregistered. + * Registration will fail if there is an already-registered override for the + * same set of attributes. + * + * @return false if there is an existing override that the new one would + * conflict with. In this case the override is not registered. + * @return true if registration was successful. + */ + bool Register(AttributeAccessInterface * attrOverride); -/** - * Unregister all attribute access interfaces that match this given endpoint. - */ -void unregisterAllAttributeAccessOverridesForEndpoint(EmberAfDefinedEndpoint * definedEndpoint); + /** + * Unregister an attribute access override (for example if the object + * implementing AttributeAccessInterface is being destroyed). + */ + void Unregister(AttributeAccessInterface * attrOverride); -namespace chip { -namespace app { + /** + * Unregister all attribute access interfaces that match this given endpoint. + */ + void UnregisterAllForEndpoint(EndpointId endpointId); -/** - * Get the registered attribute access override. nullptr when attribute access override is not found. - */ -AttributeAccessInterface * GetAttributeAccessOverride(EndpointId aEndpointId, ClusterId aClusterId); + /** + * Get the registered attribute access override. nullptr when attribute access override is not found. + */ + AttributeAccessInterface * Get(EndpointId aEndpointId, ClusterId aClusterId); + + static AttributeAccessInterfaceRegistry & Instance(); + +private: + AttributeAccessInterface * mAttributeAccessOverrides = nullptr; + AttributeAccessInterfaceCache mAttributeAccessInterfaceCache; +}; } // namespace app } // namespace chip diff --git a/src/app/CommandHandlerInterfaceRegistry.cpp b/src/app/CommandHandlerInterfaceRegistry.cpp index 74ea7d48d04955..01436853dd1a55 100644 --- a/src/app/CommandHandlerInterfaceRegistry.cpp +++ b/src/app/CommandHandlerInterfaceRegistry.cpp @@ -17,20 +17,19 @@ using namespace chip::app; -namespace { - -CommandHandlerInterface * gCommandHandlerList = nullptr; - -} - namespace chip { namespace app { -namespace CommandHandlerInterfaceRegistry { -void UnregisterAllHandlers() +CommandHandlerInterfaceRegistry & CommandHandlerInterfaceRegistry::Instance() +{ + static CommandHandlerInterfaceRegistry registry; + return registry; +} + +void CommandHandlerInterfaceRegistry::UnregisterAllHandlers() { - CommandHandlerInterface * handlerIter = gCommandHandlerList; + CommandHandlerInterface * handlerIter = mCommandHandlerList; // // Walk our list of command handlers and de-register them, before finally @@ -43,14 +42,14 @@ void UnregisterAllHandlers() handlerIter = nextHandler; } - gCommandHandlerList = nullptr; + mCommandHandlerList = nullptr; } -CHIP_ERROR RegisterCommandHandler(CommandHandlerInterface * handler) +CHIP_ERROR CommandHandlerInterfaceRegistry::RegisterCommandHandler(CommandHandlerInterface * handler) { VerifyOrReturnError(handler != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - for (auto * cur = gCommandHandlerList; cur; cur = cur->GetNext()) + for (auto * cur = mCommandHandlerList; cur; cur = cur->GetNext()) { if (cur->Matches(*handler)) { @@ -59,24 +58,23 @@ CHIP_ERROR RegisterCommandHandler(CommandHandlerInterface * handler) } } - handler->SetNext(gCommandHandlerList); - gCommandHandlerList = handler; + handler->SetNext(mCommandHandlerList); + mCommandHandlerList = handler; return CHIP_NO_ERROR; } -void UnregisterAllCommandHandlersForEndpoint(EndpointId endpointId) +void CommandHandlerInterfaceRegistry::UnregisterAllCommandHandlersForEndpoint(EndpointId endpointId) { - CommandHandlerInterface * prev = nullptr; - for (auto * cur = gCommandHandlerList; cur; cur = cur->GetNext()) + for (auto * cur = mCommandHandlerList; cur; cur = cur->GetNext()) { if (cur->MatchesEndpoint(endpointId)) { if (prev == nullptr) { - gCommandHandlerList = cur->GetNext(); + mCommandHandlerList = cur->GetNext(); } else { @@ -92,18 +90,18 @@ void UnregisterAllCommandHandlersForEndpoint(EndpointId endpointId) } } -CHIP_ERROR UnregisterCommandHandler(CommandHandlerInterface * handler) +CHIP_ERROR CommandHandlerInterfaceRegistry::UnregisterCommandHandler(CommandHandlerInterface * handler) { VerifyOrReturnError(handler != nullptr, CHIP_ERROR_INVALID_ARGUMENT); CommandHandlerInterface * prev = nullptr; - for (auto * cur = gCommandHandlerList; cur; cur = cur->GetNext()) + for (auto * cur = mCommandHandlerList; cur; cur = cur->GetNext()) { if (cur->Matches(*handler)) { if (prev == nullptr) { - gCommandHandlerList = cur->GetNext(); + mCommandHandlerList = cur->GetNext(); } else { @@ -121,9 +119,9 @@ CHIP_ERROR UnregisterCommandHandler(CommandHandlerInterface * handler) return CHIP_ERROR_KEY_NOT_FOUND; } -CommandHandlerInterface * GetCommandHandler(EndpointId endpointId, ClusterId clusterId) +CommandHandlerInterface * CommandHandlerInterfaceRegistry::GetCommandHandler(EndpointId endpointId, ClusterId clusterId) { - for (auto * cur = gCommandHandlerList; cur; cur = cur->GetNext()) + for (auto * cur = mCommandHandlerList; cur; cur = cur->GetNext()) { if (cur->Matches(endpointId, clusterId)) { @@ -134,6 +132,5 @@ CommandHandlerInterface * GetCommandHandler(EndpointId endpointId, ClusterId clu return nullptr; } -} // namespace CommandHandlerInterfaceRegistry } // namespace app } // namespace chip diff --git a/src/app/CommandHandlerInterfaceRegistry.h b/src/app/CommandHandlerInterfaceRegistry.h index 14e00335fd859d..1695b3e3b85864 100644 --- a/src/app/CommandHandlerInterfaceRegistry.h +++ b/src/app/CommandHandlerInterfaceRegistry.h @@ -19,29 +19,42 @@ namespace chip { namespace app { -namespace CommandHandlerInterfaceRegistry { -/// Remove the entire linked list of handlers -void UnregisterAllHandlers(); - -/// Add a new handler to the list of registered command handlers +/// Keeps track of a list of registered command handler interfaces /// -/// At most one command handler can exist for a given endpoint/cluster combination. Trying -/// to register conflicting handlers will result in a `CHIP_ERROR_INCORRECT_STATE` error. -CHIP_ERROR RegisterCommandHandler(CommandHandlerInterface * handler); - -/// Unregister all commandHandlers that `MatchesEndpoint` for the given endpointId. -void UnregisterAllCommandHandlersForEndpoint(EndpointId endpointId); - -/// Unregister a single handler. -/// -/// If the handler is not registered, a `CHIP_ERROR_KEY_NOT_FOUND` is returned. -CHIP_ERROR UnregisterCommandHandler(CommandHandlerInterface * handler); - -/// Find the command handler for the given endpoint/cluster combination or return -/// nullptr if no such command handler exists. -CommandHandlerInterface * GetCommandHandler(EndpointId endpointId, ClusterId clusterId); +/// NOTE: command handler interface objects are IntrusiveList elements (i.e. +/// their pointers are contained within). As a result, a command handler +/// may only ever be part of a single registry. +class CommandHandlerInterfaceRegistry +{ +public: + /// Remove the entire linked list of handlers + void UnregisterAllHandlers(); + + /// Add a new handler to the list of registered command handlers + /// + /// At most one command handler can exist for a given endpoint/cluster combination. Trying + /// to register conflicting handlers will result in a `CHIP_ERROR_INCORRECT_STATE` error. + CHIP_ERROR RegisterCommandHandler(CommandHandlerInterface * handler); + + /// Unregister all commandHandlers that `MatchesEndpoint` for the given endpointId. + void UnregisterAllCommandHandlersForEndpoint(EndpointId endpointId); + + /// Unregister a single handler. + /// + /// If the handler is not registered, a `CHIP_ERROR_KEY_NOT_FOUND` is returned. + CHIP_ERROR UnregisterCommandHandler(CommandHandlerInterface * handler); + + /// Find the command handler for the given endpoint/cluster combination or return + /// nullptr if no such command handler exists. + CommandHandlerInterface * GetCommandHandler(EndpointId endpointId, ClusterId clusterId); + + /// A global instance of a command handler registry + static CommandHandlerInterfaceRegistry & Instance(); + +private: + CommandHandlerInterface * mCommandHandlerList = nullptr; +}; -} // namespace CommandHandlerInterfaceRegistry } // namespace app } // namespace chip diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 639b590a16b345..80312a57873f43 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -110,9 +110,11 @@ void InteractionModelEngine::Shutdown() mpExchangeMgr->GetSessionManager()->SystemLayer()->CancelTimer(ResumeSubscriptionsTimerCallback, this); // TODO: individual object clears the entire command handler interface registry. - // This may not be expected. - CommandHandlerInterfaceRegistry::UnregisterAllHandlers(); - + // This may not be expected as IME does NOT own the command handler interface registry. + // + // This is to be cleaned up once InteractionModelEngine maintains a data model fully and + // the code-generation model can do its clear in its shutdown method. + CommandHandlerInterfaceRegistry::Instance().UnregisterAllHandlers(); mCommandResponderObjs.ReleaseAll(); mTimedHandlers.ForEachActiveObject([this](TimedHandler * obj) -> Loop { @@ -1682,7 +1684,7 @@ void InteractionModelEngine::DispatchCommand(CommandHandlerImpl & apCommandObj, TLV::TLVReader & apPayload) { CommandHandlerInterface * handler = - CommandHandlerInterfaceRegistry::GetCommandHandler(aCommandPath.mEndpointId, aCommandPath.mClusterId); + CommandHandlerInterfaceRegistry::Instance().GetCommandHandler(aCommandPath.mEndpointId, aCommandPath.mClusterId); if (handler) { diff --git a/src/app/WriteHandler.cpp b/src/app/WriteHandler.cpp index d19d3ae3b37d0a..8d4a82d11630c4 100644 --- a/src/app/WriteHandler.cpp +++ b/src/app/WriteHandler.cpp @@ -196,7 +196,7 @@ CHIP_ERROR WriteHandler::SendWriteResponse(System::PacketBufferTLVWriter && aMes void WriteHandler::DeliverListWriteBegin(const ConcreteAttributePath & aPath) { - if (auto * attrOverride = GetAttributeAccessOverride(aPath.mEndpointId, aPath.mClusterId)) + if (auto * attrOverride = AttributeAccessInterfaceRegistry::Instance().Get(aPath.mEndpointId, aPath.mClusterId)) { attrOverride->OnListWriteBegin(aPath); } @@ -204,7 +204,7 @@ void WriteHandler::DeliverListWriteBegin(const ConcreteAttributePath & aPath) void WriteHandler::DeliverListWriteEnd(const ConcreteAttributePath & aPath, bool writeWasSuccessful) { - if (auto * attrOverride = GetAttributeAccessOverride(aPath.mEndpointId, aPath.mClusterId)) + if (auto * attrOverride = AttributeAccessInterfaceRegistry::Instance().Get(aPath.mEndpointId, aPath.mClusterId)) { attrOverride->OnListWriteEnd(aPath, writeWasSuccessful); } diff --git a/src/app/clusters/access-control-server/access-control-server.cpp b/src/app/clusters/access-control-server/access-control-server.cpp index 316825bc91848c..321f7aa92a483a 100644 --- a/src/app/clusters/access-control-server/access-control-server.cpp +++ b/src/app/clusters/access-control-server/access-control-server.cpp @@ -479,6 +479,6 @@ void MatterAccessControlPluginServerInitCallback() { ChipLogProgress(DataManagement, "AccessControlCluster: initializing"); - registerAttributeAccessOverride(&sAttribute); + AttributeAccessInterfaceRegistry::Instance().Register(&sAttribute); GetAccessControl().AddEntryListener(sAttribute); } diff --git a/src/app/clusters/account-login-server/account-login-server.cpp b/src/app/clusters/account-login-server/account-login-server.cpp index 95d94fe9b995a5..347fac06a44a1d 100644 --- a/src/app/clusters/account-login-server/account-login-server.cpp +++ b/src/app/clusters/account-login-server/account-login-server.cpp @@ -261,5 +261,5 @@ bool emberAfAccountLoginClusterLogoutCallback(app::CommandHandler * commandObj, void MatterAccountLoginPluginServerInitCallback() { - registerAttributeAccessOverride(&gAccountLoginAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gAccountLoginAttrAccess); } diff --git a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp index a7b3eaed75fd7d..57a230de547743 100644 --- a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp +++ b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp @@ -209,5 +209,5 @@ bool emberAfAdministratorCommissioningClusterRevokeCommissioningCallback( void MatterAdministratorCommissioningPluginServerInitCallback() { ChipLogProgress(Zcl, "Initiating Admin Commissioning cluster."); - registerAttributeAccessOverride(&gAdminCommissioningAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAdminCommissioningAttrAccess); } diff --git a/src/app/clusters/air-quality-server/air-quality-server.cpp b/src/app/clusters/air-quality-server/air-quality-server.cpp index 811c4722c94fec..958d3783f72ca6 100644 --- a/src/app/clusters/air-quality-server/air-quality-server.cpp +++ b/src/app/clusters/air-quality-server/air-quality-server.cpp @@ -39,7 +39,7 @@ Instance::Instance(EndpointId aEndpointId, BitMask aFeature) : Instance::~Instance() { - unregisterAttributeAccessOverride(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR Instance::Init() @@ -47,7 +47,7 @@ CHIP_ERROR Instance::Init() // Check if the cluster has been selected in zap VerifyOrDie(emberAfContainsServer(mEndpointId, Id) == true); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } diff --git a/src/app/clusters/application-basic-server/application-basic-server.cpp b/src/app/clusters/application-basic-server/application-basic-server.cpp index 3841b81873660b..2dfaca6fbb719d 100644 --- a/src/app/clusters/application-basic-server/application-basic-server.cpp +++ b/src/app/clusters/application-basic-server/application-basic-server.cpp @@ -246,5 +246,5 @@ CHIP_ERROR ApplicationBasicAttrAccess::ReadAllowedVendorListAttribute(app::Attri void MatterApplicationBasicPluginServerInitCallback() { - registerAttributeAccessOverride(&gApplicationBasicAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gApplicationBasicAttrAccess); } diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.cpp b/src/app/clusters/application-launcher-server/application-launcher-server.cpp index ed6265e47c485b..da5314f380e607 100644 --- a/src/app/clusters/application-launcher-server/application-launcher-server.cpp +++ b/src/app/clusters/application-launcher-server/application-launcher-server.cpp @@ -495,5 +495,5 @@ bool emberAfApplicationLauncherClusterHideAppCallback(app::CommandHandler * comm void MatterApplicationLauncherPluginServerInitCallback() { - registerAttributeAccessOverride(&gApplicationLauncherAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gApplicationLauncherAttrAccess); } diff --git a/src/app/clusters/audio-output-server/audio-output-server.cpp b/src/app/clusters/audio-output-server/audio-output-server.cpp index 19d34b0ebb5718..ec71a56feb10db 100644 --- a/src/app/clusters/audio-output-server/audio-output-server.cpp +++ b/src/app/clusters/audio-output-server/audio-output-server.cpp @@ -244,5 +244,5 @@ bool emberAfAudioOutputClusterSelectOutputCallback(app::CommandHandler * command void MatterAudioOutputPluginServerInitCallback() { - registerAttributeAccessOverride(&gAudioOutputAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gAudioOutputAttrAccess); } diff --git a/src/app/clusters/basic-information/basic-information.cpp b/src/app/clusters/basic-information/basic-information.cpp index bd45a1035164b5..46b5034d7a50f8 100644 --- a/src/app/clusters/basic-information/basic-information.cpp +++ b/src/app/clusters/basic-information/basic-information.cpp @@ -476,6 +476,6 @@ bool IsLocalConfigDisabled() void MatterBasicInformationPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); PlatformMgr().SetDelegate(&gPlatformMgrDelegate); } diff --git a/src/app/clusters/bindings/bindings.cpp b/src/app/clusters/bindings/bindings.cpp index d7c1712baf9672..409e667278b081 100644 --- a/src/app/clusters/bindings/bindings.cpp +++ b/src/app/clusters/bindings/bindings.cpp @@ -268,7 +268,7 @@ CHIP_ERROR BindingTableAccess::NotifyBindingsChanged() void MatterBindingPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } CHIP_ERROR AddBindingEntry(const EmberBindingTableEntry & entry) diff --git a/src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp b/src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp index 3eb3b1216a38c7..ca9b7e403dbea1 100644 --- a/src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp +++ b/src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp @@ -453,5 +453,5 @@ bool emberAfBooleanStateConfigurationClusterEnableDisableAlarmCallback( void MatterBooleanStateConfigurationPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/channel-server/channel-server.cpp b/src/app/clusters/channel-server/channel-server.cpp index 01a1af2d3710de..13b4a8a577a09b 100644 --- a/src/app/clusters/channel-server/channel-server.cpp +++ b/src/app/clusters/channel-server/channel-server.cpp @@ -408,5 +408,5 @@ bool emberAfChannelClusterCancelRecordProgramCallback( void MatterChannelPluginServerInitCallback() { - registerAttributeAccessOverride(&gChannelAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gChannelAttrAccess); } diff --git a/src/app/clusters/concentration-measurement-server/concentration-measurement-server.h b/src/app/clusters/concentration-measurement-server/concentration-measurement-server.h index c903b21c2306fd..d71c1c4b6523c8 100644 --- a/src/app/clusters/concentration-measurement-server/concentration-measurement-server.h +++ b/src/app/clusters/concentration-measurement-server/concentration-measurement-server.h @@ -327,7 +327,7 @@ class Instance this->mMeasurementUnit = aMeasurementUnit; }; - ~Instance() override { unregisterAttributeAccessOverride(this); }; + ~Instance() override { AttributeAccessInterfaceRegistry::Instance().Unregister(this); }; CHIP_ERROR Init() { @@ -353,7 +353,7 @@ class Instance VerifyOrReturnError(emberAfContainsServer(mEndpointId, mClusterId), CHIP_ERROR_INCORRECT_STATE); // Register the object as attribute provider - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); mFeatureMap = GenerateFeatureMap(); diff --git a/src/app/clusters/content-launch-server/content-launch-server.cpp b/src/app/clusters/content-launch-server/content-launch-server.cpp index 2e4fb7435c0be9..f0b5d5992e8a36 100644 --- a/src/app/clusters/content-launch-server/content-launch-server.cpp +++ b/src/app/clusters/content-launch-server/content-launch-server.cpp @@ -286,5 +286,5 @@ bool emberAfContentLauncherClusterLaunchURLCallback(CommandHandler * commandObj, void MatterContentLauncherPluginServerInitCallback() { - registerAttributeAccessOverride(&gContentLauncherAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gContentLauncherAttrAccess); } diff --git a/src/app/clusters/descriptor/descriptor.cpp b/src/app/clusters/descriptor/descriptor.cpp index 514051226fdcf5..a8e50387646d5d 100644 --- a/src/app/clusters/descriptor/descriptor.cpp +++ b/src/app/clusters/descriptor/descriptor.cpp @@ -244,5 +244,5 @@ CHIP_ERROR DescriptorAttrAccess::Read(const ConcreteReadAttributePath & aPath, A void MatterDescriptorPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index fa913bc900a065..438e2d7bd5f7d3 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -38,16 +38,16 @@ namespace DeviceEnergyManagement { CHIP_ERROR Instance::Init() { - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void Instance::Shutdown() { - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } bool Instance::HasFeature(Feature aFeature) const diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index e003f5bc2b7704..29a76853220ef0 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -4233,7 +4233,7 @@ void MatterDoorLockPluginServerInitCallback() ChipLogProgress(Zcl, "Door Lock server initialized"); Server::GetInstance().GetFabricTable().AddFabricDelegate(&gFabricDelegate); - registerAttributeAccessOverride(&DoorLockServer::Instance()); + AttributeAccessInterfaceRegistry::Instance().Register(&DoorLockServer::Instance()); } void MatterDoorLockClusterServerAttributeChangedCallback(const app::ConcreteAttributePath & attributePath) {} diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp index 9d82f7064f0f1b..c51a5165f3ca9d 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp @@ -402,5 +402,5 @@ chip::app::Clusters::EcosystemInformation::AttrAccess gAttrAccess; void MatterEcosystemInformationPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + chip::app::AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp index cdf480b64cdde4..a2bfbc97cc4c0a 100644 --- a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp +++ b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp @@ -43,13 +43,13 @@ MeasurementData gMeasurements[MATTER_DM_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SE CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Init() { - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void ElectricalEnergyMeasurementAttrAccess::Shutdown() { - unregisterAttributeAccessOverride(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Read(const app::ConcreteReadAttributePath & aPath, diff --git a/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp b/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp index 0ac1ec956f1dab..c03cd06cc6e60c 100644 --- a/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp +++ b/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp @@ -42,13 +42,13 @@ namespace ElectricalPowerMeasurement { CHIP_ERROR Instance::Init() { - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void Instance::Shutdown() { - unregisterAttributeAccessOverride(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } bool Instance::HasFeature(Feature aFeature) const diff --git a/src/app/clusters/energy-evse-server/energy-evse-server.cpp b/src/app/clusters/energy-evse-server/energy-evse-server.cpp index 4807bf33969681..d4ae59307cfea1 100644 --- a/src/app/clusters/energy-evse-server/energy-evse-server.cpp +++ b/src/app/clusters/energy-evse-server/energy-evse-server.cpp @@ -38,16 +38,16 @@ namespace EnergyEvse { CHIP_ERROR Instance::Init() { - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void Instance::Shutdown() { - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } bool Instance::HasFeature(Feature aFeature) const diff --git a/src/app/clusters/energy-preference-server/energy-preference-server.cpp b/src/app/clusters/energy-preference-server/energy-preference-server.cpp index 789ab4ce0e7299..7b59f919dfc539 100644 --- a/src/app/clusters/energy-preference-server/energy-preference-server.cpp +++ b/src/app/clusters/energy-preference-server/energy-preference-server.cpp @@ -18,7 +18,7 @@ #include "energy-preference-server.h" #include -#include // Needed for registerAttributeAccessOverride +#include // Needed for AttributeAccessInterfaceRegistry::Instance().Register #include #include @@ -228,5 +228,5 @@ Status MatterEnergyPreferenceClusterServerPreAttributeChangedCallback(const Conc void MatterEnergyPreferencePluginServerInitCallback() { - registerAttributeAccessOverride(&gEnergyPrefAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gEnergyPrefAttrAccess); } diff --git a/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp b/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp index 7bd7043d7c7e51..0e15f2f9987439 100644 --- a/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp +++ b/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp @@ -186,5 +186,5 @@ bool emberAfEthernetNetworkDiagnosticsClusterResetCountsCallback(app::CommandHan void MatterEthernetNetworkDiagnosticsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/fixed-label-server/fixed-label-server.cpp b/src/app/clusters/fixed-label-server/fixed-label-server.cpp index bd952f148647fc..4a21dbbd3d6b47 100644 --- a/src/app/clusters/fixed-label-server/fixed-label-server.cpp +++ b/src/app/clusters/fixed-label-server/fixed-label-server.cpp @@ -110,5 +110,5 @@ CHIP_ERROR FixedLabelAttrAccess::Read(const ConcreteReadAttributePath & aPath, A void MatterFixedLabelPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp index 776441ffc9ae75..4bf97face53740 100644 --- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp +++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp @@ -343,7 +343,7 @@ void OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t void MatterGeneralCommissioningPluginServerInitCallback() { Breadcrumb::Set(0, 0); - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler); } diff --git a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp index fa3d9da3177d53..e04410d29788c2 100644 --- a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp +++ b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp @@ -491,7 +491,7 @@ void MatterGeneralDiagnosticsPluginServerInitCallback() { BootReasonEnum bootReason; - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); ConnectivityMgr().SetDelegate(&gDiagnosticDelegate); if (GetDiagnosticDataProvider().GetBootReason(bootReason) == CHIP_NO_ERROR) diff --git a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp index 518e28b94fbd2b..39b9f59d23a5ca 100644 --- a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp +++ b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp @@ -436,7 +436,7 @@ GroupKeyManagementAttributeAccess gAttribute; void MatterGroupKeyManagementPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttribute); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttribute); } // diff --git a/src/app/clusters/icd-management-server/icd-management-server.cpp b/src/app/clusters/icd-management-server/icd-management-server.cpp index e98cc5e31718b2..8445cad117c2a3 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.cpp +++ b/src/app/clusters/icd-management-server/icd-management-server.cpp @@ -467,7 +467,7 @@ void MatterIcdManagementPluginServerInitCallback() // Configure and register Attribute Access Override gAttribute.Init(storage, symmetricKeystore, fabricTable, icdConfigurationData); - registerAttributeAccessOverride(&gAttribute); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttribute); // Configure ICD Management ICDManagementServer::Init(storage, symmetricKeystore, icdConfigurationData); diff --git a/src/app/clusters/keypad-input-server/keypad-input-server.cpp b/src/app/clusters/keypad-input-server/keypad-input-server.cpp index a9903b754591a4..6ca7a6dd46767d 100644 --- a/src/app/clusters/keypad-input-server/keypad-input-server.cpp +++ b/src/app/clusters/keypad-input-server/keypad-input-server.cpp @@ -196,5 +196,5 @@ bool emberAfKeypadInputClusterSendKeyCallback(app::CommandHandler * command, con void MatterKeypadInputPluginServerInitCallback() { - registerAttributeAccessOverride(&gKeypadInputAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gKeypadInputAttrAccess); } diff --git a/src/app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.cpp b/src/app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.cpp index d8270a17bc46f6..c4f2d200c1ed8d 100644 --- a/src/app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.cpp +++ b/src/app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.cpp @@ -149,7 +149,7 @@ CHIP_ERROR LaundryDryerControlsServer::ReadSupportedDrynessLevels(const Concrete void MatterLaundryDryerControlsPluginServerInitCallback() { LaundryDryerControlsServer & laundryDryerControlsServer = LaundryDryerControlsServer::Instance(); - registerAttributeAccessOverride(&laundryDryerControlsServer); + AttributeAccessInterfaceRegistry::Instance().Register(&laundryDryerControlsServer); } Status MatterLaundryDryerControlsClusterServerPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, diff --git a/src/app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.cpp b/src/app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.cpp index 2fa6ee838c14b2..9b5a88f2103827 100644 --- a/src/app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.cpp +++ b/src/app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.cpp @@ -187,7 +187,7 @@ CHIP_ERROR LaundryWasherControlsServer::ReadSupportedRinses(const ConcreteReadAt void MatterLaundryWasherControlsPluginServerInitCallback() { LaundryWasherControlsServer & laundryWasherControlsServer = LaundryWasherControlsServer::Instance(); - registerAttributeAccessOverride(&laundryWasherControlsServer); + AttributeAccessInterfaceRegistry::Instance().Register(&laundryWasherControlsServer); } Status MatterLaundryWasherControlsClusterServerPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, diff --git a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp index 1b26542df3ed55..da061a4cfcab1f 100644 --- a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp +++ b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp @@ -221,5 +221,5 @@ void emberAfLocalizationConfigurationClusterServerInitCallback(EndpointId endpoi void MatterLocalizationConfigurationPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/media-input-server/media-input-server.cpp b/src/app/clusters/media-input-server/media-input-server.cpp index 267f4e987a1da1..e0f85f7223dee7 100644 --- a/src/app/clusters/media-input-server/media-input-server.cpp +++ b/src/app/clusters/media-input-server/media-input-server.cpp @@ -294,5 +294,5 @@ bool emberAfMediaInputClusterRenameInputCallback(app::CommandHandler * command, void MatterMediaInputPluginServerInitCallback() { - registerAttributeAccessOverride(&gMediaInputAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gMediaInputAttrAccess); } diff --git a/src/app/clusters/media-playback-server/media-playback-server.cpp b/src/app/clusters/media-playback-server/media-playback-server.cpp index b13a46d0101dd7..5f762cf8048ba0 100644 --- a/src/app/clusters/media-playback-server/media-playback-server.cpp +++ b/src/app/clusters/media-playback-server/media-playback-server.cpp @@ -708,5 +708,5 @@ void MatterMediaPlaybackClusterServerAttributeChangedCallback(const chip::app::C void MatterMediaPlaybackPluginServerInitCallback() { - registerAttributeAccessOverride(&gMediaPlaybackAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gMediaPlaybackAttrAccess); } diff --git a/src/app/clusters/messages-server/messages-server.cpp b/src/app/clusters/messages-server/messages-server.cpp index 0c03c95572dc74..f75368133cf36d 100644 --- a/src/app/clusters/messages-server/messages-server.cpp +++ b/src/app/clusters/messages-server/messages-server.cpp @@ -293,5 +293,5 @@ bool emberAfMessagesClusterCancelMessagesRequestCallback( void MatterMessagesPluginServerInitCallback() { - registerAttributeAccessOverride(&gMessagesAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gMessagesAttrAccess); } diff --git a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp index 49022891f0b1e9..73a3eb8a96774b 100644 --- a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp +++ b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp @@ -54,8 +54,8 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClus Instance::~Instance() { - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR Instance::Init() @@ -89,8 +89,8 @@ CHIP_ERROR Instance::Init() Zcl, "Microwave Oven Control: feature bits error, if feature supports PowerNumberLimits it must support PowerAsNumber")); - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); // If the PowerInWatts feature is supported, get the count of supported watt levels so we can later // ensure incoming watt level values are valid. if (HasFeature(MicrowaveOvenControl::Feature::kPowerInWatts)) 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 643dd3dd76bee2..092985d082fe06 100644 --- a/src/app/clusters/mode-base-server/mode-base-server.cpp +++ b/src/app/clusters/mode-base-server/mode-base-server.cpp @@ -64,8 +64,8 @@ void Instance::Shutdown() return; } UnregisterThisInstance(); - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR Instance::Init() @@ -78,8 +78,8 @@ CHIP_ERROR Instance::Init() LoadPersistentAttributes(); - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); RegisterThisInstance(); ReturnErrorOnFailure(mDelegate->Init()); diff --git a/src/app/clusters/mode-select-server/mode-select-server.cpp b/src/app/clusters/mode-select-server/mode-select-server.cpp index dceb72767bfb14..c5fb49708aa663 100644 --- a/src/app/clusters/mode-select-server/mode-select-server.cpp +++ b/src/app/clusters/mode-select-server/mode-select-server.cpp @@ -219,7 +219,7 @@ inline bool areStartUpModeAndCurrentModeNonVolatile(EndpointId endpointId) void MatterModeSelectPluginServerInitCallback() { - registerAttributeAccessOverride(&gModeSelectAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gModeSelectAttrAccess); } /** diff --git a/src/app/clusters/network-commissioning/network-commissioning.cpp b/src/app/clusters/network-commissioning/network-commissioning.cpp index 2cfe46c70993dc..7bb8aa665c5585 100644 --- a/src/app/clusters/network-commissioning/network-commissioning.cpp +++ b/src/app/clusters/network-commissioning/network-commissioning.cpp @@ -358,8 +358,8 @@ Instance::Instance(EndpointId aEndpointId, EthernetDriver * apDelegate) : CHIP_ERROR Instance::Init() { - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler, reinterpret_cast(this))); ReturnErrorOnFailure(mpBaseDriver->Init(this)); mLastNetworkingStatusValue.SetNull(); diff --git a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp index 04d2908986e0a2..c60fdc5255c023 100644 --- a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp +++ b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp @@ -41,13 +41,13 @@ uint16_t sHoldTime[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + C CHIP_ERROR Instance::Init() { - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(chip::app::AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void Instance::Shutdown() { - unregisterAttributeAccessOverride(this); + chip::app::AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 366694a8c504d3..ffc6a980039a3a 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -396,7 +396,7 @@ OpCredsFabricTableDelegate gFabricDelegate; void MatterOperationalCredentialsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); Server::GetInstance().GetFabricTable().AddFabricDelegate(&gFabricDelegate); diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index c86de02bfab6ae..710b1e84f38cfa 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -53,8 +53,8 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId) : Instance(aDel Instance::~Instance() { - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR Instance::Init() @@ -66,9 +66,9 @@ CHIP_ERROR Instance::Init() return CHIP_ERROR_INVALID_ARGUMENT; } - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } diff --git a/src/app/clusters/ota-requestor/ota-requestor-server.cpp b/src/app/clusters/ota-requestor/ota-requestor-server.cpp index 7bfbde1fa54ac5..26814231a23856 100644 --- a/src/app/clusters/ota-requestor/ota-requestor-server.cpp +++ b/src/app/clusters/ota-requestor/ota-requestor-server.cpp @@ -295,5 +295,5 @@ bool emberAfOtaSoftwareUpdateRequestorClusterAnnounceOTAProviderCallback( void MatterOtaSoftwareUpdateRequestorPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/power-source-configuration-server/power-source-configuration-server.cpp b/src/app/clusters/power-source-configuration-server/power-source-configuration-server.cpp index a8a9d4e80e8189..421420884e31b2 100644 --- a/src/app/clusters/power-source-configuration-server/power-source-configuration-server.cpp +++ b/src/app/clusters/power-source-configuration-server/power-source-configuration-server.cpp @@ -100,5 +100,5 @@ CHIP_ERROR PowerSourceConfigurationAttrAccess::Read(const ConcreteReadAttributeP void MatterPowerSourceConfigurationPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/power-source-server/power-source-server.cpp b/src/app/clusters/power-source-server/power-source-server.cpp index 43ca1827515731..7d95eca0da5ec5 100644 --- a/src/app/clusters/power-source-server/power-source-server.cpp +++ b/src/app/clusters/power-source-server/power-source-server.cpp @@ -91,7 +91,7 @@ PowerSourceClusterInfo * sPowerSourceClusterInfo = nullptr; void MatterPowerSourcePluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } namespace chip { diff --git a/src/app/clusters/power-topology-server/power-topology-server.cpp b/src/app/clusters/power-topology-server/power-topology-server.cpp index 0b7072ce8eb51b..31a85459eee882 100644 --- a/src/app/clusters/power-topology-server/power-topology-server.cpp +++ b/src/app/clusters/power-topology-server/power-topology-server.cpp @@ -41,13 +41,13 @@ namespace PowerTopology { CHIP_ERROR Instance::Init() { - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void Instance::Shutdown() { - unregisterAttributeAccessOverride(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } bool Instance::HasFeature(Feature aFeature) const diff --git a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp index 4d1197a73b83b8..b8d885599245a4 100644 --- a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp +++ b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp @@ -59,8 +59,8 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClus Instance::~Instance() { - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); } CHIP_ERROR Instance::Init() @@ -72,8 +72,8 @@ CHIP_ERROR Instance::Init() LoadPersistentAttributes(); - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); ChipLogDetail(Zcl, "ResourceMonitoring: calling mDelegate->Init()"); ReturnErrorOnFailure(mDelegate->Init()); diff --git a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.h b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.h index 8cdc74f34c1b0d..45c96c39f30074 100644 --- a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.h +++ b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.h @@ -74,7 +74,7 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface * @die If the endpoint and cluster ID have not been enabled in zap. * @return CHIP_ERROR_INVALID_ARGUMENT If the CommandHandler or Attribute Handler could not be registered. * @return CHIP_ERROR_INCORRECT_STATE If the CommandHandler was already registered - * @return CHIP_ERROR_INCORRECT_STATE If the registerAttributeAccessOverride fails. + * @return CHIP_ERROR_INCORRECT_STATE If the AttributeAccessInterfaceRegistry::Register fails. * @return CHIP_ERROR If the AppInit() method returned an error. This is application specific. * * @return CHIP_NO_ERROR If the cluster was initialised successfully. diff --git a/src/app/clusters/sample-mei-server/sample-mei-server.cpp b/src/app/clusters/sample-mei-server/sample-mei-server.cpp index ac461aab008b45..7677e3b1035cc7 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.cpp +++ b/src/app/clusters/sample-mei-server/sample-mei-server.cpp @@ -30,8 +30,8 @@ void MatterSampleMeiPluginServerInitCallback() { ChipLogProgress(Zcl, "Sample MEI Init. Ep %d, Total Ep %u", MATTER_DM_SAMPLE_MEI_CLUSTER_SERVER_ENDPOINT_COUNT, static_cast(kNumSupportedEndpoints)); - ReturnOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(&SampleMeiServer::Instance())); - VerifyOrReturn(registerAttributeAccessOverride(&SampleMeiServer::Instance()), CHIP_ERROR_INCORRECT_STATE); + ReturnOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&SampleMeiServer::Instance())); + VerifyOrReturn(AttributeAccessInterfaceRegistry::Instance().Register(&SampleMeiServer::Instance()), CHIP_ERROR_INCORRECT_STATE); } void emberAfSampleMeiClusterServerInitCallback(chip::EndpointId endpoint) diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index 7c215c20446948..acc2cd3a7dff80 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -339,8 +339,8 @@ CHIP_ERROR ScenesServer::Init() // Prevents re-initializing VerifyOrReturnError(!mIsInitialized, CHIP_ERROR_INCORRECT_STATE); - ReturnErrorOnFailure(chip::app::CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(chip::app::CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); mGroupProvider = Credentials::GetGroupDataProvider(); SceneTable * sceneTable = scenes::GetSceneTableImpl(); @@ -353,7 +353,7 @@ CHIP_ERROR ScenesServer::Init() void ScenesServer::Shutdown() { - chip::app::CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); + chip::app::CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); mGroupProvider = nullptr; mIsInitialized = false; diff --git a/src/app/clusters/service-area-server/service-area-server.cpp b/src/app/clusters/service-area-server/service-area-server.cpp index 17b55d12aa9352..cb5c3b144ba640 100644 --- a/src/app/clusters/service-area-server/service-area-server.cpp +++ b/src/app/clusters/service-area-server/service-area-server.cpp @@ -56,8 +56,8 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId, BitMaskInit(); } diff --git a/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp b/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp index e6bc0daac67668..9f9235a16f46d8 100644 --- a/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp +++ b/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp @@ -230,6 +230,6 @@ bool emberAfSoftwareDiagnosticsClusterResetWatermarksCallback(app::CommandHandle void MatterSoftwareDiagnosticsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); - CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gCommandHandler); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); + CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&gCommandHandler); } diff --git a/src/app/clusters/target-navigator-server/target-navigator-server.cpp b/src/app/clusters/target-navigator-server/target-navigator-server.cpp index 42c852b81c8c5a..e42673a8bfbebb 100644 --- a/src/app/clusters/target-navigator-server/target-navigator-server.cpp +++ b/src/app/clusters/target-navigator-server/target-navigator-server.cpp @@ -261,5 +261,5 @@ void MatterTargetNavigatorClusterServerAttributeChangedCallback(const chip::app: void MatterTargetNavigatorPluginServerInitCallback() { - registerAttributeAccessOverride(&gTargetNavigatorAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gTargetNavigatorAttrAccess); } diff --git a/src/app/clusters/temperature-control-server/temperature-control-server.cpp b/src/app/clusters/temperature-control-server/temperature-control-server.cpp index 85035c642d4092..2faab863d2b2f9 100644 --- a/src/app/clusters/temperature-control-server/temperature-control-server.cpp +++ b/src/app/clusters/temperature-control-server/temperature-control-server.cpp @@ -228,5 +228,5 @@ void emberAfTemperatureControlClusterServerInitCallback(EndpointId endpoint) {} void MatterTemperatureControlPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index 9bd925780524eb..4ea9964b342a50 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -1185,5 +1185,5 @@ bool emberAfUnitTestingClusterGlobalEchoRequestCallback(CommandHandler * command void MatterUnitTestingPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp index fb60b046183b28..6b8a50a6ffe7e0 100644 --- a/src/app/clusters/thermostat-server/thermostat-server.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server.cpp @@ -1868,5 +1868,5 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co void MatterThermostatPluginServerInitCallback() { - registerAttributeAccessOverride(&gThermostatAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gThermostatAttrAccess); } diff --git a/src/app/clusters/thread-border-router-management-server/thread-border-router-management-server.cpp b/src/app/clusters/thread-border-router-management-server/thread-border-router-management-server.cpp index 4956f3f1fcc0be..6988b83b46ba72 100644 --- a/src/app/clusters/thread-border-router-management-server/thread-border-router-management-server.cpp +++ b/src/app/clusters/thread-border-router-management-server/thread-border-router-management-server.cpp @@ -364,8 +364,8 @@ void ServerInstance::OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * CHIP_ERROR ServerInstance::Init() { ReturnErrorCodeIf(!mDelegate, CHIP_ERROR_INVALID_ARGUMENT); - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(chip::app::AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler, reinterpret_cast(this))); return mDelegate->Init(this); } diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp index c2e198736ff9e4..f4ec69e05b1fa5 100644 --- a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp @@ -204,6 +204,6 @@ bool emberAfThreadNetworkDiagnosticsClusterResetCountsCallback(app::CommandHandl void MatterThreadNetworkDiagnosticsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); GetDiagnosticDataProvider().SetThreadDiagnosticsDelegate(&gDiagnosticDelegate); } diff --git a/src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp b/src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp index 384686693b0a69..64aa0a583738c6 100644 --- a/src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp +++ b/src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp @@ -47,14 +47,14 @@ ThreadNetworkDirectoryServer::ThreadNetworkDirectoryServer(EndpointId endpoint, ThreadNetworkDirectoryServer::~ThreadNetworkDirectoryServer() { - unregisterAttributeAccessOverride(this); - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); } CHIP_ERROR ThreadNetworkDirectoryServer::Init() { - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INTERNAL); - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INTERNAL); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); return CHIP_NO_ERROR; } diff --git a/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp b/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp index 7e61e340f1fab1..04345ee649e48a 100644 --- a/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp +++ b/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp @@ -232,5 +232,5 @@ void emberAfTimeFormatLocalizationClusterServerInitCallback(EndpointId endpoint) void MatterTimeFormatLocalizationPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp index fda3bb50d7fda0..8ef3d967b5d655 100644 --- a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -1290,5 +1290,5 @@ bool emberAfTimeSynchronizationClusterSetDefaultNTPCallback( void MatterTimeSynchronizationPluginServerInitCallback() { TimeSynchronizationServer::Instance().Init(); - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/user-label-server/user-label-server.cpp b/src/app/clusters/user-label-server/user-label-server.cpp index 5131ed44aaca2b..5daae5ab179ac3 100644 --- a/src/app/clusters/user-label-server/user-label-server.cpp +++ b/src/app/clusters/user-label-server/user-label-server.cpp @@ -219,6 +219,6 @@ UserLabelFabricTableDelegate gUserLabelFabricDelegate; void MatterUserLabelPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); Server::GetInstance().GetFabricTable().AddFabricDelegate(&gUserLabelFabricDelegate); } diff --git a/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp b/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp index 02486beea315a4..f6fa4e8fee6332 100644 --- a/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp +++ b/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp @@ -514,5 +514,5 @@ bool emberAfValveConfigurationAndControlClusterCloseCallback( void MatterValveConfigurationAndControlPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); } diff --git a/src/app/clusters/wake-on-lan-server/wake-on-lan-server.cpp b/src/app/clusters/wake-on-lan-server/wake-on-lan-server.cpp index 3141094d1fa3c7..5f3b7bb6d3a7d1 100644 --- a/src/app/clusters/wake-on-lan-server/wake-on-lan-server.cpp +++ b/src/app/clusters/wake-on-lan-server/wake-on-lan-server.cpp @@ -142,5 +142,5 @@ CHIP_ERROR WakeOnLanAttrAccess::ReadMacAddressAttribute(app::AttributeValueEncod void MatterWakeOnLanPluginServerInitCallback() { - registerAttributeAccessOverride(&gWakeOnLanAttrAccess); + app::AttributeAccessInterfaceRegistry::Instance().Register(&gWakeOnLanAttrAccess); } diff --git a/src/app/clusters/water-heater-management-server/water-heater-management-server.cpp b/src/app/clusters/water-heater-management-server/water-heater-management-server.cpp index 6af249370e8fb8..0806638dd7ee4d 100644 --- a/src/app/clusters/water-heater-management-server/water-heater-management-server.cpp +++ b/src/app/clusters/water-heater-management-server/water-heater-management-server.cpp @@ -40,16 +40,16 @@ constexpr uint16_t kClusterRevision = 1; CHIP_ERROR Instance::Init() { - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); + VerifyOrReturnError(chip::app::AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } void Instance::Shutdown() { - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); - unregisterAttributeAccessOverride(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); + chip::app::AttributeAccessInterfaceRegistry::Instance().Unregister(this); } bool Instance::HasFeature(Feature aFeature) const diff --git a/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp b/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp index e119cfd7c2972f..416c7179c10f60 100644 --- a/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp +++ b/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp @@ -317,6 +317,6 @@ bool emberAfWiFiNetworkDiagnosticsClusterResetCountsCallback(app::CommandHandler void MatterWiFiNetworkDiagnosticsPluginServerInitCallback() { - registerAttributeAccessOverride(&gAttrAccess); + AttributeAccessInterfaceRegistry::Instance().Register(&gAttrAccess); GetDiagnosticDataProvider().SetWiFiDiagnosticsDelegate(&gDiagnosticDelegate); } diff --git a/src/app/clusters/wifi-network-management-server/wifi-network-management-server.cpp b/src/app/clusters/wifi-network-management-server/wifi-network-management-server.cpp index 43048498602ff8..79aac105e4e3fe 100644 --- a/src/app/clusters/wifi-network-management-server/wifi-network-management-server.cpp +++ b/src/app/clusters/wifi-network-management-server/wifi-network-management-server.cpp @@ -64,14 +64,14 @@ WiFiNetworkManagementServer::WiFiNetworkManagementServer(EndpointId endpoint) : WiFiNetworkManagementServer::~WiFiNetworkManagementServer() { - unregisterAttributeAccessOverride(this); - CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); + AttributeAccessInterfaceRegistry::Instance().Unregister(this); + CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); } CHIP_ERROR WiFiNetworkManagementServer::Init() { - VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INTERNAL); - ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::RegisterCommandHandler(this)); + VerifyOrReturnError(AttributeAccessInterfaceRegistry::Instance().Register(this), CHIP_ERROR_INTERNAL); + ReturnErrorOnFailure(CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this)); return CHIP_NO_ERROR; } diff --git a/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp index 6ff4b730812d16..9f87e4c8f187fe 100644 --- a/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp +++ b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp @@ -311,7 +311,8 @@ DataModel::ActionReturnStatus CodegenDataModelProvider::ReadAttribute(const Data else { aai_result = TryReadViaAccessInterface( - request.path, GetAttributeAccessOverride(request.path.mEndpointId, request.path.mClusterId), encoder); + request.path, AttributeAccessInterfaceRegistry::Instance().Get(request.path.mEndpointId, request.path.mClusterId), + encoder); } ReturnErrorCodeIf(aai_result.has_value(), *aai_result); diff --git a/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp index 925d5cce61bc87..37371043aa323f 100644 --- a/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp +++ b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp @@ -346,7 +346,8 @@ DataModel::ActionReturnStatus CodegenDataModelProvider::WriteAttribute(const Dat } } - AttributeAccessInterface * aai = GetAttributeAccessOverride(request.path.mEndpointId, request.path.mClusterId); + AttributeAccessInterface * aai = + AttributeAccessInterfaceRegistry::Instance().Get(request.path.mEndpointId, request.path.mClusterId); std::optional aai_result = TryWriteViaAccessInterface(request.path, aai, decoder); if (aai_result.has_value()) { diff --git a/src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp b/src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp index a8862bd9036963..649c6f02195a27 100644 --- a/src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp +++ b/src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp @@ -594,9 +594,9 @@ class RegisteredAttributeAccessInterface template RegisteredAttributeAccessInterface(Args &&... args) : mData(std::forward(args)...) { - VerifyOrDie(registerAttributeAccessOverride(&mData)); + VerifyOrDie(AttributeAccessInterfaceRegistry::Instance().Register(&mData)); } - ~RegisteredAttributeAccessInterface() { unregisterAttributeAccessOverride(&mData); } + ~RegisteredAttributeAccessInterface() { AttributeAccessInterfaceRegistry::Instance().Unregister(&mData); } T * operator->() { return &mData; } T & operator*() { return mData; } diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index f21132bd4026ca..b9d54fceb85fb5 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -422,8 +422,8 @@ static void shutdownEndpoint(EmberAfDefinedEndpoint * definedEndpoint) } } - CommandHandlerInterfaceRegistry::UnregisterAllCommandHandlersForEndpoint(definedEndpoint->endpoint); - unregisterAllAttributeAccessOverridesForEndpoint(definedEndpoint); + CommandHandlerInterfaceRegistry::Instance().UnregisterAllCommandHandlersForEndpoint(definedEndpoint->endpoint); + AttributeAccessInterfaceRegistry::Instance().UnregisterAllForEndpoint(definedEndpoint->endpoint); } // Calls the init functions. diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index c1545bffa88977..d556d8816c2145 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -101,7 +101,8 @@ Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCom return Status::UnsupportedCluster; } - auto * commandHandler = CommandHandlerInterfaceRegistry::GetCommandHandler(aCommandPath.mEndpointId, aCommandPath.mClusterId); + auto * commandHandler = + CommandHandlerInterfaceRegistry::Instance().GetCommandHandler(aCommandPath.mEndpointId, aCommandPath.mClusterId); if (commandHandler) { struct Context @@ -311,8 +312,9 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b // Special handling for mandatory global attributes: these are always for attribute list, using a special // reader (which can be lightweight constructed even from nullptr). GlobalAttributeReader reader(attributeCluster); - AttributeAccessInterface * attributeOverride = - (attributeCluster != nullptr) ? &reader : GetAttributeAccessOverride(aPath.mEndpointId, aPath.mClusterId); + AttributeAccessInterface * attributeOverride = (attributeCluster != nullptr) + ? &reader + : AttributeAccessInterfaceRegistry::Instance().Get(aPath.mEndpointId, aPath.mClusterId); if (attributeOverride) { bool triedEncode = false; @@ -712,7 +714,7 @@ CHIP_ERROR WriteSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, return apWriteHandler->AddStatus(aPath, Protocols::InteractionModel::Status::DataVersionMismatch); } - if (auto * attrOverride = GetAttributeAccessOverride(aPath.mEndpointId, aPath.mClusterId)) + if (auto * attrOverride = AttributeAccessInterfaceRegistry::Instance().Get(aPath.mEndpointId, aPath.mClusterId)) { AttributeValueDecoder valueDecoder(aReader, aSubjectDescriptor); ReturnErrorOnFailure(attrOverride->Write(aPath, valueDecoder)); diff --git a/src/app/util/ember-global-attribute-access-interface.cpp b/src/app/util/ember-global-attribute-access-interface.cpp index cbc4f070e7825e..be865ad0aa5727 100644 --- a/src/app/util/ember-global-attribute-access-interface.cpp +++ b/src/app/util/ember-global-attribute-access-interface.cpp @@ -97,7 +97,7 @@ CHIP_ERROR GlobalAttributeReader::EncodeCommandList(const ConcreteClusterPath & { return aEncoder.EncodeList([&](const auto & encoder) { auto * commandHandler = - CommandHandlerInterfaceRegistry::GetCommandHandler(aClusterPath.mEndpointId, aClusterPath.mClusterId); + CommandHandlerInterfaceRegistry::Instance().GetCommandHandler(aClusterPath.mEndpointId, aClusterPath.mClusterId); if (commandHandler) { struct Context diff --git a/src/controller/tests/TestEventChunking.cpp b/src/controller/tests/TestEventChunking.cpp index 0aa0b9d0a5714f..60eaf037ada087 100644 --- a/src/controller/tests/TestEventChunking.cpp +++ b/src/controller/tests/TestEventChunking.cpp @@ -220,7 +220,7 @@ class TestAttrAccess : public app::AttributeAccessInterface // Register for the Test Cluster cluster on all endpoints. TestAttrAccess() : AttributeAccessInterface(Optional::Missing(), Clusters::UnitTesting::Id) { - registerAttributeAccessOverride(this); + AttributeAccessInterfaceRegistry::Instance().Register(this); } CHIP_ERROR Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) override; diff --git a/src/controller/tests/TestReadChunking.cpp b/src/controller/tests/TestReadChunking.cpp index b00d0bed75ebcf..b5e33ede85eca4 100644 --- a/src/controller/tests/TestReadChunking.cpp +++ b/src/controller/tests/TestReadChunking.cpp @@ -360,7 +360,7 @@ class TestAttrAccess : public app::AttributeAccessInterface // Register for the Test Cluster cluster on all endpoints. TestAttrAccess() : AttributeAccessInterface(Optional::Missing(), Clusters::UnitTesting::Id) { - registerAttributeAccessOverride(this); + AttributeAccessInterfaceRegistry::Instance().Register(this); } CHIP_ERROR Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) override; diff --git a/src/controller/tests/TestServerCommandDispatch.cpp b/src/controller/tests/TestServerCommandDispatch.cpp index 960d849fc660ad..6e2c2c5306ec2a 100644 --- a/src/controller/tests/TestServerCommandDispatch.cpp +++ b/src/controller/tests/TestServerCommandDispatch.cpp @@ -62,10 +62,10 @@ class TestClusterCommandHandler : public chip::app::CommandHandlerInterface public: TestClusterCommandHandler() : chip::app::CommandHandlerInterface(Optional::Missing(), Clusters::UnitTesting::Id) { - CommandHandlerInterfaceRegistry::RegisterCommandHandler(this); + CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(this); } - ~TestClusterCommandHandler() { CommandHandlerInterfaceRegistry::UnregisterCommandHandler(this); } + ~TestClusterCommandHandler() { CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this); } void OverrideAcceptedCommands() { mOverrideAcceptedCommands = true; } void ClaimNoCommands() { mClaimNoCommands = true; } diff --git a/src/controller/tests/TestWriteChunking.cpp b/src/controller/tests/TestWriteChunking.cpp index 9ffad2c602835c..5bb7ef95214ce9 100644 --- a/src/controller/tests/TestWriteChunking.cpp +++ b/src/controller/tests/TestWriteChunking.cpp @@ -217,7 +217,7 @@ TEST_F(TestWriteChunking, TestListChunking) emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); // Register our fake attribute access interface. - registerAttributeAccessOverride(&testServer); + AttributeAccessInterfaceRegistry::Instance().Register(&testServer); app::AttributePathParams attributePath(kTestEndpointId, app::Clusters::UnitTesting::Id, kTestListAttribute); // @@ -290,7 +290,7 @@ TEST_F(TestWriteChunking, TestBadChunking) emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); // Register our fake attribute access interface. - registerAttributeAccessOverride(&testServer); + AttributeAccessInterfaceRegistry::Instance().Register(&testServer); app::AttributePathParams attributePath(kTestEndpointId, app::Clusters::UnitTesting::Id, kTestListAttribute); @@ -369,7 +369,7 @@ TEST_F(TestWriteChunking, TestConflictWrite) emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); // Register our fake attribute access interface. - registerAttributeAccessOverride(&testServer); + AttributeAccessInterfaceRegistry::Instance().Register(&testServer); app::AttributePathParams attributePath(kTestEndpointId, app::Clusters::UnitTesting::Id, kTestListAttribute); @@ -443,7 +443,7 @@ TEST_F(TestWriteChunking, TestNonConflictWrite) emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); // Register our fake attribute access interface. - registerAttributeAccessOverride(&testServer); + AttributeAccessInterfaceRegistry::Instance().Register(&testServer); app::AttributePathParams attributePath1(kTestEndpointId, app::Clusters::UnitTesting::Id, kTestListAttribute); app::AttributePathParams attributePath2(kTestEndpointId, app::Clusters::UnitTesting::Id, kTestListAttribute2); @@ -591,7 +591,7 @@ TEST_F(TestWriteChunking, TestTransactionalList) emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); // Register our fake attribute access interface. - registerAttributeAccessOverride(&testServer); + AttributeAccessInterfaceRegistry::Instance().Register(&testServer); // Test 1: we should receive transaction notifications ChipLogProgress(Zcl, "Test 1: we should receive transaction notifications"); diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm index e00bd10b5dc6c7..172ce2bd0d0797 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm @@ -379,7 +379,7 @@ - (void)registerMatterCluster std::lock_guard lock(_lock); - if (!registerAttributeAccessOverride(_attributeAccessInterface.get())) { + if (!AttributeAccessInterfaceRegistry::Instance().Register(_attributeAccessInterface.get())) { // This should only happen if we somehow managed to register an // AttributeAccessInterface for the same (endpoint, cluster) pair. MTR_LOG_ERROR("Could not register AttributeAccessInterface for endpoint %u, cluster 0x%llx", @@ -394,7 +394,7 @@ - (void)unregisterMatterCluster std::lock_guard lock(_lock); if (_attributeAccessInterface != nullptr) { - unregisterAttributeAccessOverride(_attributeAccessInterface.get()); + AttributeAccessInterfaceRegistry::Instance().Unregister(_attributeAccessInterface.get()); } }