Files
logos-protocol/cpp/logos_instance.h
T
Dario Lipicar 29afbac532 Extract the Logos protocol layer from logos-cpp-sdk (lp_* C ABI + protocol semver) (#2)
* Extract the Logos protocol layer from logos-cpp-sdk

Transports (plain TCP/TLS, qt_local, qt_remote/QRO, mock), token manager,
consumer core (LogosAPIClient/LogosAPIConsumer incl. the capability
auto-requestModule flow), ModuleProxy, the abstract LogosProviderObject
interface, and the canonical QVariant<->JSON conversion — now behind the
language-neutral lp_* C ABI (logos_protocol.h) carrying the protocol
semver (LOGOS_PROTOCOL_VERSION_*, lp_protocol_version()).

Bytes crossing the ABI use the lossless {"_bytes": base64url} tagging
(NUL-safe), matching the plain wire encoding.

Provider lp_* surface is compiled groundwork; serving lands with module
authoring.

* consumer: typed requestModule for the capability flow

Port of logos-cpp-sdk master f5a127dd ('use updated capability module',
cpp-sdk#85, Iuri Matias) — the touched files (logos_api_client.cpp,
logos_api_consumer.{h,cpp}) moved into this repo in the P1 extraction.
The capability auto-requestModule path now calls a typed std::string
helper on the consumer (which acquires the capability object directly)
instead of a stringly invokeRemoteMethod round-trip. 111/111 tests.
2026-06-12 18:59:01 -03:00

33 lines
1.0 KiB
C++

#ifndef LOGOS_INSTANCE_H
#define LOGOS_INSTANCE_H
#include <QDebug>
#include <QString>
#include <QUuid>
/**
* @brief LogosInstance provides a shared identifier for all processes launched
* by Logos core
*
* The root process generates a UUID-based ID and exports it via the
* LOGOS_INSTANCE_ID environment variable. Child processes inherit the variable
* and return the same ID, so all processes in the application tree share one
* ID. Used by both provider and consumer to build matching registry URLs.
*/
namespace LogosInstance {
inline const QString id() {
const QByteArray inherited = qgetenv("LOGOS_INSTANCE_ID");
if (!inherited.isEmpty())
return QString::fromUtf8(inherited);
const QString newId = QUuid::createUuid().toString(QUuid::Id128).left(12);
qputenv("LOGOS_INSTANCE_ID", newId.toUtf8());
return newId;
}
inline QString id(const QString& moduleName) {
return QString("local:logos_%1_%2").arg(moduleName).arg(id());
}
}
#endif // LOGOS_INSTANCE_H