Heart
1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Toggle main menu visibility
Loading...
Searching...
No Matches
asyncrenderloop.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2025-2025 QuasarApp.
3
* Distributed under the lgplv3 software license, see the accompanying
4
* Everyone is permitted to copy and distribute verbatim copies
5
* of this license document, but changing it is not allowed.
6
*/
7
8
#ifndef ASYNCRENDERLOOP_H
9
#define ASYNCRENDERLOOP_H
10
11
#include "
async.h
"
12
13
namespace
QH
{
14
58
class
HEARTSHARED_EXPORT
AsyncRenderLoop
:
public
Async
59
{
60
61
Q_OBJECT
62
public
:
63
71
template
<
typename
T>
72
class
MainSharedPtr
{
73
public
:
74
MainSharedPtr
() {
75
static_assert
(std::is_base_of_v<AsyncRenderLoop, T>,
76
"T must be derived from AsyncRenderLoop"
);
77
}
78
79
MainSharedPtr
(
const
QSharedPointer<T>& ptr): _ptr(ptr) {
80
static_assert
(std::is_base_of_v<AsyncRenderLoop, T>,
81
"T must be derived from AsyncRenderLoop"
);
82
}
83
~MainSharedPtr
() {
84
if
(_ptr) {
85
_ptr->stop();
86
}
87
}
88
89
T*
operator->
()
const
{
90
return
_ptr.operator->();
91
}
92
97
T*
get
()
const
{
98
return
_ptr.get();
99
}
100
106
template
<
typename
... Args>
107
[[nodiscard]]
static
MainSharedPtr
create
(Args && ...arguments) {
108
return
MainSharedPtr
(QSharedPointer<T>::create(std::forward<Args>(arguments)...));
109
}
110
115
const
QSharedPointer<T>&
getShared
()
const
{
116
return
_ptr;
117
}
118
119
private
:
120
QSharedPointer<T> _ptr;
121
};
122
123
124
AsyncRenderLoop
(QThread* thread);
125
~AsyncRenderLoop
();
126
130
virtual
void
run();
131
135
virtual
void
stop();
136
141
bool
isRun()
const
;
142
150
template
<
typename
Type,
typename
... Args>
151
static
MainSharedPtr<Type>
createMainPtr
(Args && ...arguments) {
152
return
MainSharedPtr<Type>
(QSharedPointer<Type>::create(std::forward<Args>(arguments)...));
153
};
154
155
protected
:
156
164
virtual
void
renderIteration
(
int
mmsec) = 0;
165
166
private
slots:
167
void
renderLoopPrivate();
168
169
private
:
170
bool
m_run =
false
;
171
std::chrono::time_point<std::chrono::high_resolution_clock> _lastIterationTime;
172
173
};
174
}
175
176
#endif
// ASYNCRENDERLOOP_H
async.h
QH::AsyncRenderLoop::MainSharedPtr
The MainSharedPtr class is a helper class for creating a shared pointer to the render loop.
Definition
asyncrenderloop.h:72
QH::AsyncRenderLoop::MainSharedPtr::operator->
T * operator->() const
Definition
asyncrenderloop.h:89
QH::AsyncRenderLoop::MainSharedPtr::MainSharedPtr
MainSharedPtr(const QSharedPointer< T > &ptr)
Definition
asyncrenderloop.h:79
QH::AsyncRenderLoop::MainSharedPtr::create
static MainSharedPtr create(Args &&...arguments)
create This method creates a shared pointer to the render loop.
Definition
asyncrenderloop.h:107
QH::AsyncRenderLoop::MainSharedPtr::getShared
const QSharedPointer< T > & getShared() const
getShared This method return child shared pointer. You can use them as a general shared pointer of th...
Definition
asyncrenderloop.h:115
QH::AsyncRenderLoop::MainSharedPtr::get
T * get() const
get This is a alias of the QSharedPointer::get method.
Definition
asyncrenderloop.h:97
QH::AsyncRenderLoop::MainSharedPtr::MainSharedPtr
MainSharedPtr()
Definition
asyncrenderloop.h:74
QH::AsyncRenderLoop::MainSharedPtr::~MainSharedPtr
~MainSharedPtr()
Definition
asyncrenderloop.h:83
QH::AsyncRenderLoop
The AsyncRenderLoop is a class for asynchronous rendering. This class is used to create a render loop...
Definition
asyncrenderloop.h:59
QH::AsyncRenderLoop::AsyncRenderLoop
AsyncRenderLoop(QThread *thread)
Definition
asyncrenderloop.cpp:14
QH::AsyncRenderLoop::renderIteration
virtual void renderIteration(int mmsec)=0
renderIteration This method is called in each iteration of the render loop. This method must be imple...
QH::AsyncRenderLoop::createMainPtr
static MainSharedPtr< Type > createMainPtr(Args &&...arguments)
createMainPtr This method creates a shared pointer to the render loop.
Definition
asyncrenderloop.h:151
QH::Async::Async
Async(QThread *thread)
Async This is default constructor of the async object.
Definition
async.cpp:38
QH
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition
heart.cpp:13
src
public
asyncrenderloop.h
Generated by
1.18.0