Skip to content

Commit e1fd1d4

Browse files
jmirabelolivier-stasse
authored andcommitted
Fix backward compatibility of Add_of_(...)
1 parent 80371e1 commit e1fd1d4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/matrix/operator.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,15 @@ namespace dynamicgraph {
969969
}
970970

971971
void setCoeffs(const Vector& c) { coeffs = c; }
972+
void setCoeff1(const double& c) { assert(coeffs.size() == 2); coeffs(0) = c; }
973+
void setCoeff2(const double& c) { assert(coeffs.size() == 2); coeffs(1) = c; }
974+
972975
void setSignalNumber (const int& n)
973976
{
977+
if (entity->getSignalNumber() == 2) {
978+
entity->removeSignal();
979+
entity->removeSignal();
980+
}
974981
coeffs = Vector::Ones(n);
975982
entity->setSignalNumber(n);
976983
}
@@ -981,7 +988,9 @@ namespace dynamicgraph {
981988
using namespace dynamicgraph::command;
982989
entity = ent;
983990

984-
setSignalNumber (2);
991+
coeffs = Vector::Ones(2);
992+
entity->addSignal ("sin1");
993+
entity->addSignal ("sin2");
985994

986995
commandMap.insert(std::make_pair( "getSignalNumber",
987996
new Getter<Base, int> (*ent, &Base::getSignalNumber,
@@ -996,6 +1005,17 @@ namespace dynamicgraph {
9961005
makeCommandVoid1<Base,Vector>(*ent,
9971006
boost::function <void (const Vector&)> (boost::bind ( &AdderVariadic::setCoeffs, this, _1)),
9981007
docCommandVoid1("set the multipliers.", "vector"))));
1008+
1009+
// Add deprecated commands.
1010+
commandMap.insert(std::make_pair("setCoeff1",
1011+
makeCommandVoid1<Base,double>(*ent,
1012+
boost::function <void (const double&)> (boost::bind ( &AdderVariadic::setCoeff1, this, _1)),
1013+
docCommandVoid1("deprecated. Use setCoeffs.", "double"))));
1014+
1015+
commandMap.insert(std::make_pair("setCoeff2",
1016+
makeCommandVoid1<Base,double>(*ent,
1017+
boost::function <void (const double&)> (boost::bind ( &AdderVariadic::setCoeff2, this, _1)),
1018+
docCommandVoid1("deprecated. Use setCoeffs.", "double"))));
9991019
}
10001020

10011021
virtual std::string getDocString () const

0 commit comments

Comments
 (0)