dataselect

cesars/data-latch/dataselect

No description
dataselect
@/dataselect
IDXnumber
Index to select. All values below 1 are considered to be 0. Values of 1 and above are considered to be 1.
X0generic t1
X1generic t1 (variadic)
dataselect
OUT
IDX_
IDX
X0
X1
OUTgeneric t1
The selected value. Equals to one of `Xi` input.
IDX_number
Utility output needed for expanding node. Shoud be ignored by the end user.
To use the node in your project you should have the cesars/data-latch library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

struct State {};

int cond;

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    auto x = getValue<input_IDX>(ctx);
    auto y = 1;
    if (x < y){
     cond = 1;
    }else{cond = 0;}

    auto trueVal = getValue<input_X0>(ctx);
    auto falseVal = getValue<input_X1>(ctx);
    emitValue<output_OUT>(ctx, cond ? trueVal : falseVal);
    emitValue<output_IDX_>(ctx, x - 1);
}