29#include <boost/bind/bind.hpp>
37 template<
class ValueType>
46 template<
class ValueType>
63 template<
class ValueType,
class CastedKeyValuePairType,
class KeyValuePairType>
65 static CastedKeyValuePairType cast(KeyValuePairType key_value) {
67 return CastedKeyValuePairType(key_value.key,
69 ValueType
>&>(key_value.value)).
value());
73 template<
class CastedKeyValuePairType,
class KeyValuePairType>
75 static CastedKeyValuePairType cast(KeyValuePairType key_value) {
79 return CastedKeyValuePairType(key_value.key, key_value.value);
83 template<
class CastedKeyValuePairType,
class KeyValuePairType>
85 static CastedKeyValuePairType cast(KeyValuePairType key_value) {
89 return CastedKeyValuePairType(key_value.key, key_value.value);
94 template<
class ValueType>
103 boost::transform_iterator<
105 boost::filter_iterator<
110 typedef iterator const_iterator;
113 boost::transform_iterator<
115 boost::filter_iterator<
118 const_const_iterator;
120 iterator begin() {
return begin_; }
122 const_iterator begin()
const {
return begin_; }
123 const_iterator end()
const {
return end_; }
124 const_const_iterator beginConst()
const {
return constBegin_; }
125 const_const_iterator endConst()
const {
return constEnd_; }
130 for (const_const_iterator it = beginConst(); it != endConst(); ++it)
140 boost::make_transform_iterator(
141 boost::make_filter_iterator(
filter, values.begin(), values.end()),
143 boost::make_transform_iterator(
144 boost::make_filter_iterator(
filter, values.end(), values.end()),
146 boost::make_transform_iterator(
147 boost::make_filter_iterator(
filter,
148 ((const
Values&) values).begin(),
149 ((const
Values&) values).end()),
152 boost::make_transform_iterator(
153 boost::make_filter_iterator(
filter,
154 ((const
Values&) values).end(),
155 ((const
Values&) values).end()),
163 const_const_iterator constBegin_;
164 const_const_iterator constEnd_;
168 template<
class ValueType>
175 typedef typename Filtered<ValueType>::const_const_iterator iterator;
176 typedef typename Filtered<ValueType>::const_const_iterator const_iterator;
180 begin_(rhs.beginConst()),
181 end_(rhs.endConst()) {}
184 iterator end() {
return end_; }
185 const_iterator begin()
const {
return begin_; }
186 const_iterator end()
const {
return end_; }
191 for (const_iterator it = begin(); it != end(); ++it)
199 result.push_back(it->key);
205 const_iterator begin_;
212 const Filtered<ValueType> filtered(
filter,
const_cast<Values&
>(values));
213 begin_ = filtered.beginConst();
214 end_ = filtered.endConst();
220 template<
class ValueType>
222 for(
const auto key_value: view) {
223 Key key = key_value.key;
224 insert(key,
static_cast<const ValueType&
>(key_value.value));
229 template<
class ValueType>
231 for(
const auto key_value: view) {
232 Key key = key_value.key;
233 insert(key,
static_cast<const ValueType&
>(key_value.value));
240 return filter<Value>(filterFcn);
244 template<
class ValueType>
248 std::placeholders::_1), *
this);
254 return filter<Value>(filterFcn);
258 template<
class ValueType>
262 filterFcn, std::placeholders::_1), *
this);
267 inline bool Values::filterHelper<Value>(
const std::function<
bool(
Key)> filter,
268 const ConstKeyValuePair& key_value) {
270 return filter(key_value.key);
279 template <
typename ValueType>
281 ValueType operator()(
Key j,
const Value*
const pointer) {
285 }
catch (std::bad_cast&) {
291 template <
typename MatrixType,
bool isDynamic>
295 template <
int M,
int N>
297 Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
301 }
catch (std::bad_cast&) {
309 template <
int M,
int N>
311 Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
315 }
catch (std::bad_cast&) {
325 if (A.rows() != M || A.cols() != N)
334 template <
int M,
int N>
335 struct handle<Eigen::Matrix<double, M, N>> {
336 Eigen::Matrix<double, M, N> operator()(
Key j,
const Value*
const pointer) {
338 (M == Eigen::Dynamic || N == Eigen::Dynamic)>()(j, pointer);
345 template <
typename ValueType>
348 KeyValueMap::const_iterator item = values_.find(j);
356 return h(j, item->second);
360 template<
typename ValueType>
363 KeyValueMap::const_iterator item = values_.find(j);
365 if(item != values_.end()) {
367 const Value& value = *item->second;
370 }
catch (std::bad_cast &) {
372 const Value* value = item->second;
383 template<
typename ValueType>
389 template <
typename ValueType>
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:69
Definition: FastList.h:40
Wraps any type T so it can play as a Value.
Definition: GenericValue.h:47
const T & value() const
Return a constant value.
Definition: GenericValue.h:67
This is the base class for any type to be stored in Values.
Definition: Value.h:36
Definition: Values-inl.h:38
const Key key
The key.
Definition: Values-inl.h:39
ValueType & value
The value.
Definition: Values-inl.h:40
Definition: Values-inl.h:47
const Key key
The key.
Definition: Values-inl.h:48
const ValueType & value
The value.
Definition: Values-inl.h:49
Definition: Values-inl.h:64
A filtered view of a Values, returned from Values::filter.
Definition: Values-inl.h:95
size_t size() const
Returns the number of values in this view.
Definition: Values-inl.h:128
_ValuesKeyValuePair< ValueType > KeyValuePair
A key-value pair, with the value a specific derived Value type.
Definition: Values-inl.h:98
A filtered view of a const Values, returned from Values::filter.
Definition: Values-inl.h:169
ConstFiltered(const Filtered< ValueType > &rhs)
Conversion from Filtered to ConstFiltered.
Definition: Values-inl.h:179
size_t size() const
Returns the number of values in this view.
Definition: Values-inl.h:189
_ValuesConstKeyValuePair< ValueType > KeyValuePair
A const key-value pair, with the value a specific derived Value type.
Definition: Values-inl.h:172
Definition: Values-inl.h:280
Definition: Values-inl.h:292
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63
boost::transform_iterator< std::function< ConstKeyValuePair(const ConstKeyValuePtrPair &)>, KeyValueMap::const_iterator > const_iterator
Const forward iterator, with value type ConstKeyValuePair.
Definition: Values.h:117
const ValueType at(Key j) const
Retrieve a variable by key j.
Definition: Values-inl.h:346
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:132
bool exists(Key j) const
Check if a value exists with key j.
Definition: Values.cpp:96
Values()
Default constructor creates an empty Values class.
Definition: Values.h:138
void update(Key j, const Value &val)
single element change of existing element
Definition: Values.cpp:153
boost::transform_iterator< std::function< KeyValuePair(const KeyValuePtrPair &)>, KeyValueMap::iterator > iterator
Mutable forward iterator, with value type KeyValuePair.
Definition: Values.h:113
Filtered< Value > filter(const std::function< bool(Key)> &filterFcn)
Return a filtered view of this Values class, without copying any data.
Definition: Values-inl.h:239
A key-value pair, which you get by dereferencing iterators.
Definition: Values.h:95
A key-value pair, which you get by dereferencing iterators.
Definition: Values.h:103