Matter SDK Coverage Report
Current view: top level - data-model-providers/codegen - EmberMetadata.cpp (source / functions) Coverage Total Hit
Test: SHA:f84fe08d06f240e801b5d923f8a938a9938ca110 Lines: 100.0 % 11 11
Test Date: 2025-02-22 08:08:07 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *    Copyright (c) 2024 Project CHIP Authors
       3              :  *    All rights reserved.
       4              :  *
       5              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       6              :  *    you may not use this file except in compliance with the License.
       7              :  *    You may obtain a copy of the License at
       8              :  *
       9              :  *        http://www.apache.org/licenses/LICENSE-2.0
      10              :  *
      11              :  *    Unless required by applicable law or agreed to in writing, software
      12              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      13              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14              :  *    See the License for the specific language governing permissions and
      15              :  *    limitations under the License.
      16              :  */
      17              : #include <data-model-providers/codegen/EmberMetadata.h>
      18              : 
      19              : #include <app/GlobalAttributes.h>
      20              : #include <app/util/attribute-storage.h>
      21              : #include <app/util/endpoint-config-api.h>
      22              : 
      23              : namespace chip {
      24              : namespace app {
      25              : namespace Ember {
      26              : 
      27              : using Protocols::InteractionModel::Status;
      28              : 
      29              : std::variant<const EmberAfAttributeMetadata *, // a specific attribute stored by ember
      30              :              Status                            // one of Status::Unsupported*
      31              :              >
      32         4387 : FindAttributeMetadata(const ConcreteAttributePath & aPath)
      33              : {
      34              :     const EmberAfAttributeMetadata * metadata =
      35         4387 :         emberAfLocateAttributeMetadata(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId);
      36              : 
      37         4387 :     if (metadata == nullptr)
      38              :     {
      39            9 :         const EmberAfEndpointType * type = emberAfFindEndpointType(aPath.mEndpointId);
      40            9 :         if (type == nullptr)
      41              :         {
      42            3 :             return Status::UnsupportedEndpoint;
      43              :         }
      44              : 
      45            6 :         const EmberAfCluster * cluster = emberAfFindClusterInType(type, aPath.mClusterId, MATTER_CLUSTER_FLAG_SERVER);
      46            6 :         if (cluster == nullptr)
      47              :         {
      48            3 :             return Status::UnsupportedCluster;
      49              :         }
      50              : 
      51              :         // Since we know the attribute is unsupported and the endpoint/cluster are
      52              :         // OK, this is the only option left.
      53            3 :         return Status::UnsupportedAttribute;
      54              :     }
      55              : 
      56         4378 :     return metadata;
      57              : }
      58              : 
      59              : } // namespace Ember
      60              : } // namespace app
      61              : } // namespace chip
        

Generated by: LCOV version 2.0-1