Coverage Report

Created: 2025-06-24 06:17

/src/connectedhomeip/src/inet/EndPointBasis.h
Line
Count
Source
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
43
    EndPointBasis(EndPointManager<EndPoint> & endPointManager) : mAppState(nullptr), mEndPointManager(endPointManager) {}
chip::Inet::EndPointBasis<chip::Inet::UDPEndPoint>::EndPointBasis(chip::Inet::EndPointManager<chip::Inet::UDPEndPoint>&)
Line
Count
Source
54
42
    EndPointBasis(EndPointManager<EndPoint> & endPointManager) : mAppState(nullptr), mEndPointManager(endPointManager) {}
chip::Inet::EndPointBasis<chip::Inet::TCPEndPoint>::EndPointBasis(chip::Inet::EndPointManager<chip::Inet::TCPEndPoint>&)
Line
Count
Source
54
1
    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
43
    EndPointManager<EndPoint> & GetEndPointManager() const { return mEndPointManager; }
chip::Inet::EndPointBasis<chip::Inet::UDPEndPoint>::GetEndPointManager() const
Line
Count
Source
59
42
    EndPointManager<EndPoint> & GetEndPointManager() const { return mEndPointManager; }
chip::Inet::EndPointBasis<chip::Inet::TCPEndPoint>::GetEndPointManager() const
Line
Count
Source
59
1
    EndPointManager<EndPoint> & GetEndPointManager() const { return mEndPointManager; }
60
61
    /**
62
     *  Returns a reference to the System::Layer associated with this object.
63
     */
64
132
    chip::System::Layer & GetSystemLayer() const { return mEndPointManager.SystemLayer(); }
chip::Inet::EndPointBasis<chip::Inet::UDPEndPoint>::GetSystemLayer() const
Line
Count
Source
64
126
    chip::System::Layer & GetSystemLayer() const { return mEndPointManager.SystemLayer(); }
chip::Inet::EndPointBasis<chip::Inet::TCPEndPoint>::GetSystemLayer() const
Line
Count
Source
64
6
    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
43
    static void Release(EndPointType * obj) { obj->GetEndPointManager().DeleteEndPoint(obj); }
chip::Inet::EndPointDeletor<chip::Inet::UDPEndPoint>::Release(chip::Inet::UDPEndPoint*)
Line
Count
Source
76
42
    static void Release(EndPointType * obj) { obj->GetEndPointManager().DeleteEndPoint(obj); }
chip::Inet::EndPointDeletor<chip::Inet::TCPEndPoint>::Release(chip::Inet::TCPEndPoint*)
Line
Count
Source
76
1
    static void Release(EndPointType * obj) { obj->GetEndPointManager().DeleteEndPoint(obj); }
77
};
78
79
} // namespace Inet
80
} // namespace chip