Skip to content
Snippets Groups Projects
Commit e5329361 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Fix Switch bindings.

parent f7d702de
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ template <typename Value, typename Time = int>
class SOT_CORE_DLLAPI Switch : public VariadicAbstract<Value, Value, Time> {
DYNAMIC_GRAPH_ENTITY_DECL();
public:
typedef VariadicAbstract<Value, Value, Time> Base;
Switch(const std::string &name)
......@@ -55,6 +56,9 @@ class SOT_CORE_DLLAPI Switch : public VariadicAbstract<Value, Value, Time> {
return "Dynamically select a given signal based on a input information.\n";
}
SignalPtr<int, Time> selectionSIN;
SignalPtr<bool, Time> boolSelectionSIN;
private:
Value &signal(Value &ret, const Time &time) {
int sel;
......@@ -70,9 +74,6 @@ private:
ret = this->signalsIN[sel]->access(time);
return ret;
}
SignalPtr<int, Time> selectionSIN;
SignalPtr<bool, Time> boolSelectionSIN;
};
} // namespace sot
} // namespace dynamicgraph
......
#include "dynamic-graph/python/module.hh"
#include <sot/core/switch.hh>
namespace dg = dynamicgraph;
typedef bp::return_value_policy<bp::reference_existing_object> reference_existing_object;
template<typename T, typename Time>
void exposeSwitch()
{
typedef dg::sot::Switch<T, Time> E_t;
typedef typename E_t::Base B_t;
dg::python::exposeEntity<E_t, bp::bases<dg::Entity>, dg::python::AddCommands>()
.def_readonly("sout", &E_t::SOUT)
.def("sin", &B_t::getSignalIn, reference_existing_object())
.add_property("n_sin", &B_t::getSignalNumber, &B_t::setSignalNumber,
"the number of input signal.")
.def_readonly("selection", &E_t::selectionSIN)
.def_readonly("boolSelection", &E_t::boolSelectionSIN)
.def("setSignalNumber", &B_t::setSignalNumber,
"set the number of input signal.", bp::arg("size"))
.def("getSignalNumber", &B_t::getSignalNumber,
"get the number of input signal.", bp::arg("size"))
;
}
BOOST_PYTHON_MODULE(wrap)
{
exposeSwitch <bool, int> ();
exposeSwitch <dg::Vector, int> ();
exposeSwitch <dg::sot::MatrixHomogeneous, int> ();
}
#include <sot/core/switch.hh>
namespace dg = ::dynamicgraph;
typedef boost::mpl::vector<
dg::sot::Switch<bool, int>
, dg::sot::Switch<dg::Vector, int>
, dg::sot::Switch<dg::sot::MatrixHomogeneous, int>
> entities_t;
......@@ -18,12 +18,18 @@ std::string VariadicAbstract<Tin, Tout, Time>::getTypeOutName(void) {
return TypeNameHelper<Tout>::typeName();
}
template class VariadicAbstract<Vector, Vector, int>;
typedef Switch<Vector, int> SwitchVector;
template <> DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(SwitchVector, "SwitchVector");
template class VariadicAbstract<bool, bool, int>;
typedef Switch<bool, int> SwitchBool;
template <> DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(SwitchBool, "SwitchBoolean");
template class VariadicAbstract<MatrixHomogeneous, MatrixHomogeneous, int>;
typedef Switch<MatrixHomogeneous, int> SwitchMatrixHomogeneous;
template <>
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(SwitchMatrixHomogeneous,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment