libtcspc.ChannelRouter¶
- class libtcspc.ChannelRouter(channel_indices, *, arity=None, numeric_traits=None)[source]¶
Bases:
RouterRouter that routes events by their channel number.
Each routed event’s
channelmember 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
Parambinds the whole mapping at execution time;aritymust 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 ifchannel_indicesis aParam; for a literal mapping it is inferred and, if given, must equallen(channel_indices).numeric_traits (NumericTraits or None, keyword-only) – Provides the C++
channel_typeof the channel numbers. Default:NumericTraits().
- Raises:
ValueError – If a literal
channel_indicesis empty, contains a negative output index, or has a length not matching a givenarity; or ifchannel_indicesis aParamandarityis not given.
See also
- tcspc::channel_router
The underlying C++ router.
NullRouterRouter that discards every event.