35 template<
class ValueType>
36 struct _ValuesKeyValuePair {
40 _ValuesKeyValuePair(
Key _key, ValueType& _value) :
key(_key),
value(_value) {}
44 template<
class ValueType>
45 struct _ValuesConstKeyValuePair {
49 _ValuesConstKeyValuePair(
Key _key,
const ValueType& _value) :
61 template<
class ValueType,
class CastedKeyValuePairType,
class KeyValuePairType>
63 static CastedKeyValuePairType cast(KeyValuePairType key_value) {
65 return CastedKeyValuePairType(key_value.key,
67 ValueType
>&>(key_value.value)).
value());
71 template<
class CastedKeyValuePairType,
class KeyValuePairType>
73 static CastedKeyValuePairType cast(KeyValuePairType key_value) {
77 return CastedKeyValuePairType(key_value.key, key_value.value);
81 template<
class CastedKeyValuePairType,
class KeyValuePairType>
83 static CastedKeyValuePairType cast(KeyValuePairType key_value) {
87 return CastedKeyValuePairType(key_value.key, key_value.value);
92 template <
class ValueType>
93 size_t Values::count()
const {
95 for (
const auto& [_, value] : values_) {
102 template <
class ValueType>
103 std::map<Key, ValueType>
105 std::map<Key, ValueType> result;
106 for (
const auto& [key,value] : values_) {
108 if (filterFcn(key)) {
112 result[key] = t->value();
120 inline bool Values::filterHelper<Value>(
const std::function<
bool(
Key)> filter,
121 const ConstKeyValuePair& key_value) {
123 return filter(key_value.key);
132 template <
typename ValueType>
134 ValueType operator()(
Key j,
const Value*
const pointer) {
145 template <
typename MatrixType,
bool isDynamic>
149 template <
int M,
int N>
151 inline Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
164 template <
int M,
int N>
166 inline Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
182 if (A.rows() != M || A.cols() != N)
191 template <
int M,
int N>
192 struct handle<Eigen::Matrix<double, M, N>> {
193 Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
195 (M == Eigen::Dynamic || N == Eigen::Dynamic)>()(j, pointer);
204 template <
int M,
int N>
205 struct handle_matrix<Eigen::Matrix<double, M, N, 0, M, N>, true> {
206 inline Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
219 template <
int M,
int N>
220 struct handle_matrix<Eigen::Matrix<double, M, N, 0, M, N>, false> {
221 inline Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
222 auto ptr =
dynamic_cast<const GenericValue<Eigen::Matrix<double, M, N>
>*>(pointer);
229 auto ptr =
dynamic_cast<const GenericValue<Eigen::MatrixXd>*
>(pointer);
234 A = handle_matrix<Eigen::VectorXd, true>()(j, pointer);
237 if (A.rows() != M || A.cols() != N)
238 throw NoMatchFoundForFixed(M, N, A.rows(), A.cols());
246 template <
int M,
int N>
247 struct handle<Eigen::Matrix<double, M, N, 0, M, N>> {
248 Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
249 return handle_matrix<Eigen::Matrix<double, M, N, 0, M, N>,
250 (M == Eigen::Dynamic || N == Eigen::Dynamic)>()(j, pointer);
259 template <
typename ValueType>
262 KeyValueMap::const_iterator item = values_.find(j);
270 return h(j, item->second.get());
274 template <
typename ValueType>
277 KeyValueMap::const_iterator item = values_.find(j);
282 const Value* value = item->second.get();
285 assert(ptr &&
"Values::atRef: incorrect ValueType");
295 template<
typename ValueType>
298 KeyValueMap::const_iterator item = values_.find(j);
300 if(item != values_.end()) {
301 const Value* value = item->second.get();
305 return &ptr->value();
318 template<
typename ValueType>
324 template <
typename UnaryOp,
typename ValueType>
330 template <
typename BinaryOp,
typename ValueType1,
typename ValueType2>
331 void Values::insert(
Key j,
const Eigen::CwiseBinaryOp<BinaryOp, const ValueType1, const ValueType2>& val) {
336 template <
typename ValueType>
342 template <
typename UnaryOp,
typename ValueType>
348 template <
typename BinaryOp,
typename ValueType1,
typename ValueType2>
349 void Values::update(
Key j,
const Eigen::CwiseBinaryOp<BinaryOp, const ValueType1, const ValueType2>& val) {
354 template <
typename ValueType>
359 template <
typename UnaryOp,
typename ValueType>
364 template <
typename BinaryOp,
typename ValueType1,
typename ValueType2>
A non-templated config holding any types of Manifold-group elements.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
Wraps any type T so it can play as a Value.
Definition GenericValue.h:48
const T & value() const
Return a constant value.
Definition GenericValue.h:69
This is the base class for any type to be stored in Values.
Definition Value.h:39
Definition Values-inl.h:36
const Key key
The key.
Definition Values-inl.h:37
ValueType & value
The value.
Definition Values-inl.h:38
Definition Values-inl.h:45
const Key key
The key.
Definition Values-inl.h:46
const ValueType & value
The value.
Definition Values-inl.h:47
Definition Values-inl.h:62
Definition Values-inl.h:133
Definition Values-inl.h:146
void update(Key j, const Value &val)
single element change of existing element
Definition Values.cpp:186
const ValueType at(Key j) const
Retrieve a variable by key j.
Definition Values-inl.h:260
void insert(Key j, const Value &val)
Add a variable with the given j, throws KeyAlreadyExists<J> if j is already present.
Definition Values.cpp:170
const ValueType & atRef(Key j) const
Retrieve a variable by key j without copying.
Definition Values-inl.h:275
void insert_or_assign(Key j, const Value &val)
If key j exists, update value, else perform an insert.
Definition Values.cpp:209
Values extract(const KeyVector &keys) const
Returns a new Values holding copies of the values at the given keys, whatever their types.
Definition Values.cpp:252
bool exists(Key j) const
Check if a value exists with key j.
Definition Values.cpp:95