MeVisLab Toolbox Reference
ml::ContainerProxy< T, R, I, Count, Access > Class Template Reference

This template implements a proxy for containers that contain a collection of items normally accessed with a get-by-index method. More...

#include <mlContainerHelpers.h>

Classes

class  iterator
 

Public Types

using value_type = R *
 
using const_iterator = const iterator
 

Public Member Functions

 ContainerProxy (const T &object)
 
 ContainerProxy (const ContainerProxy &)=default
 
ContainerProxyoperator= (const ContainerProxy &)=default
 
 ContainerProxy (ContainerProxy &&)=default
 
ContainerProxyoperator= (ContainerProxy &&)=default
 
iterator begin () const
 
iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 

Detailed Description

template<class T, class R, typename I, I(T::*)() const Count, R *(T::*)(I) const Access>
class ml::ContainerProxy< T, R, I, Count, Access >

This template implements a proxy for containers that contain a collection of items normally accessed with a get-by-index method.

Due to this structure, it is not possible to use them in any STL-compatible algorithm or range-based for-loop. This way, the proxy provides a begin()/end() pair that follows the standard STL conventions. Note that calling *end() is not advisable.

By defining a proxy like:

using TreeWidgetProxy = ContainerHelpers::ContainerProxy<QTreeWidget,
QTreeWidgetItem,
int,
&QTreeWidget::topLevelItemCount,
&QTreeWidget::topLevelItem>;
auto element = SCR::in(TreeWidgetProxy(*myListView)).find([&value](QTreeWidgetItem* item)
{ return item->text(0) == value; }).or_return_nullptr();

Note: It is not wise to add or remove items within any loop!

Definition at line 65 of file mlContainerHelpers.h.

Member Typedef Documentation

◆ const_iterator

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
using ml::ContainerProxy< T, R, I, Count, Access >::const_iterator = const iterator

Definition at line 158 of file mlContainerHelpers.h.

◆ value_type

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
using ml::ContainerProxy< T, R, I, Count, Access >::value_type = R *

Definition at line 70 of file mlContainerHelpers.h.

Constructor & Destructor Documentation

◆ ContainerProxy() [1/3]

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
ml::ContainerProxy< T, R, I, Count, Access >::ContainerProxy ( const T object)
inlineexplicit

Definition at line 72 of file mlContainerHelpers.h.

◆ ContainerProxy() [2/3]

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
ml::ContainerProxy< T, R, I, Count, Access >::ContainerProxy ( const ContainerProxy< T, R, I, Count, Access > &  )
default

◆ ContainerProxy() [3/3]

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
ml::ContainerProxy< T, R, I, Count, Access >::ContainerProxy ( ContainerProxy< T, R, I, Count, Access > &&  )
default

Member Function Documentation

◆ begin()

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
iterator ml::ContainerProxy< T, R, I, Count, Access >::begin ( ) const
inline

Definition at line 160 of file mlContainerHelpers.h.

◆ cbegin()

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
const_iterator ml::ContainerProxy< T, R, I, Count, Access >::cbegin ( ) const
inline

Definition at line 170 of file mlContainerHelpers.h.

◆ cend()

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
const_iterator ml::ContainerProxy< T, R, I, Count, Access >::cend ( ) const
inline

Definition at line 175 of file mlContainerHelpers.h.

◆ end()

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
iterator ml::ContainerProxy< T, R, I, Count, Access >::end ( ) const
inline

Definition at line 165 of file mlContainerHelpers.h.

◆ operator=() [1/2]

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
ContainerProxy& ml::ContainerProxy< T, R, I, Count, Access >::operator= ( const ContainerProxy< T, R, I, Count, Access > &  )
default

◆ operator=() [2/2]

template<class T , class R , typename I , I(T::*)() const Count, R *(T::*)(I) const Access>
ContainerProxy& ml::ContainerProxy< T, R, I, Count, Access >::operator= ( ContainerProxy< T, R, I, Count, Access > &&  )
default

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