readability

release/4.3a0
Gerry Chen 2022-12-22 17:55:25 -05:00
parent 885eed33d1
commit e5ec007185
No known key found for this signature in database
GPG Key ID: E9845092D3A57286
1 changed files with 50 additions and 64 deletions

View File

@ -555,31 +555,38 @@ class NoiseModelFactorN : public NoiseModelFactor {
} }
public: public:
/// @name Deprecated methods /// @name Deprecated methods. Use `key<1>()`, `key<2>()`, ... instead of old
/// `key1()`, `key2()`, ...
/// If your class is templated AND you are trying to call `key<1>` inside your
/// class, due to dependent types you need to do `this->template key<1>()`.
/// @{ /// @{
template <int I = N, typename = typename std::enable_if<(I > 1), void>::type>
inline Key GTSAM_DEPRECATED key1() const { inline Key GTSAM_DEPRECATED key1() const {
return key<1>(); return key<1>();
} }
template <int I = 2, typename = IndexIsValid<I>> template <int I = 2>
inline Key GTSAM_DEPRECATED key2() const { inline Key GTSAM_DEPRECATED key2() const {
static_assert(I <= N, "Index out of bounds");
return key<2>(); return key<2>();
} }
template <int I = 3, typename = IndexIsValid<I>> template <int I = 3>
inline Key GTSAM_DEPRECATED key3() const { inline Key GTSAM_DEPRECATED key3() const {
static_assert(I <= N, "Index out of bounds");
return key<3>(); return key<3>();
} }
template <int I = 4, typename = IndexIsValid<I>> template <int I = 4>
inline Key GTSAM_DEPRECATED key4() const { inline Key GTSAM_DEPRECATED key4() const {
static_assert(I <= N, "Index out of bounds");
return key<4>(); return key<4>();
} }
template <int I = 5, typename = IndexIsValid<I>> template <int I = 5>
inline Key GTSAM_DEPRECATED key5() const { inline Key GTSAM_DEPRECATED key5() const {
static_assert(I <= N, "Index out of bounds");
return key<5>(); return key<5>();
} }
template <int I = 6, typename = IndexIsValid<I>> template <int I = 6>
inline Key GTSAM_DEPRECATED key6() const { inline Key GTSAM_DEPRECATED key6() const {
static_assert(I <= N, "Index out of bounds");
return key<6>(); return key<6>();
} }
@ -588,8 +595,12 @@ class NoiseModelFactorN : public NoiseModelFactor {
}; // \class NoiseModelFactorN }; // \class NoiseModelFactorN
/* ************************************************************************* */ /* ************************************************************************* */
/** @deprecated: use NoiseModelFactorN, replacing .key() with .key<1> and X1 /** @deprecated: use NoiseModelFactorN, replacing .key() with .key<1>() and X1
* with ValueType<1>. If your class is templated, use `this->template key<1>()` * with ValueType<1>.
* If your class is templated AND you are trying to call `.key<1>()` or
* `ValueType<1>` inside your class, due to dependent types you need to do
* `this->template key<1>()` or `This::template ValueType<1>`.
* ~~~
* A convenient base class for creating your own NoiseModelFactor * A convenient base class for creating your own NoiseModelFactor
* with 1 variable. To derive from this class, implement evaluateError(). * with 1 variable. To derive from this class, implement evaluateError().
*/ */
@ -613,11 +624,6 @@ class GTSAM_DEPRECATED NoiseModelFactor1 : public NoiseModelFactorN<VALUE> {
using NoiseModelFactorN<VALUE>::NoiseModelFactorN; using NoiseModelFactorN<VALUE>::NoiseModelFactorN;
~NoiseModelFactor1() override {} ~NoiseModelFactor1() override {}
/** Method to retrieve key.
* Similar to `ValueType`, you can probably do `return key<1>();`
*/
inline Key key() const { return NoiseModelFactorN<VALUE>::template key<1>(); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;
@ -629,8 +635,12 @@ class GTSAM_DEPRECATED NoiseModelFactor1 : public NoiseModelFactorN<VALUE> {
}; // \class NoiseModelFactor1 }; // \class NoiseModelFactor1
/* ************************************************************************* */ /* ************************************************************************* */
/** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1> and X1 /** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1>() and X1
* with ValueType<1>. If your class is templated, use `this->template key<1>()` * with ValueType<1>.
* If your class is templated AND you are trying to call `.key<1>()` or
* `ValueType<1>` inside your class, due to dependent types you need to do
* `this->template key<1>()` or `This::template ValueType<1>`.
* ~~~
* A convenient base class for creating your own NoiseModelFactor * A convenient base class for creating your own NoiseModelFactor
* with 2 variables. To derive from this class, implement evaluateError(). * with 2 variables. To derive from this class, implement evaluateError().
*/ */
@ -656,12 +666,6 @@ class GTSAM_DEPRECATED NoiseModelFactor2
using NoiseModelFactorN<VALUE1, VALUE2>::NoiseModelFactorN; using NoiseModelFactorN<VALUE1, VALUE2>::NoiseModelFactorN;
~NoiseModelFactor2() override {} ~NoiseModelFactor2() override {}
/** Methods to retrieve keys.
* Similar to `ValueType`, you can probably do `return key<#>();`
*/
inline Key key1() const { return this->template key<1>(); }
inline Key key2() const { return this->template key<2>(); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;
@ -673,8 +677,12 @@ class GTSAM_DEPRECATED NoiseModelFactor2
}; // \class NoiseModelFactor2 }; // \class NoiseModelFactor2
/* ************************************************************************* */ /* ************************************************************************* */
/** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1> and X1 /** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1>() and X1
* with ValueType<1>. If your class is templated, use `this->template key<1>()` * with ValueType<1>.
* If your class is templated AND you are trying to call `.key<1>()` or
* `ValueType<1>` inside your class, due to dependent types you need to do
* `this->template key<1>()` or `This::template ValueType<1>`.
* ~~~
* A convenient base class for creating your own NoiseModelFactor * A convenient base class for creating your own NoiseModelFactor
* with 3 variables. To derive from this class, implement evaluateError(). * with 3 variables. To derive from this class, implement evaluateError().
*/ */
@ -701,13 +709,6 @@ class GTSAM_DEPRECATED NoiseModelFactor3
using NoiseModelFactorN<VALUE1, VALUE2, VALUE3>::NoiseModelFactorN; using NoiseModelFactorN<VALUE1, VALUE2, VALUE3>::NoiseModelFactorN;
~NoiseModelFactor3() override {} ~NoiseModelFactor3() override {}
/** Methods to retrieve keys.
* Similar to `ValueType`, you can probably do `return key<#>();`
*/
inline Key key1() const { return this->template key<1>(); }
inline Key key2() const { return this->template key<2>(); }
inline Key key3() const { return this->template key<3>(); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;
@ -719,8 +720,12 @@ class GTSAM_DEPRECATED NoiseModelFactor3
}; // \class NoiseModelFactor3 }; // \class NoiseModelFactor3
/* ************************************************************************* */ /* ************************************************************************* */
/** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1> and X1 /** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1>() and X1
* with ValueType<1>. If your class is templated, use `this->template key<1>()` * with ValueType<1>.
* If your class is templated AND you are trying to call `.key<1>()` or
* `ValueType<1>` inside your class, due to dependent types you need to do
* `this->template key<1>()` or `This::template ValueType<1>`.
* ~~~
* A convenient base class for creating your own NoiseModelFactor * A convenient base class for creating your own NoiseModelFactor
* with 4 variables. To derive from this class, implement evaluateError(). * with 4 variables. To derive from this class, implement evaluateError().
*/ */
@ -748,14 +753,6 @@ class GTSAM_DEPRECATED NoiseModelFactor4
using NoiseModelFactorN<VALUE1, VALUE2, VALUE3, VALUE4>::NoiseModelFactorN; using NoiseModelFactorN<VALUE1, VALUE2, VALUE3, VALUE4>::NoiseModelFactorN;
~NoiseModelFactor4() override {} ~NoiseModelFactor4() override {}
/** Methods to retrieve keys.
* Similar to `ValueType`, you can probably do `return key<#>();`
*/
inline Key key1() const { return this->template key<1>(); }
inline Key key2() const { return this->template key<2>(); }
inline Key key3() const { return this->template key<3>(); }
inline Key key4() const { return this->template key<4>(); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;
@ -767,8 +764,12 @@ class GTSAM_DEPRECATED NoiseModelFactor4
}; // \class NoiseModelFactor4 }; // \class NoiseModelFactor4
/* ************************************************************************* */ /* ************************************************************************* */
/** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1> and X1 /** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1>() and X1
* with ValueType<1>. If your class is templated, use `this->template key<1>()` * with ValueType<1>.
* If your class is templated AND you are trying to call `.key<1>()` or
* `ValueType<1>` inside your class, due to dependent types you need to do
* `this->template key<1>()` or `This::template ValueType<1>`.
* ~~~
* A convenient base class for creating your own NoiseModelFactor * A convenient base class for creating your own NoiseModelFactor
* with 5 variables. To derive from this class, implement evaluateError(). * with 5 variables. To derive from this class, implement evaluateError().
*/ */
@ -798,15 +799,6 @@ class GTSAM_DEPRECATED NoiseModelFactor5
VALUE5>::NoiseModelFactorN; VALUE5>::NoiseModelFactorN;
~NoiseModelFactor5() override {} ~NoiseModelFactor5() override {}
/** Methods to retrieve keys.
* Similar to `ValueType`, you can probably do `return key<#>();`
*/
inline Key key1() const { return this->template key<1>(); }
inline Key key2() const { return this->template key<2>(); }
inline Key key3() const { return this->template key<3>(); }
inline Key key4() const { return this->template key<4>(); }
inline Key key5() const { return this->template key<5>(); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;
@ -818,8 +810,12 @@ class GTSAM_DEPRECATED NoiseModelFactor5
}; // \class NoiseModelFactor5 }; // \class NoiseModelFactor5
/* ************************************************************************* */ /* ************************************************************************* */
/** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1> and X1 /** @deprecated: use NoiseModelFactorN, replacing .key1() with .key<1>() and X1
* with ValueType<1>. If your class is templated, use `this->template key<1>()` * with ValueType<1>.
* If your class is templated AND you are trying to call `.key<1>()` or
* `ValueType<1>` inside your class, due to dependent types you need to do
* `this->template key<1>()` or `This::template ValueType<1>`.
* ~~~
* A convenient base class for creating your own NoiseModelFactor * A convenient base class for creating your own NoiseModelFactor
* with 6 variables. To derive from this class, implement evaluateError(). * with 6 variables. To derive from this class, implement evaluateError().
*/ */
@ -852,16 +848,6 @@ class GTSAM_DEPRECATED NoiseModelFactor6
VALUE6>::NoiseModelFactorN; VALUE6>::NoiseModelFactorN;
~NoiseModelFactor6() override {} ~NoiseModelFactor6() override {}
/** Methods to retrieve keys.
* Similar to `ValueType`, you can probably do `return key<#>();`
*/
inline Key key1() const { return this->template key<1>(); }
inline Key key2() const { return this->template key<2>(); }
inline Key key3() const { return this->template key<3>(); }
inline Key key4() const { return this->template key<4>(); }
inline Key key5() const { return this->template key<5>(); }
inline Key key6() const { return this->template key<6>(); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;