Rerun C++ SDK
Loading...
Searching...
No Matches
video_timestamp.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/components/video_timestamp.fbs".
3
4#pragma once
5
6#include "../component_descriptor.hpp"
7#include "../datatypes/video_timestamp.hpp"
8#include "../result.hpp"
9
10#include <chrono>
11#include <cstdint>
12#include <memory>
13
14namespace rerun::components {
15 /// **Component**: Timestamp inside a `archetypes::AssetVideo`.
18
19 public: // START of extensions from video_timestamp_ext.cpp:
20 /// Creates a new `VideoTimestamp` from a presentation timestamp as a chrono duration.
21 template <typename TRep, typename TPeriod>
22 VideoTimestamp(std::chrono::duration<TRep, TPeriod> time) {
23 timestamp.timestamp_ns =
24 std::chrono::duration_cast<std::chrono::nanoseconds>(time).count();
25 }
26
27 /// Creates a new `VideoTimestamp` from a presentation timestamp in seconds.
28 static VideoTimestamp from_secs(double seconds) {
29 return VideoTimestamp(std::chrono::duration<double>(seconds));
30 }
31
32 /// Creates a new `VideoTimestamp` from a presentation timestamp in seconds.
33 [[deprecated("Renamed to `from_secs`")]] static VideoTimestamp from_seconds(double seconds
34 ) {
35 return VideoTimestamp(std::chrono::duration<double>(seconds));
36 }
37
38 /// Creates a new `VideoTimestamp` from a presentation timestamp in milliseconds.
39 static VideoTimestamp from_millis(double milliseconds) {
40 return VideoTimestamp(std::chrono::duration<double, std::milli>(milliseconds));
41 }
42
43 /// Creates a new `VideoTimestamp` from a presentation timestamp in milliseconds.
44 [[deprecated("Renamed to `from_millis`")]] static VideoTimestamp from_milliseconds(
45 double milliseconds
46 ) {
47 return VideoTimestamp(std::chrono::duration<double, std::milli>(milliseconds));
48 }
49
50 /// Creates a new `VideoTimestamp` from a presentation timestamp in nanoseconds.
51 static VideoTimestamp from_nanos(int64_t nanoseconds) {
52 return VideoTimestamp(std::chrono::nanoseconds(nanoseconds));
53 }
54
55 /// Creates a new `VideoTimestamp` from a presentation timestamp in nanoseconds.
56 [[deprecated("Renamed to `from_nanos`")]] static VideoTimestamp from_nanoseconds(
57 int64_t nanoseconds
58 ) {
59 return VideoTimestamp(std::chrono::nanoseconds(nanoseconds));
60 }
61
62 // END of extensions from video_timestamp_ext.cpp, start of generated code:
63
64 public:
65 VideoTimestamp() = default;
66
67 VideoTimestamp(rerun::datatypes::VideoTimestamp timestamp_) : timestamp(timestamp_) {}
68
69 VideoTimestamp& operator=(rerun::datatypes::VideoTimestamp timestamp_) {
70 timestamp = timestamp_;
71 return *this;
72 }
73
74 VideoTimestamp(int64_t timestamp_ns_) : timestamp(timestamp_ns_) {}
75
76 VideoTimestamp& operator=(int64_t timestamp_ns_) {
77 timestamp = timestamp_ns_;
78 return *this;
79 }
80
81 /// Cast to the underlying VideoTimestamp datatype
83 return timestamp;
84 }
85 };
86} // namespace rerun::components
87
88namespace rerun {
89 static_assert(sizeof(rerun::datatypes::VideoTimestamp) == sizeof(components::VideoTimestamp));
90
91 /// \private
92 template <>
93 struct Loggable<components::VideoTimestamp> {
94 static constexpr ComponentDescriptor Descriptor = "rerun.components.VideoTimestamp";
95
96 /// Returns the arrow data type this type corresponds to.
97 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
98 return Loggable<rerun::datatypes::VideoTimestamp>::arrow_datatype();
99 }
100
101 /// Serializes an array of `rerun::components::VideoTimestamp` into an arrow array.
102 static Result<std::shared_ptr<arrow::Array>> to_arrow(
103 const components::VideoTimestamp* instances, size_t num_instances
104 ) {
105 if (num_instances == 0) {
106 return Loggable<rerun::datatypes::VideoTimestamp>::to_arrow(nullptr, 0);
107 } else if (instances == nullptr) {
108 return rerun::Error(
109 ErrorCode::UnexpectedNullArgument,
110 "Passed array instances is null when num_elements> 0."
111 );
112 } else {
113 return Loggable<rerun::datatypes::VideoTimestamp>::to_arrow(
114 &instances->timestamp,
115 num_instances
116 );
117 }
118 }
119 };
120} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:99
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: Timestamp inside a archetypes::AssetVideo.
Definition video_timestamp.hpp:16
static VideoTimestamp from_milliseconds(double milliseconds)
Creates a new VideoTimestamp from a presentation timestamp in milliseconds.
Definition video_timestamp.hpp:44
static VideoTimestamp from_millis(double milliseconds)
Creates a new VideoTimestamp from a presentation timestamp in milliseconds.
Definition video_timestamp.hpp:39
static VideoTimestamp from_nanos(int64_t nanoseconds)
Creates a new VideoTimestamp from a presentation timestamp in nanoseconds.
Definition video_timestamp.hpp:51
static VideoTimestamp from_seconds(double seconds)
Creates a new VideoTimestamp from a presentation timestamp in seconds.
Definition video_timestamp.hpp:33
static VideoTimestamp from_nanoseconds(int64_t nanoseconds)
Creates a new VideoTimestamp from a presentation timestamp in nanoseconds.
Definition video_timestamp.hpp:56
VideoTimestamp(std::chrono::duration< TRep, TPeriod > time)
Creates a new VideoTimestamp from a presentation timestamp as a chrono duration.
Definition video_timestamp.hpp:22
static VideoTimestamp from_secs(double seconds)
Creates a new VideoTimestamp from a presentation timestamp in seconds.
Definition video_timestamp.hpp:28
Datatype: Presentation timestamp within a archetypes::AssetVideo.
Definition video_timestamp.hpp:28
int64_t timestamp_ns
Presentation timestamp value in nanoseconds.
Definition video_timestamp.hpp:30