Matter SDK Coverage Report
Current view: top level - access - ProviderDeviceTypeResolver.h (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 14.3 % 7 1
Test Date: 2025-01-17 19:00:11 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/Provider.h>
      20              : 
      21              : namespace chip {
      22              : namespace Access {
      23              : 
      24              : /// A device type resolver where the DataModel::Provider is fetched dynamically (may change over time)
      25              : class DynamicProviderDeviceTypeResolver : public chip::Access::AccessControl::DeviceTypeResolver
      26              : {
      27              : public:
      28              :     using ModelGetter = app::DataModel::Provider * (*) ();
      29              : 
      30            1 :     DynamicProviderDeviceTypeResolver(ModelGetter model) : mModelGetter(model) {}
      31              : 
      32            0 :     bool IsDeviceTypeOnEndpoint(chip::DeviceTypeId deviceType, chip::EndpointId endpoint) override
      33              :     {
      34            0 :         app::DataModel::Provider * model = mModelGetter();
      35            0 :         for (auto type = model->FirstDeviceType(endpoint); type.has_value(); type = model->NextDeviceType(endpoint, *type))
      36              :         {
      37            0 :             if (type->deviceTypeId == deviceType)
      38              :             {
      39            0 :                 return true;
      40              :             }
      41              :         }
      42            0 :         return false;
      43              :     }
      44              : 
      45              : private:
      46              :     ModelGetter mModelGetter;
      47              : };
      48              : 
      49              : } // namespace Access
      50              : } // namespace chip
        

Generated by: LCOV version 2.0-1