11#include "as_components.hpp"
12#include "component_column.hpp"
14#include "spawn_options.hpp"
15#include "time_column.hpp"
18 struct ComponentBatch;
20 enum class StoreKind {
68 std::string_view app_id, std::string_view recording_id = std::string_view(),
69 StoreKind store_kind = StoreKind::Recording
147 std::string_view tcp_addr =
"127.0.0.1:9876",
float flush_timeout_sec = 2.0
161 std::string_view tcp_addr =
"127.0.0.1:9876",
float flush_timeout_sec = 2.0
181 template <
typename TRep,
typename TPeriod>
184 std::chrono::duration<TRep, TPeriod> flush_timeout = std::chrono::seconds(2)
186 using seconds_float = std::chrono::duration<float>;
187 return spawn(options, std::chrono::duration_cast<seconds_float>(flush_timeout).count());
245 template <
typename TClock>
246 void set_time(std::string_view timeline_name, std::chrono::time_point<TClock> time)
const {
247 set_time(timeline_name, time.time_since_epoch());
259 template <
typename TRep,
typename TPeriod>
260 void set_time(std::string_view timeline_name, std::chrono::duration<TRep, TPeriod> time)
262 if constexpr (std::is_floating_point<TRep>::value) {
263 using seconds_double =
264 std::chrono::duration<double>;
267 std::chrono::duration_cast<seconds_double>(time).count()
272 std::chrono::duration_cast<std::chrono::nanoseconds>(time).count()
359 template <
typename... Ts>
360 void log(std::string_view entity_path,
const Ts&... archetypes_or_collections)
const {
367 template <
typename... Ts>
368 [[deprecated(
"Use `log_static` instead")]]
void log_timeless(
369 std::string_view entity_path,
const Ts&... archetypes_or_collections
371 return log_static(entity_path, archetypes_or_collections...);
387 template <
typename... Ts>
388 void log_static(std::string_view entity_path,
const Ts&... archetypes_or_collections)
406 template <
typename... Ts>
407 Error try_log(std::string_view entity_path,
const Ts&... archetypes_or_collections)
const {
414 template <
typename... Ts>
415 [[deprecated(
"Use `try_log_static` instead")]]
Error try_log_timeless(
416 std::string_view entity_path,
const Ts&... archetypes_or_collections
432 template <
typename... Ts>
441 template <
typename... Ts>
442 [[deprecated(
"Use `log_with_static` instead")]]
void log_with_timeless(
443 std::string_view entity_path,
bool timeless,
const Ts&... archetypes_or_collections
445 return log_with_static(entity_path, timeless, archetypes_or_collections...);
463 template <
typename... Ts>
465 std::string_view entity_path,
bool static_,
const Ts&... archetypes_or_collections
470 template <
typename... Ts>
471 [[deprecated(
"Use `try_log_with_static` instead")]]
Error try_log_with_timeless(
472 std::string_view entity_path,
bool static_,
const Ts&... archetypes_or_collections
493 template <
typename... Ts>
495 std::string_view entity_path,
bool static_,
const Ts&... archetypes_or_collections
500 std::vector<ComponentBatch> serialized_columns;
509 AsComponents<Ts>().serialize(archetypes_or_collections);
510 if (serialization_result.
is_err()) {
511 err = serialization_result.error;
515 if (serialized_columns.empty()) {
517 serialized_columns = std::move(serialization_result.value);
519 serialized_columns.insert(
520 serialized_columns.end(),
521 std::make_move_iterator(serialization_result.value.begin()),
522 std::make_move_iterator(serialization_result.value.end())
528 RR_RETURN_NOT_OK(err);
548 std::string_view entity_path,
bool static_, std::vector<ComponentBatch> batches
564 std::string_view entity_path,
size_t num_data_cells,
const ComponentBatch* data_cells,
587 const std::filesystem::path& filepath,
588 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
612 const std::filesystem::path& filepath,
613 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
637 const std::filesystem::path& filepath,
const std::byte* contents,
size_t contents_size,
638 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
671 const std::filesystem::path& filepath,
const std::byte* contents,
size_t contents_size,
672 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
693 template <
typename... Ts>
717 template <
typename... Ts>
725 std::vector<ComponentColumn> serialized_columns;
735 if (serialization_result.
is_err()) {
736 err = serialization_result.error;
739 serialized_columns.emplace_back(std::move(serialization_result.value));
743 RR_RETURN_NOT_OK(err);
745 return try_send_columns(entity_path, time_columns, std::move(serialized_columns));
798 StoreKind _store_kind;
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
void handle() const
Handle this error based on the set log handler.
bool is_err() const
Returns true if the code is not Ok.
Definition error.hpp:131
static Error ok()
Creates a new error set to ok.
Definition error.hpp:116
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Error spawn(const SpawnOptions &options={}, float flush_timeout_sec=2.0) const
Spawns a new Rerun Viewer process from an executable available in PATH, then connects to it over TCP.
Error try_send_columns(std::string_view entity_path, Collection< TimeColumn > time_columns, Collection< ComponentColumn > component_columns) const
Directly log a columns of data to Rerun.
void log_file_from_path(const std::filesystem::path &filepath, std::string_view entity_path_prefix=std::string_view(), bool static_=false) const
Logs the file at the given path using all DataLoaders available.
Definition recording_stream.hpp:586
bool is_enabled() const
Returns whether the recording stream is enabled.
Definition recording_stream.hpp:99
Error try_log_static(std::string_view entity_path, const Ts &... archetypes_or_collections) const
Logs one or more archetype and/or component batches as static data, returning an error.
Definition recording_stream.hpp:433
void disable_timeline(std::string_view timeline_name) const
Stops logging to the specified timeline for subsequent log calls.
void reset_time() const
Clears out the current time of the recording, for the current calling thread.
Error to_stdout() const
Stream all log-data to standard output.
void send_columns(std::string_view entity_path, Collection< TimeColumn > time_columns, Collection< ComponentColumn > component_columns) const
Directly log a columns of data to Rerun.
Definition recording_stream.hpp:765
Error try_log_file_from_path(const std::filesystem::path &filepath, std::string_view entity_path_prefix=std::string_view(), bool static_=false) const
Logs the file at the given path using all DataLoaders available.
Error save(std::string_view path) const
Stream all log-data to a given .rrd file.
void log_with_static(std::string_view entity_path, bool static_, const Ts &... archetypes_or_collections) const
Logs one or more archetype and/or component batches optionally static, returning an error.
Definition recording_stream.hpp:464
StoreKind kind() const
Returns the store kind as passed during construction.
Definition recording_stream.hpp:91
void log(std::string_view entity_path, const Ts &... archetypes_or_collections) const
Logs one or more archetype and/or component batches.
Definition recording_stream.hpp:360
Error try_send_columns(std::string_view entity_path, Collection< TimeColumn > time_columns, Collection< Ts >... component_columns) const
Directly log a columns of data to Rerun.
Definition recording_stream.hpp:718
Error spawn(const SpawnOptions &options={}, std::chrono::duration< TRep, TPeriod > flush_timeout=std::chrono::seconds(2)) const
Definition recording_stream.hpp:182
Error try_log_data_row(std::string_view entity_path, size_t num_data_cells, const ComponentBatch *data_cells, bool inject_time) const
Bottom level API that logs raw data cells to the recording stream.
void log_file_from_contents(const std::filesystem::path &filepath, const std::byte *contents, size_t contents_size, std::string_view entity_path_prefix=std::string_view(), bool static_=false) const
Logs the given contents using all DataLoaders available.
Definition recording_stream.hpp:636
Error try_log(std::string_view entity_path, const Ts &... archetypes_or_collections) const
Logs one or more archetype and/or component batches.
Definition recording_stream.hpp:407
void flush_blocking() const
Initiates a flush the batching pipeline and waits for it to propagate.
void set_time_nanos(std::string_view timeline_name, int64_t nanos) const
Set the current time of the recording, for the current calling thread.
void set_time(std::string_view timeline_name, std::chrono::duration< TRep, TPeriod > time) const
Set the current time of the recording, for the current calling thread.
Definition recording_stream.hpp:260
void log_static(std::string_view entity_path, const Ts &... archetypes_or_collections) const
Logs one or more archetype and/or component batches as static data.
Definition recording_stream.hpp:388
static RecordingStream & current(StoreKind store_kind=StoreKind::Recording)
Retrieves the most appropriate globally available recording stream for the given kind.
RecordingStream(std::string_view app_id, std::string_view recording_id=std::string_view(), StoreKind store_kind=StoreKind::Recording)
Creates a new recording stream to log to.
void set_thread_local() const
Replaces the currently active recording for this stream's store kind in the thread-local scope with t...
Error try_log_serialized_batches(std::string_view entity_path, bool static_, std::vector< ComponentBatch > batches) const
Logs several serialized batches batches, returning an error on failure.
void set_time(std::string_view timeline_name, std::chrono::time_point< TClock > time) const
Set the current time of the recording, for the current calling thread.
Definition recording_stream.hpp:246
Error connect_tcp(std::string_view tcp_addr="127.0.0.1:9876", float flush_timeout_sec=2.0) const
Connect to a remote Rerun Viewer on the given ip:port.
void send_columns(std::string_view entity_path, Collection< TimeColumn > time_columns, Collection< Ts >... component_columns) const
Directly log a columns of data to Rerun.
Definition recording_stream.hpp:694
void set_time_seconds(std::string_view timeline_name, double seconds) const
Set the current time of the recording, for the current calling thread.
Error try_log_with_static(std::string_view entity_path, bool static_, const Ts &... archetypes_or_collections) const
Logs one or more archetype and/or component batches optionally static, returning an error.
Definition recording_stream.hpp:494
Error try_log_file_from_contents(const std::filesystem::path &filepath, const std::byte *contents, size_t contents_size, std::string_view entity_path_prefix=std::string_view(), bool static_=false) const
Logs the given contents using all DataLoaders available.
void set_global() const
Replaces the currently active recording for this stream's store kind in the global scope with this on...
Error connect(std::string_view tcp_addr="127.0.0.1:9876", float flush_timeout_sec=2.0) const
Connect to a remote Rerun Viewer on the given ip:port.
void set_time_sequence(std::string_view timeline_name, int64_t sequence_nr) const
Set the current time of the recording, for the current calling thread.
A class for representing either a usable value, or an error.
Definition result.hpp:14
bool is_err() const
Returns true if error is not set to rerun::ErrorCode::Ok, implying that no value is contained,...
Definition result.hpp:44
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Arrow-encoded data of a single batch components for a single entity.
Definition component_batch.hpp:22
static Result< ComponentColumn > from_loggable(const Collection< T > &components)
Creates a new component column from a collection of component instances where each run has a length o...
Definition component_column.hpp:60
Options to control the behavior of spawn.
Definition spawn_options.hpp:17