API  4.0
For C++ developers
OpenSim::ComponentList< T > Class Template Reference


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 ()
 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

typedef std::add_const< T >::type ConstT
 
typedef ComponentListIterator< ConstTconst_iterator
 A const forward iterator for iterating through ComponentList<T>. More...
 
typedef ComponentListIterator< T > iterator
 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...
 

Detailed Description

template<typename T>
class OpenSim::ComponentList< T >


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().

Member Typedef Documentation

◆ const_iterator

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.

◆ ConstT

template<typename T>
typedef std::add_const<T>::type OpenSim::ComponentList< T >::ConstT

◆ iterator

template<typename T>
typedef ComponentListIterator<T> OpenSim::ComponentList< T >::iterator

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.

Constructor & Destructor Documentation

◆ ComponentList() [1/2]

template<typename T>
OpenSim::ComponentList< T >::ComponentList ( const Component root,
const ComponentFilter f 
)
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().

◆ ComponentList() [2/2]

template<typename T>
OpenSim::ComponentList< T >::ComponentList ( const Component root)
inline

Constructor that takes only a Component to iterate over (itself and its descendants).

ComponentFilterMatchAll is used internally. You can change the filter using setFilter() method.

◆ ~ComponentList()

template<typename T>
virtual OpenSim::ComponentList< T >::~ComponentList ( )
inlinevirtual

Destructor of ComponentList.

Member Function Documentation

◆ begin() [1/2]

template<typename T>
iterator OpenSim::ComponentList< T >::begin ( )
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.

◆ begin() [2/2]

template<typename T>
const_iterator OpenSim::ComponentList< T >::begin ( ) const
inline

Same as cbegin().

◆ cbegin()

template<typename T>
const_iterator OpenSim::ComponentList< T >::cbegin ( ) const
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>).

◆ cend()

template<typename T>
const_iterator OpenSim::ComponentList< T >::cend ( ) const
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().

◆ end() [1/2]

template<typename T>
iterator 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.

◆ end() [2/2]

template<typename T>
const_iterator OpenSim::ComponentList< T >::end ( ) const
inline

◆ setFilter()

template<typename T>
void OpenSim::ComponentList< T >::setFilter ( const ComponentFilter filter)
inline

Allow users to specify a custom ComponentFilter.

This object makes a clone of the passed in filter.


The documentation for this class was generated from the following file: