Skip to main content

Constant

The Constant operator emits a fixed value while preserving the timing of input messages. For each input message received, it outputs a message with the same timestamp but replaces the value with the configured constant.

Ports

  • Input Port 0: Accepts messages of type T
  • Output Port 0: Emits messages of type T with constant value

Operation

The operator maintains no internal state and processes messages immediately:

  1. Receives an input message
  2. Creates a new message with:
    • Same timestamp as input
    • Value field set to configured constant
  3. Emits the new message

Example Message Flow

TimeInput (Port 0)Output (Port 0)
110.042.0
215.042.0
525.042.0
730.042.0

Features

  • Zero buffering - processes messages immediately
  • Preserves message timing
  • Type-safe operation
  • Configurable for any data type
  • Constant throughput (1:1 input to output)

Implementation

// Create operator with constant value 42.0
auto constant = make_number_constant("const1", 42.0);

// Process some values (will all be converted to 42.0)
constant->receive_data(create_message<NumberData>(1, NumberData{10.0}), 0);
constant->execute();

Error Handling

The operator throws exceptions for:

  • Type mismatches on input
  • Invalid port indices
  • Message conversion failures

Performance Characteristics

  • O(1) processing per message
  • No memory growth
  • Zero-copy message handling where possible
  • Immediate message processing