|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
Finds an object's debug id, then fetches it with its properties. More...
Public Types | |
| using | Fetched = std::function<void(const ServiceObject &, const QList<ServiceObject> &)> |
| Called with a fetched object and its children's own data. | |
Public Member Functions | |
| Lookup (QObject *object, QObject *context, FetchCallback done) | |
Looks up object for done, unless context goes away first. | |
| void | start () |
| Starts with the cached id, if there is one, else with the engines. | |
Private Member Functions | |
| void | enginesListed (QDataStream *answer, const QString &error) |
| LIST_ENGINES answered: list each engine's objects. | |
| void | listObjects (QList< int > engines) |
Gathers the component roots of engines, one engine at a time. | |
| void | objectsListed (QDataStream *answer, const QString &error, const QList< int > &engines) |
| LIST_OBJECTS answered for one engine: keep its roots, then the next engine. | |
| QList< ServiceObject > | listedAs (const QObject *object) const |
The listed roots that could be object, by objectName, QML id and file. | |
| void | pickRoot (int from) |
Looks for the nearest component root, from chain index from up. | |
| void | compareValues (const QList< ServiceObject > &candidates, int k, int index, int match) |
Fetches candidate index of candidates for chain index k, and keeps the one whose values match (match); the next root up if none or several do. | |
| void | walk (int id, int level) |
Walks down from id, which is chain index level, to the target. | |
| void | walked (int level, int index, const QList< ServiceObject > &children) |
One level down: the child at index of children is chain index level - 1. | |
| void | fetchTarget (int id) |
Fetches the target, id, with its properties, and answers. | |
| void | targetFetched (int id, const ServiceObject &o) |
The target, id, came back as o: check it, remember its id, answer. | |
| void | fetch (int id, bool properties, Fetched then) |
Fetches object id (with its properties if properties) and its children's own data, then calls then. | |
| void | fail (const QString &why) |
Answers with why. | |
Private Attributes | |
| QPointer< QObject > | m_context |
| The answer is dropped if this is gone. | |
| FetchCallback | m_done |
| Gets the answer. | |
| QList< QPointer< QObject > > | m_chain |
| The target, then its parents up to the top. | |
| QList< ServiceObject > | m_listed |
| The component roots the service listed. | |
| Fetched | m_fetched |
| What the fetch in flight continues with. | |
Finds an object's debug id, then fetches it with its properties.
The service lists only the roots of component instances, with their objectName, QML id and file. So the lookup finds the nearest ancestor that is such a root and that the listing names unambiguously (comparing property values when instances look the same), then walks down from it, one level at a time, by position among each object's children (the service counts them as QObject::children() without QQmlContext objects). Fetches never recurse: a recursive fetch makes the service create deferred objects.
|
inlineprivate |
Fetches object id (with its properties if properties) and its children's own data, then calls then.
One fetch at a time: the lookup is a sequence.