LCOV - code coverage report
Current view: top level - app - CommandPathParams.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 0 5 0.0 %
Date: 2024-02-15 08:20:41 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2021 Project CHIP Authors
       4             :  *    All rights reserved.
       5             :  *
       6             :  *    Licensed under the Apache License, Version 2.0 (the "License");
       7             :  *    you may not use this file except in compliance with the License.
       8             :  *    You may obtain a copy of the License at
       9             :  *
      10             :  *        http://www.apache.org/licenses/LICENSE-2.0
      11             :  *
      12             :  *    Unless required by applicable law or agreed to in writing, software
      13             :  *    distributed under the License is distributed on an "AS IS" BASIS,
      14             :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15             :  *    See the License for the specific language governing permissions and
      16             :  *    limitations under the License.
      17             :  */
      18             : 
      19             : #pragma once
      20             : 
      21             : #include <app/util/basic-types.h>
      22             : #include <lib/core/GroupId.h>
      23             : #include <lib/support/BitFlags.h>
      24             : 
      25             : namespace chip {
      26             : namespace app {
      27             : 
      28             : enum class CommandPathFlags : uint8_t
      29             : {
      30             :     kEndpointIdValid = 0x01,
      31             :     kGroupIdValid    = 0x02,
      32             : };
      33             : 
      34             : struct CommandPathParams
      35             : {
      36           0 :     CommandPathParams(EndpointId aEndpointId, GroupId aGroupId, ClusterId aClusterId, CommandId aCommandId,
      37           0 :                       const BitFlags<CommandPathFlags> & aFlags) :
      38           0 :         mEndpointId(aEndpointId),
      39           0 :         mGroupId(aGroupId), mClusterId(aClusterId), mCommandId(aCommandId), mFlags(aFlags)
      40           0 :     {}
      41             : 
      42             :     CommandPathParams(uint16_t aId, ClusterId aClusterId, CommandId aCommandId, const BitFlags<CommandPathFlags> & aFlags) :
      43             :         mClusterId(aClusterId), mCommandId(aCommandId), mFlags(aFlags)
      44             :     {
      45             :         if (aFlags == CommandPathFlags::kEndpointIdValid)
      46             :         {
      47             :             mEndpointId = aId;
      48             :         }
      49             :         else if (aFlags == CommandPathFlags::kGroupIdValid)
      50             :         {
      51             :             mGroupId = aId;
      52             :         }
      53             :     }
      54             : 
      55             :     bool IsSamePath(const CommandPathParams & other) const
      56             :     {
      57             :         if (other.mClusterId != mClusterId || other.mCommandId != mCommandId)
      58             :         {
      59             :             return false;
      60             :         }
      61             :         if (mFlags != other.mFlags)
      62             :         {
      63             :             return false;
      64             :         }
      65             :         if (mFlags == CommandPathFlags::kEndpointIdValid && other.mEndpointId != mEndpointId)
      66             :         {
      67             :             return false;
      68             :         }
      69             :         if (mFlags == CommandPathFlags::kGroupIdValid && other.mGroupId != mGroupId)
      70             :         {
      71             :             return false;
      72             :         }
      73             :         return true;
      74             :     }
      75             :     EndpointId mEndpointId = 0;
      76             :     GroupId mGroupId       = 0;
      77             :     ClusterId mClusterId   = 0;
      78             :     CommandId mCommandId   = 0;
      79             :     BitFlags<CommandPathFlags> mFlags;
      80             : };
      81             : } // namespace app
      82             : } // namespace chip

Generated by: LCOV version 1.14