From: Robert W. E. <gi...@gi...> - 2014-04-23 15:46:58
|
canon: Fixed subscript operator in CANON_POSITION to return proper reference http://git.linuxcnc.org/?p=linuxcnc.git;a=commitdiff;h=029bbe2 --- src/emc/nml_intf/canon_position.cc | 17 +++++------------ src/emc/nml_intf/canon_position.hh | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/emc/nml_intf/canon_position.cc b/src/emc/nml_intf/canon_position.cc index 5199312..e69174b 100644 --- a/src/emc/nml_intf/canon_position.cc +++ b/src/emc/nml_intf/canon_position.cc @@ -16,6 +16,8 @@ #include "math.h" #include "posemath.h" +static double noElement = 0.0; + CANON_POSITION::CANON_POSITION(double _x, double _y, double _z, double _a, double _b, double _c, double _u, double _v, double _w) { @@ -229,37 +231,28 @@ void CANON_POSITION::print() const { this->w); } -const double CANON_POSITION::operator[](const int ind) const { +double &CANON_POSITION::operator[](int ind){ switch (ind) { case 0: return x; - break; case 1: return y; - break; case 2: return z; - break; case 3: return a; - break; case 4: return b; - break; case 5: return c; - break; case 6: return u; - break; case 7: return v; - break; case 8: return w; - break; default: - //TODO exception here? - return 0.0; + printf("noelement!\n"); + return noElement; } } diff --git a/src/emc/nml_intf/canon_position.hh b/src/emc/nml_intf/canon_position.hh index eda297e..1b2ba66 100644 --- a/src/emc/nml_intf/canon_position.hh +++ b/src/emc/nml_intf/canon_position.hh @@ -54,7 +54,7 @@ struct CANON_POSITION { const CANON_POSITION operator-(const CANON_POSITION &o) const; const CANON_POSITION operator-(const EmcPose &o) const; - const double operator[](const int ind) const; + double &operator[](const int ind); const CANON_POSITION abs() const; const CANON_POSITION absdiff(const CANON_POSITION &o) const; |