ACF $AcfVersion:0$
TCompPtr.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <icomp/IComponent.h>
8
9
10template <class InterfaceType>
11class TSharedCompPtr: protected CInterfaceManipBase
12{
13public:
14 TSharedCompPtr(const TCompPtr& source)
15 :m_ptr(source.ptr)
16 {
17 }
18
20 {
21 m_ptr.SetPtr(ptr, ExtractIntefrace<InterfaceType>(ptr));
22 }
23
24 bool IsValid() const
25 {
26 return m_ptr.IsValid();
27 }
28
29 const InterfaceType* operator->() const
30 {
31 Q_ASSERT(m_ptr.IsValid());
32
33 return m_ptr.operator->();
34 }
35
36 InterfaceType* operator->()
37 {
38 Q_ASSERT(m_ptr.IsValid());
39
40 return m_ptr.operator->();
41 }
42
43 const InterfaceType& operator*() const
44 {
45 Q_ASSERT(m_ptr.IsValid());
46
47 return *m_ptr;
48 }
49
50 InterfaceType& operator*()
51 {
52 Q_ASSERT(m_ptr.IsValid());
53
54 return *m_ptr;
55 }
56
57private:
59 PtrImpl m_ptr;
60};
61
62
63} // namespace icomp
64
65
const InterfaceType * operator->() const
Definition TCompPtr.h:29
InterfaceType & operator*()
Definition TCompPtr.h:50
bool IsValid() const
Definition TCompPtr.h:24
TSharedCompPtr(icomp::IComponent *ptr)
Definition TCompPtr.h:19
const InterfaceType & operator*() const
Definition TCompPtr.h:43
TSharedCompPtr(const TCompPtr &source)
Definition TCompPtr.h:14
InterfaceType * operator->()
Definition TCompPtr.h:36
Main component interface.
Definition IComponent.h:32
bool IsValid() const noexcept
void SetPtr(InterfaceType *interfacePtr)
Shared ownership smart pointer for interface types.