DGtal  0.9.3beta
Public Member Functions | Private Member Functions | Private Attributes
DGtal::OneItemOutputIterator< T > Class Template Reference

#include <DGtal/base/OneItemOutputIterator.h>

Inheritance diagram for DGtal::OneItemOutputIterator< T >:
[legend]
Collaboration 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
 

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

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

Default constructor.

Definition at line 73 of file OneItemOutputIterator.h.

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

73  : myItemPtr(NULL)
74  {
75  myItemPtr = new T();
76  }
T * myItemPtr
pointer that stores the last assigned item
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) {}
T * myItemPtr
pointer that stores the last assigned item

Member Function Documentation

template<typename T >
DGtal::OneItemOutputIterator< T >::BOOST_CONCEPT_ASSERT ( (boost::DefaultConstructible< T >)  )
private
template<typename T >
DGtal::OneItemOutputIterator< T >::BOOST_CONCEPT_ASSERT ( (boost::CopyConstructible< T >)  )
private
template<typename T >
DGtal::OneItemOutputIterator< T >::BOOST_CONCEPT_ASSERT ( (boost::Assignable< T >)  )
private
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.

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

120  {
121  ASSERT( isValid() );
122  return *myItemPtr;
123  }
T * myItemPtr
pointer that stores the last assigned item
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.

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

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

129 { return (myItemPtr != NULL); }
T * myItemPtr
pointer that stores the last assigned item
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; }
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; }
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; }
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.

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

91  {
92  ASSERT( isValid() );
93  *myItemPtr = aItem;
94  return *this;
95  }
T * myItemPtr
pointer that stores the last assigned item

Field Documentation

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

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