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()
360 template <
typename... Ts>
361 void log(std::string_view entity_path,
const Ts&... as_components)
const {
382 template <
typename... Ts>
383 void log_static(std::string_view entity_path,
const Ts&... as_components)
const {
401 template <
typename... Ts>
402 Error try_log(std::string_view entity_path,
const Ts&... as_components)
const {
421 template <
typename... Ts>
445 template <
typename... Ts>
446 void log_with_static(std::string_view entity_path,
bool static_,
const Ts&... as_components)
468 template <
typename... Ts>
470 std::string_view entity_path,
bool static_,
const Ts&... as_components
475 std::vector<ComponentBatch> serialized_columns;
484 AsComponents<Ts>().as_batches(as_components);
485 if (serialization_result.
is_err()) {
486 err = serialization_result.error;
490 if (serialized_columns.empty()) {
492 serialized_columns = std::move(serialization_result.value).to_vector();
494 serialized_columns.insert(
495 serialized_columns.end(),
496 std::make_move_iterator(serialization_result.value.begin()),
497 std::make_move_iterator(serialization_result.value.end())
503 RR_RETURN_NOT_OK(err);
523 std::string_view entity_path,
bool static_, std::vector<ComponentBatch> batches
539 std::string_view entity_path,
size_t num_data_cells,
const ComponentBatch* data_cells,
562 const std::filesystem::path& filepath,
563 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
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,
const std::byte* contents,
size_t contents_size,
613 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
646 const std::filesystem::path& filepath,
const std::byte* contents,
size_t contents_size,
647 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
669 template <
typename... Ts>
672 Ts... component_columns
694 template <
typename... Ts>
697 Ts... component_columns
699 if constexpr (
sizeof...(Ts) == 1) {
704 std::move(time_columns),
705 Collection(std::forward<Ts...>(component_columns...))
709 std::vector<ComponentColumn> flat_column_list;
714 std::is_constructible_v<Collection<ComponentColumn>, Ts>,
715 "Ts must be ComponentColumn or a collection thereof"
718 push_back_columns(flat_column_list, std::move(component_columns));
724 std::move(time_columns),
778 static void push_back_columns(
781 for (
const auto& new_column : new_columns) {
782 component_columns.emplace_back(std::move(new_column));
786 static void push_back_columns(
787 std::vector<ComponentColumn>& component_columns, ComponentColumn new_column
789 component_columns.emplace_back(std::move(new_column));
795 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:96
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:132
static Error ok()
Creates a new error set to ok.
Definition error.hpp:117
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Error try_log_with_static(std::string_view entity_path, bool static_, const Ts &... as_components) const
Logs one or more archetype and/or component batches optionally static, returning an error.
Definition recording_stream.hpp:469
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:561
bool is_enabled() const
Returns whether the recording stream is enabled.
Definition recording_stream.hpp:99
Error try_log(std::string_view entity_path, const Ts &... as_components) const
Logs one or more archetype and/or component batches.
Definition recording_stream.hpp:402
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:747
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.
Error try_log_static(std::string_view entity_path, const Ts &... as_components) const
Logs one or more archetype and/or component batches as static data, returning an error.
Definition recording_stream.hpp:422
StoreKind kind() const
Returns the store kind as passed during construction.
Definition recording_stream.hpp:91
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:611
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_with_static(std::string_view entity_path, bool static_, const Ts &... as_components) const
Logs one or more archetype and/or component batches optionally static, returning an error.
Definition recording_stream.hpp:446
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 log(std::string_view entity_path, const Ts &... as_components) const
Logs one or more archetype and/or component batches.
Definition recording_stream.hpp:361
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 set_time_seconds(std::string_view timeline_name, double seconds) const
Set the current time of the recording, for the current calling thread.
void send_columns(std::string_view entity_path, Collection< TimeColumn > time_columns, Ts... component_columns) const
Directly log a columns of data to Rerun.
Definition recording_stream.hpp:670
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.
Error try_send_columns(std::string_view entity_path, Collection< TimeColumn > time_columns, Ts... component_columns) const
Directly log a columns of data to Rerun.
Definition recording_stream.hpp:695
void log_static(std::string_view entity_path, const Ts &... as_components) const
Logs one or more archetype and/or component batches as static data.
Definition recording_stream.hpp:383
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:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
Arrow-encoded data of a column of components.
Definition component_column.hpp:20
Options to control the behavior of spawn.
Definition spawn_options.hpp:17