MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / valueHandle

Method valueHandle

app/src/API/Handlers/DataTablesHandler.cpp:734–759  ·  view source on GitHub ↗

* @brief Resolves a (table, register) pair to a reusable handle for the marshalled fast path. */

Source from the content-addressed store, hash-verified

732 * @brief Resolves a (table, register) pair to a reusable handle for the marshalled fast path.
733 */
734API::CommandResponse API::Handlers::DataTablesHandler::valueHandle(const QString& id,
735 const QJsonObject& params)
736{
737 QString table;
738 QString name;
739 if (!requireString(params, QStringLiteral("table"), table))
740 return CommandResponse::makeError(
741 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: table"));
742
743 if (!requireString(params, QStringLiteral("name"), name))
744 return CommandResponse::makeError(
745 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: name"));
746
747 const auto& store = DataModel::FrameBuilder::instance().tableStore();
748 if (!store.isInitialized())
749 return CommandResponse::makeError(
750 id, ErrorCode::InvalidParam, QStringLiteral("Data-table store not initialized (no project)"));
751
752 const qint64 handle = store.handleOf(table, name);
753
754 QJsonObject result;
755 result[QStringLiteral("table")] = table;
756 result[QStringLiteral("name")] = name;
757 result[QStringLiteral("handle")] = static_cast<double>(handle);
758 return CommandResponse::makeSuccess(id, result);
759}
760
761/**
762 * @brief Returns a register's live value by handle; found=false for a stale or invalid handle.

Callers

nothing calls this directly

Calls 3

requireStringFunction · 0.85
isInitializedMethod · 0.80
handleOfMethod · 0.80

Tested by

no test coverage detected