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