Matter SDK Coverage Report
Current view: top level - inet - EndPointBasis.h (source / functions) Coverage Total Hit
Test: SHA:e98a48c2e59f85a25417956e1d105721433aa5d1 Lines: 100.0 % 5 5
Test Date: 2026-01-09 16:53:50 Functions: 100.0 % 10 10

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2020-2025 Project CHIP Authors
       4              :  *    Copyright (c) 2015-2017 Nest Labs, Inc.
       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              : /**
      20              :  *    @file
      21              :  *      This file contains the basis class for all the various transport
      22              :  *      endpoint classes in the Inet layer, i.e. TCP and UDP.
      23              :  */
      24              : 
      25              : #pragma once
      26              : 
      27              : #include <inet/InetConfig.h>
      28              : #include <lib/core/ReferenceCounted.h>
      29              : #include <lib/support/DLLUtil.h>
      30              : #include <lib/support/ReferenceCountedPtr.h>
      31              : 
      32              : namespace chip {
      33              : 
      34              : namespace System {
      35              : class Layer;
      36              : } // namespace System
      37              : 
      38              : namespace Inet {
      39              : 
      40              : template <typename EndPointType>
      41              : class EndPointManager;
      42              : 
      43              : template <typename EndPointType>
      44              : class EndPointDeletor;
      45              : 
      46              : template <class EndPointType>
      47              : class EndPointHandle;
      48              : 
      49              : /**
      50              :  * Base class of internet transport endpoint classes. Guarded by EndPointManager::CreateEndPoint to guarantee proper ref-counting.
      51              :  */
      52              : template <typename EndPointType>
      53              : class DLL_EXPORT EndPointBasis : public ReferenceCountedProtected<EndPointType, EndPointDeletor<EndPointType>>
      54              : {
      55              : public:
      56              :     using EndPoint = EndPointType;
      57              : 
      58          141 :     EndPointBasis(EndPointManager<EndPoint> & endPointManager) : mAppState(nullptr), mEndPointManager(endPointManager) {}
      59              : 
      60              :     /**
      61              :      *  Returns a reference to the endpoint fatory that owns this basis object.
      62              :      */
      63          177 :     EndPointManager<EndPoint> & GetEndPointManager() const { return mEndPointManager; }
      64              : 
      65              :     /**
      66              :      *  Returns a reference to the System::Layer associated with this object.
      67              :      */
      68          692 :     chip::System::Layer & GetSystemLayer() const { return mEndPointManager.SystemLayer(); }
      69              : 
      70              :     void * mAppState;
      71              : 
      72              : protected:
      73              :     friend class EndPointHandle<EndPointType>;
      74              : 
      75          141 :     inline void Delete() { GetEndPointManager().DeleteEndPoint(static_cast<EndPointType *>(this)); }
      76              : 
      77              : private:
      78              :     EndPointManager<EndPoint> & mEndPointManager; /**< Factory that owns this object. */
      79              : };
      80              : 
      81              : template <typename EndPointType>
      82              : class EndPointDeletor
      83              : {
      84              : public:
      85          141 :     static void Release(EndPointType * obj) { obj->Free(); }
      86              : };
      87              : 
      88              : } // namespace Inet
      89              : } // namespace chip
        

Generated by: LCOV version 2.0-1