Matter SDK Coverage Report
Current view: top level - access - ProviderDeviceTypeResolver.h (source / functions) Coverage Total Hit
Test: SHA:f84fe08d06f240e801b5d923f8a938a9938ca110 Lines: 10.0 % 10 1
Test Date: 2025-02-22 08:08:07 Functions: 50.0 % 2 1

            Line data    Source code
       1              : /*
       2              :  *    Copyright (c) 2024 Project CHIP Authors
       3              :  *
       4              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       5              :  *    you may not use this file except in compliance with the License.
       6              :  *    You may obtain a copy of the License at
       7              :  *
       8              :  *        http://www.apache.org/licenses/LICENSE-2.0
       9              :  *
      10              :  *    Unless required by applicable law or agreed to in writing, software
      11              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      12              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              :  *    See the License for the specific language governing permissions and
      14              :  *    limitations under the License.
      15              :  */
      16              : #pragma once
      17              : 
      18              : #include <access/AccessControl.h>
      19              : #include <app/data-model-provider/MetadataList.h>
      20              : #include <app/data-model-provider/MetadataTypes.h>
      21              : #include <app/data-model-provider/Provider.h>
      22              : 
      23              : namespace chip {
      24              : namespace Access {
      25              : 
      26              : /// A device type resolver where the DataModel::Provider is fetched dynamically (may change over time)
      27              : class DynamicProviderDeviceTypeResolver : public chip::Access::AccessControl::DeviceTypeResolver
      28              : {
      29              : public:
      30              :     using ModelGetter = app::DataModel::Provider * (*) ();
      31              : 
      32            1 :     DynamicProviderDeviceTypeResolver(ModelGetter model) : mModelGetter(model) {}
      33              : 
      34            0 :     bool IsDeviceTypeOnEndpoint(chip::DeviceTypeId deviceType, chip::EndpointId endpoint) override
      35              :     {
      36            0 :         app::DataModel::ListBuilder<app::DataModel::DeviceTypeEntry> builder;
      37            0 :         (void) mModelGetter()->DeviceTypes(endpoint, builder);
      38            0 :         for (auto & type : builder.TakeBuffer())
      39              :         {
      40            0 :             if (type.deviceTypeId == deviceType)
      41              :             {
      42            0 :                 return true;
      43              :             }
      44            0 :         }
      45            0 :         return false;
      46            0 :     }
      47              : 
      48              : private:
      49              :     ModelGetter mModelGetter;
      50              : };
      51              : 
      52              : } // namespace Access
      53              : } // namespace chip
        

Generated by: LCOV version 2.0-1