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