Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::StateChange Struct Reference

Archetype: A state change, representing a transition of an entity into a new state. More...

#include <rerun/archetypes/state_change.hpp>

Public Member Functions

 StateChange (StateChange &&other)=default
 
 StateChange (const StateChange &other)=default
 
StateChangeoperator= (const StateChange &other)=default
 
StateChangeoperator= (StateChange &&other)=default
 
StateChange with_state (const rerun::components::Text &_state) &&
 The new state value. A null state is ignored, it can be used to partially update a multi-instance state array.
 
StateChange with_many_state (const Collection< rerun::components::Text > &_state) &&
 This method makes it possible to pack multiple state in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static StateChange update_fields ()
 Update only some specific fields of a StateChange.
 
static StateChange clear_fields ()
 Clear all the fields of a StateChange.
 

Public Attributes

std::optional< ComponentBatchstate
 The new state value. A null state is ignored, it can be used to partially update a multi-instance state array.
 

Static Public Attributes

static constexpr const char ArchetypeName [] = "rerun.archetypes.StateChange"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_state
 ComponentDescriptor for the state field.
 

Detailed Description

Archetype: A state change, representing a transition of an entity into a new state.

Useful for representing discrete state machines, mode transitions, or state changes over time. Each logged archetypes::StateChange marks a new state at the given time. A null state is ignored by the state timeline view.

The state timeline view displays these as horizontal colored lanes over time.

Example

State changes over time

image

#include <rerun.hpp>
int main(int argc, char* argv[]) {
const auto rec = rerun::RecordingStream("rerun_example_state_change");
rec.spawn().exit_on_failure();
rec.set_time_sequence("step", 0);
rec.log("door", rerun::StateChange().with_state("open"));
rec.set_time_sequence("step", 1);
rec.log("door", rerun::StateChange().with_state("closed"));
rec.set_time_sequence("step", 2);
rec.log("door", rerun::StateChange().with_state("open"));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:73
Archetype: A state change, representing a transition of an entity into a new state.
Definition state_change.hpp:51
StateChange with_state(const rerun::components::Text &_state) &&
The new state value. A null state is ignored, it can be used to partially update a multi-instance sta...
Definition state_change.hpp:80

This type is unstable and may change significantly in a way that the data won't be backwards compatible.

Member Function Documentation

◆ with_many_state()

StateChange rerun::archetypes::StateChange::with_many_state ( const Collection< rerun::components::Text > &  _state) &&
inline

This method makes it possible to pack multiple state in a single component batch.

This only makes sense when used in conjunction with columns. with_state should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::StateChange::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::StateChange::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ Descriptor_state

constexpr auto rerun::archetypes::StateChange::Descriptor_state
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "StateChange:state", Loggable<rerun::components::Text>::ComponentType
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition state_change.hpp:57

ComponentDescriptor for the state field.


The documentation for this struct was generated from the following file: