Rerun C++ SDK: rerun/components/scalar.hpp Source File (original) (raw)

1

2

3

4#pragma once

5

6#include "../component_descriptor.hpp"

7#include "../datatypes/float64.hpp"

8#include "../result.hpp"

9

10#include

11#include

12

14

15

16

19

20 public:

22

24

26 value = value_;

27 return *this;

28 }

29

30 Scalar(double value_) : value(value_) {}

31

32 Scalar& operator=(double value_) {

33 value = value_;

34 return *this;

35 }

36

37

39 return value;

40 }

41 };

42}

43

46

47

48 template <>

49 struct Loggablecomponents::Scalar {

50 static constexpr ComponentDescriptor Descriptor = "rerun.components.Scalar";

51

52

53 static const std::shared_ptrarrow::DataType& arrow_datatype() {

54 return Loggablererun::datatypes::Float64::arrow_datatype();

55 }

56

57

58 static Result<std::shared_ptrarrow::Array> to_arrow(

59 const components::Scalar* instances, size_t num_instances

60 ) {

61 if (num_instances == 0) {

62 return Loggablererun::datatypes::Float64::to_arrow(nullptr, 0);

63 } else if (instances == nullptr) {

65 ErrorCode::UnexpectedNullArgument,

66 "Passed array instances is null when num_elements> 0."

67 );

68 } else {

69 return Loggablererun::datatypes::Float64::to_arrow(

70 &instances->value,

71 num_instances

72 );

73 }

74 }

75 };

76}

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: A scalar value, encoded as a 64-bit floating point.

Definition scalar.hpp:17

Datatype: A double-precision 64-bit IEEE 754 floating point number.

Definition float64.hpp:25