DGtal  1.2.0
Public Member Functions | Private Member Functions | Private Attributes
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>

Inheritance diagram for DGtal::OneItemOutputIterator< T >:
[legend]

Public Member Functions

 OneItemOutputIterator ()
 
 OneItemOutputIterator (const OneItemOutputIterator &other)
 
OneItemOutputIteratoroperator= (const T &aItem)
 
OneItemOutputIteratoroperator* ()
 
OneItemOutputIteratoroperator++ ()
 
OneItemOutputIterator operator++ (int)
 
get () const
 
bool isValid () const
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((boost::DefaultConstructible< T >))
 
 BOOST_CONCEPT_ASSERT ((boost::CopyConstructible< T >))
 
 BOOST_CONCEPT_ASSERT ((boost::Assignable< T >))
 

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.

Constructor & Destructor Documentation

◆ OneItemOutputIterator() [1/2]

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

Default constructor.

Definition at line 73 of file OneItemOutputIterator.h.

73  : myItemPtr(NULL)
74  {
75  myItemPtr = new T();
76  }
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 80 of file OneItemOutputIterator.h.

80 : myItemPtr(other.myItemPtr) {}

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/3]

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

◆ BOOST_CONCEPT_ASSERT() [2/3]

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

◆ BOOST_CONCEPT_ASSERT() [3/3]

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

◆ 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 119 of file OneItemOutputIterator.h.

120  {
121  ASSERT( isValid() );
122  return *myItemPtr;
123  }

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 129 of file OneItemOutputIterator.h.

129 { 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 101 of file OneItemOutputIterator.h.

101 { 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 107 of file OneItemOutputIterator.h.

107 { return *this; }

◆ operator++() [2/2]

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

Post-increment operator

Returns
*this

Definition at line 113 of file OneItemOutputIterator.h.

113 { 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 90 of file OneItemOutputIterator.h.

91  {
92  ASSERT( isValid() );
93  *myItemPtr = aItem;
94  return *this;
95  }

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

Field Documentation

◆ myItemPtr

template<typename T >
T* DGtal::OneItemOutputIterator< T >::myItemPtr
private

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