API
4.5.1
For C++ developers
|
Collection (linked list) of components to iterate through.
More...
Public Member Functions | |
ComponentList (const Component &root, const ComponentFilter &f) | |
Constructor that takes a Component to iterate over (itself and its descendants) and a ComponentFilter. More... | |
ComponentList (const Component &root) | |
Constructor that takes only a Component to iterate over (itself and its descendants). More... | |
virtual | ~ComponentList () noexcept=default |
Destructor of ComponentList. More... | |
iterator | begin () |
Return an iterator pointing to the first component in the tree traversal of components under and including the root component passed to the ComponentList constructor. More... | |
const_iterator | begin () const |
Same as cbegin(). More... | |
const_iterator | cbegin () const |
Similar to begin(), except it does not permit modifying the elements of the list, even if T is non-const (e.g., ComponentList<Body>). More... | |
iterator | end () |
Use this method to check if you have reached the end of the list. More... | |
const_iterator | end () const |
Same as cend(). More... | |
const_iterator | cend () const |
Use this method to check if you have reached the end of the list. More... | |
void | setFilter (const ComponentFilter &filter) |
Allow users to specify a custom ComponentFilter. More... | |
Public Types | |
using | ConstT = typename std::add_const< T >::type |
using | value_type = T |
using | difference_type = std::ptrdiff_t |
using | reference = T & |
using | const_reference = const T & |
using | pointer = T * |
using | const_pointer = const T * |
using | iterator = ComponentListIterator< T > |
If T is const (e.g., ComponentList<const Body>), then this is the same as const_iterator, and does not allow modifying the elements. More... | |
using | const_iterator = ComponentListIterator< ConstT > |
A const forward iterator for iterating through ComponentList<T>. More... | |
using | iterator_category = std::forward_iterator_tag |
Collection (linked list) of components to iterate through.
Typical use is to call getComponentList() on a component (e.g. model) to obtain an instance of this class, then call begin() to get an iterator pointing to the first entry in the list then increment the iterator until end(). The linked list is formed by tree pre-order traversal where each component is visited followed by all its immediate subcomponents (recursively).
The traversal order is wired via Component::initComponentTreeTraversal(), which is called just before getting a ComponentList from a Component, either via Component::getComponentList() or Component::updComponentList().
using OpenSim::ComponentList< T >::const_iterator = ComponentListIterator<ConstT> |
A const forward iterator for iterating through ComponentList<T>.
The const indicates that the iterator provides only const references/pointers, and that components can't be modified through this iterator.
using OpenSim::ComponentList< T >::const_pointer = const T* |
using OpenSim::ComponentList< T >::const_reference = const T& |
using OpenSim::ComponentList< T >::ConstT = typename std::add_const<T>::type |
using OpenSim::ComponentList< T >::difference_type = std::ptrdiff_t |
using OpenSim::ComponentList< T >::iterator = ComponentListIterator<T> |
If T is const (e.g., ComponentList<const Body>), then this is the same as const_iterator, and does not allow modifying the elements.
If T is not const, then this iterator allows modifying the elements.
using OpenSim::ComponentList< T >::iterator_category = std::forward_iterator_tag |
using OpenSim::ComponentList< T >::pointer = T* |
using OpenSim::ComponentList< T >::reference = T& |
using OpenSim::ComponentList< T >::value_type = T |
|
inline |
Constructor that takes a Component to iterate over (itself and its descendants) and a ComponentFilter.
You can change the filter later using the setFilter() method. The filter is cloned on construction and can only be changed using setFilter().
|
inline |
Constructor that takes only a Component to iterate over (itself and its descendants).
You can change the filter using setFilter() method.
|
virtualdefaultnoexcept |
Destructor of ComponentList.
|
inline |
Return an iterator pointing to the first component in the tree traversal of components under and including the root component passed to the ComponentList constructor.
If T is non-const, then this iterator allows you to modify the elements of this list.
|
inline |
Same as cbegin().
|
inline |
Similar to begin(), except it does not permit modifying the elements of the list, even if T is non-const (e.g., ComponentList<Body>).
|
inline |
Use this method to check if you have reached the end of the list.
This points past the end of the list, not to the last item in the list. Use this if you used cbegin().
Referenced by OpenSim::ComponentList< T >::end().
|
inline |
Use this method to check if you have reached the end of the list.
This points past the end of the list, not to the last item in the list.
|
inline |
Same as cend().
References OpenSim::ComponentList< T >::cend().
|
inline |
Allow users to specify a custom ComponentFilter.
This object makes a clone of the passed in filter.