10#include "as_components.hpp"
12#include "spawn_options.hpp"
17 enum class StoreKind {
65 std::string_view app_id, std::string_view recording_id = std::string_view(),
66 StoreKind store_kind = StoreKind::Recording
143 Error connect(std::string_view tcp_addr =
"127.0.0.1:9876",
float flush_timeout_sec = 2.0)
163 template <
typename TRep,
typename TPeriod>
166 std::chrono::duration<TRep, TPeriod> flush_timeout = std::chrono::seconds(2)
168 using seconds_float = std::chrono::duration<float>;
169 return spawn(options, std::chrono::duration_cast<seconds_float>(flush_timeout).count());
223 template <
typename TClock>
224 void set_time(std::string_view timeline_name, std::chrono::time_point<TClock> time)
const {
225 set_time(timeline_name, time.time_since_epoch());
237 template <
typename TRep,
typename TPeriod>
238 void set_time(std::string_view timeline_name, std::chrono::duration<TRep, TPeriod> time)
240 if constexpr (std::is_floating_point<TRep>::value) {
241 using seconds_double =
242 std::chrono::duration<double>;
245 std::chrono::duration_cast<seconds_double>(time).count()
250 std::chrono::duration_cast<std::chrono::nanoseconds>(time).count()
337 template <
typename... Ts>
338 void log(std::string_view entity_path,
const Ts&... archetypes_or_collections)
const {
345 template <
typename... Ts>
346 [[deprecated(
"Use `log_static` instead")]]
void log_timeless(
347 std::string_view entity_path,
const Ts&... archetypes_or_collections
349 return log_static(entity_path, archetypes_or_collections...);
365 template <
typename... Ts>
366 void log_static(std::string_view entity_path,
const Ts&... archetypes_or_collections)
384 template <
typename... Ts>
385 Error try_log(std::string_view entity_path,
const Ts&... archetypes_or_collections)
const {
392 template <
typename... Ts>
393 [[deprecated(
"Use `try_log_static` instead")]]
Error try_log_timeless(
394 std::string_view entity_path,
const Ts&... archetypes_or_collections
410 template <
typename... Ts>
419 template <
typename... Ts>
420 [[deprecated(
"Use `log_with_static` instead")]]
void log_with_timeless(
421 std::string_view entity_path,
bool timeless,
const Ts&... archetypes_or_collections
423 return log_with_static(entity_path, timeless, archetypes_or_collections...);
441 template <
typename... Ts>
443 std::string_view entity_path,
bool static_,
const Ts&... archetypes_or_collections
448 template <
typename... Ts>
449 [[deprecated(
"Use `try_log_with_static` instead")]]
Error try_log_with_timeless(
450 std::string_view entity_path,
bool static_,
const Ts&... archetypes_or_collections
471 template <
typename... Ts>
473 std::string_view entity_path,
bool static_,
const Ts&... archetypes_or_collections
478 std::vector<DataCell> serialized_batches;
487 AsComponents<Ts>().serialize(archetypes_or_collections);
488 if (serialization_result.
is_err()) {
489 err = serialization_result.error;
493 if (serialized_batches.empty()) {
495 serialized_batches = std::move(serialization_result.value);
497 serialized_batches.insert(
498 serialized_batches.end(),
499 std::make_move_iterator(serialization_result.value.begin()),
500 std::make_move_iterator(serialization_result.value.end())
506 RR_RETURN_NOT_OK(err);
526 std::string_view entity_path,
bool static_, std::vector<DataCell> batches
542 std::string_view entity_path,
size_t num_data_cells,
const DataCell* data_cells,
565 const std::filesystem::path& filepath,
566 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
590 const std::filesystem::path& filepath,
591 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
615 const std::filesystem::path& filepath,
const std::byte* contents,
size_t contents_size,
616 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
649 const std::filesystem::path& filepath,
const std::byte* contents,
size_t contents_size,
650 std::string_view entity_path_prefix = std::string_view(),
bool static_ =
false
659 StoreKind _store_kind;
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:89
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:125
static Error ok()
Creates a new error set to ok.
Definition error.hpp:110
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:57
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_log_data_row(std::string_view entity_path, size_t num_data_cells, const DataCell *data_cells, bool inject_time) const
Bottom level API that logs raw data cells to the recording stream.
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:564
bool is_enabled() const
Returns whether the recording stream is enabled.
Definition recording_stream.hpp:96
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:411
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 try_log_serialized_batches(std::string_view entity_path, bool static_, std::vector< DataCell > batches) const
Logs several serialized batches batches, returning an error on failure.
Error to_stdout() const
Stream all log-data to standard output.
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:442
StoreKind kind() const
Returns the store kind as passed during construction.
Definition recording_stream.hpp:88
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:338
Error spawn(const SpawnOptions &options={}, std::chrono::duration< TRep, TPeriod > flush_timeout=std::chrono::seconds(2)) const
Definition recording_stream.hpp:164
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:614
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:385
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:238
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:366
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...
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:224
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:472
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:21
Arrow-encoded data of a single batch components for a single entity.
Definition data_cell.hpp:21
Options to control the behavior of spawn.
Definition spawn_options.hpp:17