5#include <QtQml/QQmlEngine>
6#include <QtQml/QQmlIncubator>
7#include <QtQuick/QQuickItem>
13class PoolIncubator :
public QQmlIncubator {
15 PoolIncubator(Pool* p, qint64
id, IncubationMode mode);
18 void statusChanged(Status)
override;
19 void setInitialState(QObject*)
override;
26class Pool :
public QObject {
30 Q_PROPERTY(
bool async READ async WRITE setAsync NOTIFY asyncChanged FINAL)
32 friend class PoolIncubator;
35 Pool(QObject* parent =
nullptr);
38 Q_INVOKABLE
bool contains(
const QString& key)
const;
39 Q_INVOKABLE QObject* get(
const QString& key)
const;
40 Q_INVOKABLE
void add(
const QVariant&,
const QVariantMap&,
bool autoKey =
false);
41 Q_INVOKABLE
void addWithKey(
const QString& key,
const QVariant& url_module_comp,
43 Q_SIGNAL
void objectAdded(QObject* obj,
const QVariant& key );
45 auto async() const ->
bool;
47 Q_SIGNAL
void asyncChanged(
bool);
49 Q_INVOKABLE
bool removeObject(QObject*);
50 Q_INVOKABLE
void clear();
52 void add(std::optional<QStringView> key, QQmlComponent* comp, const QVariantMap&);
55 Q_SIGNAL
void queueAdded(qint64);
56 Q_SLOT
void onQueueAdded(qint64);
57 Q_SLOT
void onUncacheObjectDeleted(QObject*);
61 bool hasKey {
false };
62 QObject*
object {
nullptr };
64 QPointer<QQmlComponent> component {};
65 PoolIncubator* incubator {
nullptr };
68 void incubatorStateChanged(qint64
id, QQmlIncubator::Status status);
69 void setInitialState(QObject* o);
70 auto genSerial() const -> qint64;
71 void onComponentProgress(qint64
id, qreal);
72 void onComponentLoaded(qint64
id);
73 auto createComponent() -> QQmlComponent*;
74 auto tryCreateComponent(const QVariant&) -> QQmlComponent*;
75 auto tryCache(QStringView) ->
bool;
77 using task_iterator = std::map<qint64, Task>::iterator;
78 void clearTask(task_iterator);
80 mutable qint64 m_serial;
81 std::map<qint64, Task> m_tasks;
82 std::map<QString, QPointer<QObject>, std::less<>> m_objs;
83 std::set<QObject*> m_nokey_objs;