LCOV - code coverage report
Current view: top level - inet - EndPointBasis.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 3 3 100.0 %
Date: 2024-02-15 08:20:41 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2020-2021 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             : 
      31             : namespace chip {
      32             : 
      33             : namespace System {
      34             : class Layer;
      35             : } // namespace System
      36             : 
      37             : namespace Inet {
      38             : 
      39             : template <typename EndPointType>
      40             : class EndPointManager;
      41             : 
      42             : template <typename EndPointType>
      43             : class EndPointDeletor;
      44             : 
      45             : /**
      46             :  * Basis of internet transport endpoint classes.
      47             :  */
      48             : template <typename EndPointType>
      49             : class DLL_EXPORT EndPointBasis : public ReferenceCounted<EndPointType, EndPointDeletor<EndPointType>>
      50             : {
      51             : public:
      52             :     using EndPoint = EndPointType;
      53             : 
      54             :     EndPointBasis(EndPointManager<EndPoint> & endPointManager) : mAppState(nullptr), mEndPointManager(endPointManager) {}
      55             : 
      56             :     /**
      57             :      *  Returns a reference to the endpoint fatory that owns this basis object.
      58             :      */
      59          95 :     EndPointManager<EndPoint> & GetEndPointManager() const { return mEndPointManager; }
      60             : 
      61             :     /**
      62             :      *  Returns a reference to the System::Layer associated with this object.
      63             :      */
      64         326 :     chip::System::Layer & GetSystemLayer() const { return mEndPointManager.SystemLayer(); }
      65             : 
      66             :     void * mAppState;
      67             : 
      68             : private:
      69             :     EndPointManager<EndPoint> & mEndPointManager; /**< Factory that owns this object. */
      70             : };
      71             : 
      72             : template <typename EndPointType>
      73             : class EndPointDeletor
      74             : {
      75             : public:
      76          89 :     static void Release(EndPointType * obj) { obj->GetEndPointManager().DeleteEndPoint(obj); }
      77             : };
      78             : 
      79             : } // namespace Inet
      80             : } // namespace chip

Generated by: LCOV version 1.14