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 "../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_seconds(double seconds) {
28 return VideoTimestamp(std::chrono::duration<double>(seconds));
29 }
30
31 /// Creates a new `VideoTimestamp` from a presentation timestamp in milliseconds.
32 static VideoTimestamp from_milliseconds(double milliseconds) {
33 return VideoTimestamp(std::chrono::duration<double, std::milli>(milliseconds));
34 }
35
36 /// Creates a new `VideoTimestamp` from a presentation timestamp in nanoseconds.
37 static VideoTimestamp from_nanoseconds(int64_t nanoseconds) {
38 return VideoTimestamp(std::chrono::nanoseconds(nanoseconds));
39 }
40
41 // END of extensions from video_timestamp_ext.cpp, start of generated code:
42
43 public:
44 VideoTimestamp() = default;
45
46 VideoTimestamp(rerun::datatypes::VideoTimestamp timestamp_) : timestamp(timestamp_) {}
47
48 VideoTimestamp& operator=(rerun::datatypes::VideoTimestamp timestamp_) {
49 timestamp = timestamp_;
50 return *this;
51 }
52
53 VideoTimestamp(int64_t timestamp_ns_) : timestamp(timestamp_ns_) {}
54
55 VideoTimestamp& operator=(int64_t timestamp_ns_) {
56 timestamp = timestamp_ns_;
57 return *this;
58 }
59
60 /// Cast to the underlying VideoTimestamp datatype
62 return timestamp;
63 }
64 };
65} // namespace rerun::components
66
67namespace rerun {
68 static_assert(sizeof(rerun::datatypes::VideoTimestamp) == sizeof(components::VideoTimestamp));
69
70 /// \private
71 template <>
72 struct Loggable<components::VideoTimestamp> {
73 static constexpr const char Name[] = "rerun.components.VideoTimestamp";
74
75 /// Returns the arrow data type this type corresponds to.
76 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
77 return Loggable<rerun::datatypes::VideoTimestamp>::arrow_datatype();
78 }
79
80 /// Serializes an array of `rerun::components::VideoTimestamp` into an arrow array.
81 static Result<std::shared_ptr<arrow::Array>> to_arrow(
82 const components::VideoTimestamp* instances, size_t num_instances
83 ) {
84 if (num_instances == 0) {
85 return Loggable<rerun::datatypes::VideoTimestamp>::to_arrow(nullptr, 0);
86 } else if (instances == nullptr) {
87 return rerun::Error(
88 ErrorCode::UnexpectedNullArgument,
89 "Passed array instances is null when num_elements> 0."
90 );
91 } else {
92 return Loggable<rerun::datatypes::VideoTimestamp>::to_arrow(
93 &instances->timestamp,
94 num_instances
95 );
96 }
97 }
98 };
99} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
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:32
static VideoTimestamp from_seconds(double seconds)
Creates a new VideoTimestamp from a presentation timestamp in seconds.
Definition video_timestamp.hpp:27
static VideoTimestamp from_nanoseconds(int64_t nanoseconds)
Creates a new VideoTimestamp from a presentation timestamp in nanoseconds.
Definition video_timestamp.hpp:37
VideoTimestamp(std::chrono::duration< TRep, TPeriod > time)
Creates a new VideoTimestamp from a presentation timestamp as a chrono duration.
Definition video_timestamp.hpp:21
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