ImFusion C++ SDK 4.4.0
ImFusion::Utils::LinearIterator< T > Class Template Reference

#include <ImFusion/Base/Utils/Iterators.h>

Typed convenience iterator for quick integration into custom containers, especially if traversal requires on-the-fly evaluations. More...

Detailed Description

template<typename T>
class ImFusion::Utils::LinearIterator< T >

Typed convenience iterator for quick integration into custom containers, especially if traversal requires on-the-fly evaluations.

Note that operator* only returns T and not T&. For the same reason, there is no operator->. This supports pure rvalue expressions on regular dereferencing if you choose non-reference types for T.

For instance, TrackingSequence::matrix(int index) computes the matrix product registration*m_matrix[i]*calibration, so there is no container for direct traversal. Hence, a naive implementation of TrackingSequence::begin() and TrackingSequence::end() could look like this:

Utils::LinearIterator<mat4> TrackingSequence::begin() const
{
return Utils::LinearIterator<mat4>(0, [this](int i){ return matrix(i); });
}
Typed convenience iterator for quick integration into custom containers, especially if traversal requ...
Definition Iterators.h:43

This allows:

for(mat4 m : ts)
LOG_INFO("Matrix " << m);
Sequence of rigid tracking data with optional timestamps, quality values and flags.
Definition TrackingSequence.h:47
#define LOG_INFO(...)
Emits a log message of Log::Level::Info, optionally with a category.
Definition Log.h:247

Public Types

using iterator_category = std::random_access_iterator_tag
using value_type = T
using difference_type = ptrdiff_t
using pointer = T*
using reference = T&
using LinIt = LinearIterator<T>

Public Member Functions

 LinearIterator (int pos, std::function< T(int)> func)
 LinearIterator (const LinIt &)=default
int index () const
LinIt & operator= (const LinIt &)=default
operator* () const
LinIt & operator++ ()
LinIt operator++ (int)
LinIt & operator-- ()
LinIt operator-- (int)
LinIt & operator+= (int rhs)
LinIt & operator-= (int rhs)
LinIt operator+ (const LinIt &rhs)
LinIt operator+ (int rhs)
std::ptrdiff_t operator- (const LinIt &rhs)
bool operator== (const LinIt &rhs)
bool operator!= (const LinIt &rhs)

Protected Attributes

int m_pos
std::function< T(int)> m_func

The documentation for this class was generated from the following file:
  • ImFusion/Base/Utils/Iterators.h
Search Tab / S to search, Esc to close