Rerun C++ SDK
Loading...
Searching...
No Matches
config.hpp
1#pragma once
2#include <atomic>
3
4#ifndef RERUN_ENABLED
5#define RERUN_ENABLED 1
6#endif
7
8namespace rerun {
9 /// Configuration singleton that applies to the entire SDK.
11 static RerunGlobalConfig& instance();
12
13 RerunGlobalConfig(const RerunGlobalConfig&) = delete;
14 RerunGlobalConfig& operator=(const RerunGlobalConfig&) = delete;
15
16 /// Whether `RecordingStream`s are enabled by default.
17 ///
18 /// \see set_default_enabled, is_default_enabled
19 std::atomic_bool default_enabled;
20
21 private:
23
25 };
26
27 /// Change whether `RecordingStream`s are enabled by default.
28 ///
29 /// This governs the creation of new `RecordingStream`s. If `default_enabled` is
30 /// `false`, `RecordingStreams` will be created in the disabled state. Changing
31 /// the value of `default_enabled` will not affect existing `RecordingStream`s.
32 ///
33 /// Note that regardless of usage of this API, the value of default_enabled will
34 /// be overridden by the RERUN environment variable.
35 ///
36 /// If RERUN is set to `1`, `true`, or `yes`, then Rerun is enabled. If RERUN is
37 /// set to `0`, `false`, or `no`, then Rerun is disabled.
38 inline void set_default_enabled(bool default_enabled) {
39 RerunGlobalConfig::instance().default_enabled.store(
40 default_enabled,
41 std::memory_order_seq_cst
42 );
43 }
44
45 /// Check if Rerun is enabled.
46 inline bool is_default_enabled() {
47 // We use `memory_order_seq_cst` since this is only ever called during construction of
48 // RecordingStreams. Consider changing to `memory_order_relaxed` if we need to call this
49 // in a more frequently used code-path.
50 return RerunGlobalConfig::instance().default_enabled.load(std::memory_order_seq_cst);
51 }
52} // namespace rerun
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
bool is_default_enabled()
Check if Rerun is enabled.
Definition config.hpp:46
void set_default_enabled(bool default_enabled)
Change whether RecordingStreams are enabled by default.
Definition config.hpp:38
Configuration singleton that applies to the entire SDK.
Definition config.hpp:10
std::atomic_bool default_enabled
Whether RecordingStreams are enabled by default.
Definition config.hpp:19