libtcspc.ChannelRouter

class libtcspc.ChannelRouter(channel_indices, *, arity=None, numeric_traits=None)[source]

Bases: Router

Router that routes events by their channel number.

Each routed event’s channel member is looked up in a channel-to-index map; the event is routed to the corresponding output port, or discarded if the channel is absent from the map.

Parameters:
  • channel_indices (Mapping[int, int] or Param) – Maps channel number to output-port index. A plain mapping is baked into the generated code at compile time. A Param binds the whole mapping at execution time; arity must then be given. Must be non-empty.

  • arity (int or None, keyword-only) – Number of channel entries N (the compile-time channel_router<N, ...> size). Required if and only if channel_indices is a Param; for a literal mapping it is inferred and, if given, must equal len(channel_indices).

  • numeric_traits (NumericTraits or None, keyword-only) – Provides the C++ channel_type of the channel numbers. Default: NumericTraits().

Raises:

ValueError – If a literal channel_indices is empty, contains a negative output index, or has a length not matching a given arity; or if channel_indices is a Param and arity is not given.

See also

tcspc::channel_router

The underlying C++ router.

NullRouter

Router that discards every event.