MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / toolboxObjectReadLatestAt

Function toolboxObjectReadLatestAt

pj_datastore/src/plugin_data_host.cpp:1804–1836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1802}
1803
1804bool toolboxObjectReadLatestAt(
1805 void* ctx, PJ_object_topic_handle_t topic, int64_t timestamp_ns, PJ_object_bytes_handle_t* out_handle,
1806 int64_t* out_timestamp, PJ_error_t* out_error) noexcept {
1807 auto* impl = static_cast<DatastoreToolboxObjectReadHostState*>(ctx);
1808 if (out_handle == nullptr) {
1809 propagateError(out_error, "out_handle must not be null");
1810 return false;
1811 }
1812 *out_handle = nullptr;
1813 try {
1814 auto entry = impl->store.latestAt(ObjectTopicId{topic.id}, timestamp_ns);
1815 if (!entry.has_value() || entry->payload.anchor == nullptr) {
1816 impl->setError("no entry at-or-before timestamp");
1817 propagateError(out_error, impl->last_error.c_str());
1818 return false;
1819 }
1820 auto* payload_handle = new sdk::PayloadView(std::move(entry->payload));
1821 *out_handle = reinterpret_cast<PJ_object_bytes_handle_t>(payload_handle);
1822 if (out_timestamp != nullptr) {
1823 *out_timestamp = entry->timestamp;
1824 }
1825 impl->last_error.clear();
1826 return true;
1827 } catch (const std::exception& e) {
1828 impl->setError(e.what());
1829 propagateError(out_error, impl->last_error.c_str());
1830 return false;
1831 } catch (...) {
1832 impl->setError("readLatestAt: unknown exception");
1833 propagateError(out_error, impl->last_error.c_str());
1834 return false;
1835 }
1836}
1837
1838void toolboxObjectGetBytes(PJ_object_bytes_handle_t handle, const uint8_t** out_data, uint64_t* out_size) noexcept {
1839 if (out_data != nullptr) {

Callers

nothing calls this directly

Calls 4

propagateErrorFunction · 0.85
latestAtMethod · 0.45
setErrorMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected