ACF $AcfVersion:0$
TTransPtr.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// Qt includes
6#include <QtCore/QSharedPointer>
7
8
9namespace istd
10{
11
12
20template <class Type>
22{
23public:
27 bool IsValid() const;
28
32 const Type* GetPtr() const;
33
37 Type* GetPtr();
38
42 void Reset();
43
47 void Swap(TTransPtr& pointer);
48
49 template <class CastedType>
50 CastedType Cast() const
51 {
52 return dynamic_cast<CastedType>(GetPtr());
53 }
54
55 // operators
60 Type& operator*() const;
61 Type* operator->() const;
62
63 QSharedPointer<Type> m_impl;
64
65protected:
67};
68
69
70// public methods
71
72template<class Type>
73inline bool TTransPtr<Type>::IsValid() const
74{
75 return m_impl.data() != NULL;
76}
77
78
79template<class Type>
80inline const Type * TTransPtr<Type>::GetPtr() const
81{
82 return m_impl.data();
83}
84
85
86template<class Type>
88{
89 return m_impl.data();
90}
91
92
93template<class Type>
95{
96 m_impl.reset();
97}
98
99
100template<class Type>
102{
103 m_impl.swap(pointer);
104}
105
106
107template<class Type>
108inline Type & TTransPtr<Type>::operator*() const
109{
110 return *m_impl;
111}
112
113
114template<class Type>
115inline Type * TTransPtr<Type>::operator->() const
116{
117 return m_impl.data();
118}
119
120
121template<class Type>
123{
124}
125
126
127} // namespace istd
128
129
130
131
Implementation of data transfer smart pointer.
Definition TTransPtr.h:22
Type * GetPtr()
Get access to pointed object.
Definition TTransPtr.h:87
const Type * GetPtr() const
Get access to pointed object.
Definition TTransPtr.h:80
CastedType Cast() const
Definition TTransPtr.h:50
bool IsValid() const
Check, whether the object is in valid state.
Definition TTransPtr.h:73
Type * operator->() const
Definition TTransPtr.h:115
Type & operator*() const
Copy operator overtaking the pointer.
Definition TTransPtr.h:108
QSharedPointer< Type > m_impl
Definition TTransPtr.h:63
void Swap(TTransPtr &pointer)
Swap two pointers.
Definition TTransPtr.h:101
void Reset()
Set this pointer to NULL.
Definition TTransPtr.h:94
#define NULL
Definition istd.h:74
Standard library.
Definition IComponent.h:17