2023-07-10 13:54:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QSGNode>
|
|
|
|
|
2023-07-17 08:03:33 +00:00
|
|
|
namespace QskSGNode
|
2023-07-20 14:12:54 +00:00
|
|
|
{
|
|
|
|
namespace detail
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
2023-07-20 14:12:54 +00:00
|
|
|
template< typename... Ts >
|
|
|
|
struct append;
|
2023-07-10 13:54:53 +00:00
|
|
|
|
2023-07-20 14:12:54 +00:00
|
|
|
template<>
|
|
|
|
struct append<>
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
2023-07-20 14:12:54 +00:00
|
|
|
static void nodes( QSGNode* root )
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
|
|
|
}
|
2023-07-20 14:12:54 +00:00
|
|
|
};
|
2023-07-10 13:54:53 +00:00
|
|
|
|
2023-07-20 14:12:54 +00:00
|
|
|
template< typename Child, typename... Children >
|
|
|
|
struct append< Child, Children... >
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
2023-07-20 14:12:54 +00:00
|
|
|
static void nodes( QSGNode* root )
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
2023-07-20 14:12:54 +00:00
|
|
|
auto* const child = new Child;
|
|
|
|
root->appendChildNode( child );
|
|
|
|
append< Children... >::nodes( child );
|
2023-07-10 13:54:53 +00:00
|
|
|
}
|
2023-07-20 14:12:54 +00:00
|
|
|
};
|
|
|
|
}
|
2023-07-10 13:54:53 +00:00
|
|
|
|
2023-07-20 14:12:54 +00:00
|
|
|
template< typename Root, typename... Children >
|
|
|
|
inline Q_REQUIRED_RESULT Root* ensureNode( QSGNode* root = nullptr )
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
2023-07-20 14:12:54 +00:00
|
|
|
if ( root == nullptr )
|
2023-07-10 13:54:53 +00:00
|
|
|
{
|
2023-07-20 14:12:54 +00:00
|
|
|
root = new Root;
|
|
|
|
detail::append< Children... >::nodes( root );
|
2023-07-10 13:54:53 +00:00
|
|
|
}
|
2023-07-20 14:12:54 +00:00
|
|
|
return static_cast< Root* >( root );
|
|
|
|
}
|
2023-07-10 13:54:53 +00:00
|
|
|
}
|