Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::anonymous_namespace{statetools.cpp} Namespace Reference

Classes

struct  Condition
 What state_wait waits for. More...
struct  ObjectState
 One object in a snapshot. More...
struct  Snapshot
 A snapshot: objects by id, in tree order. More...
struct  Snapshots
 The snapshots, oldest first, shared by the two tools. More...

Functions

bool truthy (const QJsonValue &v)
 Whether v counts as true: true, non-zero, or a non-empty string, array or object.
bool passes (const Condition &c, const QJsonValue &value)
 Whether value passes c's test.
std::optional< Condition > parseCondition (const QJsonObject &args, QString *error)
 Parses state_wait's arguments.
bool check (const Condition &c, QString *state, QJsonValue *value, QString *error)
 One check of c.
void waitUntil (const ToolCall &call)
 The state_wait tool.
QMap< QString, QString > propertyValues (const QObject *o)
 The readable properties of o, as compact JSON text.
Snapshot takeSnapshot (const QObjectList &start, int maxObjects)
 Takes a snapshot of the objects under start (breadth-first, hidden ones included).
std::optional< QObjectList > snapshotStart (const QString &root, QString *error)
 The objects a snapshot starts from: the object root names, or the roots of the tree.
ToolResult stateSnapshot (Snapshots *snapshots, const QJsonObject &args)
 The state_snapshot tool.
int objectChanges (const ObjectState &before, const ObjectState &after, const QSet< QString > &ignore, QStringList *lines)
 Appends the changes of one object to lines, skipping ignore.
int diffLines (const Snapshot &from, const Snapshot &to, const QSet< QString > &ignore, QStringList *lines)
 The "+", "-" and "~" lines from from to to.
const Snapshot * namedSnapshot (const Snapshots *snapshots, const QJsonObject &args, const QString &key, QString *error)
 The snapshot named by the argument key, with an error listing the kept ones if there is none.
ToolResult stateDiff (const Snapshots *snapshots, const QJsonObject &args)
 The state_diff tool.
void installAppStatus (Server &server)
 Registers app_status, which runs on the sessions' thread.
void installStallArm (Server &server)
 Registers app_stall_arm, which runs on the sessions' thread (design 0016).
void installWaitUntil (Server &server)
 Registers state_wait.
void installSnapshots (Server &server)
 Registers state_snapshot and state_diff.

Variables

constexpr int kPollMs = 50
 How often state_wait checks its condition.
constexpr int kDefaultTimeoutMs = 5000
 Default and longest state_wait timeout.
constexpr int kMaxTimeoutMs = 60000
 See kDefaultTimeoutMs.
constexpr qsizetype kMaxSnapshots = 5
 Most snapshots kept; the oldest goes when another is taken.
constexpr int kDefaultSnapshotObjects = 2000
 Default and largest number of objects in a snapshot.
constexpr int kMaxSnapshotObjects = 10000
 See kDefaultSnapshotObjects.
constexpr qsizetype kMaxValueText = 200
 Longest property value kept in a snapshot, as JSON text.
constexpr int kDefaultChanges = 200
 Default and largest number of changes state_diff lists.
constexpr int kMaxChanges = 2000
 See kDefaultChanges.

Function Documentation

◆ check()

bool Sonde::anonymous_namespace{statetools.cpp}::check ( const Condition & c,
QString * state,
QJsonValue * value,
QString * error )

One check of c.

Returns
Whether it holds; state describes what was seen, and error is set if the condition can never hold (an object without the property).

◆ diffLines()

int Sonde::anonymous_namespace{statetools.cpp}::diffLines ( const Snapshot & from,
const Snapshot & to,
const QSet< QString > & ignore,
QStringList * lines )

The "+", "-" and "~" lines from from to to.

Returns
How many changes.

◆ objectChanges()

int Sonde::anonymous_namespace{statetools.cpp}::objectChanges ( const ObjectState & before,
const ObjectState & after,
const QSet< QString > & ignore,
QStringList * lines )

Appends the changes of one object to lines, skipping ignore.

Returns
How many.

◆ parseCondition()

std::optional< Condition > Sonde::anonymous_namespace{statetools.cpp}::parseCondition ( const QJsonObject & args,
QString * error )

Parses state_wait's arguments.

Returns
The condition, or std::nullopt with error set.