Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::Cli::Endpoints Class Reference

This checkout's endpoints, with {instance} resolved. More...

#include <endpoints.h>

Public Member Functions

 Endpoints (const QJsonObject &config, const QString &root)
 The endpoints of config, whose paths are relative to root.
QString url () const
 The MCP URL on the port, or an empty string if there is no port.
QList< quint16 > candidatePorts () const
 The ports the application may have taken: its first choice, then the rest of the range.
bool learnPort (std::optional< qint64 > pid=std::nullopt)
 Asks the running copy which port it took (design 0019).
QStringList describe () const
 The endpoints, as sonde names them in its output.
void write (const QString &path) const
 Writes them to path (endpoint.json), as the Python sonde did.
QString instance () const
 The instance key, or an empty string if the executable wasn't found.
std::optional< QString > executable () const
 The executable's canonical path, or nothing if it wasn't found.
QString local () const
 The local socket's name, or an empty string for none.
quint16 port () const
 The HTTP port (with {instance}, the first choice until learnPort()), or 0.
std::optional< std::pair< quint16, quint16 > > portRange () const
 The range {instance} chooses from, or nothing without {instance}.

Private Attributes

QString m_instance
 See instance().
std::optional< QString > m_executable
 See executable().
QString m_local
 See local().
quint16 m_port = 0
 See port().
std::optional< std::pair< quint16, quint16 > > m_range
 See portRange().
bool m_confirmed = false
 Whether a running copy said m_port is its port.

Detailed Description

This checkout's endpoints, with {instance} resolved.

Constructor & Destructor Documentation

◆ Endpoints()

Sonde::Cli::Endpoints::Endpoints ( const QJsonObject & config,
const QString & root )

The endpoints of config, whose paths are relative to root.

Fails if "http" isn't valid, or {instance} is used and the executable isn't found.

Member Function Documentation

◆ learnPort()

bool Sonde::Cli::Endpoints::learnPort ( std::optional< qint64 > pid = std::nullopt)

Asks the running copy which port it took (design 0019).

Through the local socket if there is one. Without it, looks on the ports it may have taken for a copy of this executable (with process id pid, if given): another checkout's copy may be on one of them.

Returns
Whether it answered.

The documentation for this class was generated from the following files: