API
4.3
For MATLAB, Python, Java, and C++ users
|
Class used to iterate over subcomponents of a specific type (by default, any Component). More...
Public Member Functions | |
template<typename OtherT > | |
bool | operator== (const ComponentListIterator< OtherT > &other) const |
Check that the component under the current iterator is the same (has same address) as the right-hand iterator. More... | |
template<typename OtherT > | |
bool | operator!= (const ComponentListIterator< OtherT > &other) const |
Check for inequality using same convention as operator==. More... | |
T & | operator* () const |
Dereference the iterator to get a reference to Component of proper type (matching Filter if specified). More... | |
T & | deref () const |
T * | operator-> () const |
Another dereferencing operator that returns a pointer. More... | |
ComponentListIterator & | operator++ () |
Prefix increment operator to get the next item in the ComponentList. More... | |
ComponentListIterator | operator++ (int) |
Postfix increment operator to get the next item in the ComponentList. More... | |
ComponentListIterator & | next () |
Method equivalent to pre-increment operator for operator-deficient languages. More... | |
template<typename FromT > | |
ComponentListIterator (const ComponentListIterator< FromT > &source, typename std::enable_if< std::is_convertible< FromT *, T *>::value >::type *=0) | |
Allow converting from non-const iterator to const_iterator. More... | |
bool | equals (const ComponentListIterator &other) const |
@ Comparison operators for scripting These variants accept only an iterator with the same template parameter. More... | |
bool | operator== (const ComponentListIterator &other) const |
bool | operator!= (const ComponentListIterator &other) const |
Class used to iterate over subcomponents of a specific type (by default, any Component).
This iterator is can either be a const_iterator or non-const iterator, depending on how you got it. If this is a const_iterator, it returns only a const reference to a component. If this is a non-const iterator, then it returns a non-const reference to a component, and thus you can modify the component.
If you got this iterator from something like a ComponentList<const Body>, then it is necessarily a const_iterator. If you got this iterator from something like ComponentList<Body>, then this may be either a const_iterator (e.g., from ComponentList<Body>::cbegin()) or non-const iterator (e.g., from ComponentList<Body>::begin()).
If you have a non-const iterator, you should not add (sub)components to any components.
This iterator works only in the forward direction (not bidirectional).
Here is an example of using this iterator with a range for loop (const_iterator):
Here is a similar example, but where you can modify the components:
|
inline |
Allow converting from non-const iterator to const_iterator.
This helps with iterating through the list in a const way, even if you have a non-const list. This allows the following code:
This constructor does not allow converting from a const_iterator to a non-const iterator (through the enable_if).
|
inline |
|
inline |
@ Comparison operators for scripting These variants accept only an iterator with the same template parameter.
Check for (non)equality using a normal method rather than an operator.
|
inline |
Method equivalent to pre-increment operator for operator-deficient languages.
Referenced by OpenSim::ComponentListIterator< T >::operator++().
|
inline |
Check for inequality using same convention as operator==.
|
inline |
|
inline |
Dereference the iterator to get a reference to Component of proper type (matching Filter if specified).
If you have a const iterator, then this returns a const reference; otherwise, this returns a non-const reference.
References OpenSim::ComponentListIterator< T >::operator->().
ComponentListIterator< T > & OpenSim::ComponentListIterator< T >::operator++ | ( | ) |
Prefix increment operator to get the next item in the ComponentList.
ComponentListIterator<T> pre-increment operator, advances the iterator to the next valid entry.
Prefer to use ++iter and not iter++.
|
inline |
Postfix increment operator to get the next item in the ComponentList.
To enable usage as iter++, although ++iter is more efficient.
References OpenSim::ComponentListIterator< T >::next().
|
inline |
Another dereferencing operator that returns a pointer.
Referenced by OpenSim::ComponentListIterator< T >::deref(), and OpenSim::ComponentListIterator< T >::operator*().
|
inline |
Check that the component under the current iterator is the same (has same address) as the right-hand iterator.
|
inline |