DGtal  1.5.beta
DGtal::OneItemOutputIterator< T > Class Template Reference

Aim: model of output iterator, ie incrementable and writable iterator, which only stores in a variable the last assigned item. More...

#include <DGtal/base/OneItemOutputIterator.h>

Public Types

using iterator_category = std::output_iterator_tag
 
using value_type = void
 
using difference_type = void
 
using pointer = void
 
using reference = void
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((boost::DefaultConstructible< T >))
 
 BOOST_CONCEPT_ASSERT ((boost::CopyConstructible< T >))
 
 BOOST_CONCEPT_ASSERT ((boost::Assignable< T >))
 
 OneItemOutputIterator ()
 
 OneItemOutputIterator (const OneItemOutputIterator &other)
 
OneItemOutputIteratoroperator= (const T &aItem)
 
OneItemOutputIteratoroperator* ()
 
OneItemOutputIteratoroperator++ ()
 
OneItemOutputIterator operator++ (int)
 
get () const
 
bool isValid () const
 

Private Attributes

T * myItemPtr
 pointer that stores the last assigned item More...
 

Detailed Description

template<typename T>
class DGtal::OneItemOutputIterator< T >

Aim: model of output iterator, ie incrementable and writable iterator, which only stores in a variable the last assigned item.

Description of template class 'OneItemOutputIterator'

Template Parameters
Tat least a default constructible, copy constuctible and assignable type.

Definition at line 59 of file OneItemOutputIterator.h.

Member Typedef Documentation

◆ difference_type

template<typename T >
using DGtal::OneItemOutputIterator< T >::difference_type = void

Definition at line 65 of file OneItemOutputIterator.h.

◆ iterator_category

template<typename T >
using DGtal::OneItemOutputIterator< T >::iterator_category = std::output_iterator_tag

Definition at line 63 of file OneItemOutputIterator.h.

◆ pointer

template<typename T >
using DGtal::OneItemOutputIterator< T >::pointer = void

Definition at line 66 of file OneItemOutputIterator.h.

◆ reference

template<typename T >
using DGtal::OneItemOutputIterator< T >::reference = void

Definition at line 67 of file OneItemOutputIterator.h.

◆ value_type

template<typename T >
using DGtal::OneItemOutputIterator< T >::value_type = void

Definition at line 64 of file OneItemOutputIterator.h.

Constructor & Destructor Documentation

◆ OneItemOutputIterator() [1/2]

template<typename T >
DGtal::OneItemOutputIterator< T >::OneItemOutputIterator ( )
inline

Default constructor.

Definition at line 80 of file OneItemOutputIterator.h.

80  : myItemPtr(NULL)
81  {
82  myItemPtr = new T();
83  }
T * myItemPtr
pointer that stores the last assigned item

References DGtal::OneItemOutputIterator< T >::myItemPtr.

◆ OneItemOutputIterator() [2/2]

template<typename T >
DGtal::OneItemOutputIterator< T >::OneItemOutputIterator ( const OneItemOutputIterator< T > &  other)
inline

Copy constructor.

Definition at line 87 of file OneItemOutputIterator.h.

87 : myItemPtr(other.myItemPtr) {}

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/3]

template<typename T >
DGtal::OneItemOutputIterator< T >::BOOST_CONCEPT_ASSERT ( (boost::Assignable< T >)  )

◆ BOOST_CONCEPT_ASSERT() [2/3]

template<typename T >
DGtal::OneItemOutputIterator< T >::BOOST_CONCEPT_ASSERT ( (boost::CopyConstructible< T >)  )

◆ BOOST_CONCEPT_ASSERT() [3/3]

template<typename T >
DGtal::OneItemOutputIterator< T >::BOOST_CONCEPT_ASSERT ( (boost::DefaultConstructible< T >)  )

◆ get()

template<typename T >
T DGtal::OneItemOutputIterator< T >::get ( ) const
inline

Accessor to the last assigned item.

Returns
the content of myItem.

Definition at line 126 of file OneItemOutputIterator.h.

127  {
128  ASSERT( isValid() );
129  return *myItemPtr;
130  }

References DGtal::OneItemOutputIterator< T >::isValid(), and DGtal::OneItemOutputIterator< T >::myItemPtr.

◆ isValid()

template<typename T >
bool DGtal::OneItemOutputIterator< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 136 of file OneItemOutputIterator.h.

136 { return (myItemPtr != NULL); }

References DGtal::OneItemOutputIterator< T >::myItemPtr.

Referenced by DGtal::OneItemOutputIterator< T >::get(), and DGtal::OneItemOutputIterator< T >::operator=().

◆ operator*()

template<typename T >
OneItemOutputIterator& DGtal::OneItemOutputIterator< T >::operator* ( )
inline

Dereference operator

Returns
a reference to *this

Definition at line 108 of file OneItemOutputIterator.h.

108 { return *this; }

◆ operator++() [1/2]

template<typename T >
OneItemOutputIterator& DGtal::OneItemOutputIterator< T >::operator++ ( )
inline

Pre-increment operator

Returns
a reference to *this

Definition at line 114 of file OneItemOutputIterator.h.

114 { return *this; }

◆ operator++() [2/2]

template<typename T >
OneItemOutputIterator DGtal::OneItemOutputIterator< T >::operator++ ( int  )
inline

Post-increment operator

Returns
*this

Definition at line 120 of file OneItemOutputIterator.h.

120 { return *this; }

◆ operator=()

template<typename T >
OneItemOutputIterator& DGtal::OneItemOutputIterator< T >::operator= ( const T &  aItem)
inline

Assignment

Parameters
aItemany item
Returns
a reference to *this

Definition at line 97 of file OneItemOutputIterator.h.

98  {
99  ASSERT( isValid() );
100  *myItemPtr = aItem;
101  return *this;
102  }

References DGtal::OneItemOutputIterator< T >::isValid(), and DGtal::OneItemOutputIterator< T >::myItemPtr.

Field Documentation

◆ myItemPtr


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