4 #ifndef __SOT_SWITCH_H__
5 #define __SOT_SWITCH_H__
9 #include <dynamic-graph/entity.h>
10 #include <dynamic-graph/pool.h>
13 #include <dynamic-graph/signal.h>
15 #include <sot/core/config.hh>
21 template <
typename Value,
typename Time = sigtime_t>
30 selectionSIN(NULL,
"Switch(" +
name +
")::input(size_type)::selection"),
31 boolSelectionSIN(NULL,
32 "Switch(" +
name +
")::input(bool)::boolSelection") {
33 this->signalRegistration(selectionSIN << boolSelectionSIN);
34 this->SOUT.setFunction(boost::bind(&
Switch::signal,
this, _1, _2));
35 this->SOUT.addDependency(selectionSIN);
36 this->SOUT.addDependency(boolSelectionSIN);
39 std::string docstring =
41 " Set number of input signals\n";
48 " Get number of input signals\n";
49 this->addCommand(
"getSignalNumber",
51 *
this, &Base::getSignalNumber, docstring));
58 return "Dynamically select a given signal based on a input information.\n";
68 sel = selectionSIN(time);
70 const bool &
b = boolSelectionSIN(time);
73 if (sel < 0 || sel >=
size_type(this->signalsIN.size()))
74 throw std::runtime_error(
"Signal selection is out of range.");
76 ret = this->signalsIN[sel]->access(time);
82 #endif // __SOT_SWITCH_H__