Develop Biology
The language of life
bio::SmartIterator Class Reference

#include <SmartIterator.h>

+ Collaboration diagram for bio::SmartIterator:

Public Member Functions

 SmartIterator (const Container *container)
 
 SmartIterator (const Container *container, Index index)
 
 ~SmartIterator ()
 
template<typename T >
As ()
 
template<typename T >
const T As () const
 
IteratorGetImplementation ()
 
const IteratorGetImplementation () const
 
Index GetIndex () const
 
bool IsAtBeginning () const
 
bool IsAtEnd () const
 
bool MoveTo (Index index) const
 
template<typename T >
 operator const T () const
 
template<typename T >
 operator T ()
 
virtual ByteStream operator* ()
 
virtual const ByteStream operator* () const
 
SmartIteratoroperator++ () const
 
SmartIterator operator++ (int) const
 
SmartIteratoroperator-- () const
 
SmartIterator operator-- (int) const
 

Protected Attributes

Iteratorm_implementation
 

Detailed Description

SmartIterators wrap our iterator interface to provide a consistent means of access. Everything is const so that we don't need to worry about const_iterator vs iterator nonsense.

Definition at line 36 of file SmartIterator.h.

Constructor & Destructor Documentation

◆ SmartIterator() [1/2]

bio::SmartIterator::SmartIterator ( const Container container)

Sets m_index to container->GetEndIndex().

Parameters
container

Definition at line 28 of file SmartIterator.cpp.

29 :
30 m_implementation(container->ConstructClassIterator(container->GetEndIndex()))
31{
32
33}
Iterator * m_implementation

◆ SmartIterator() [2/2]

bio::SmartIterator::SmartIterator ( const Container container,
Index  index 
)
Parameters
container
index

Definition at line 35 of file SmartIterator.cpp.

39 :
40 m_implementation(container->ConstructClassIterator(index))
41{
42
43}

◆ ~SmartIterator()

bio::SmartIterator::~SmartIterator ( )

Not virtual

Definition at line 45 of file SmartIterator.cpp.

46{
47 delete m_implementation;
48}

References m_implementation.

Member Function Documentation

◆ As() [1/2]

template<typename T >
T bio::SmartIterator::As ( )
inline

Convenient casting wrapper.

Template Parameters
T
Returns
*this casted to the given value.

Definition at line 110 of file SmartIterator.h.

111 {
112 return (**this).template As< T >();
113 }

◆ As() [2/2]

template<typename T >
const T bio::SmartIterator::As ( ) const
inline

Convenient casting wrapper.

Template Parameters
T
Returns
*this casted to the given value.

Definition at line 121 of file SmartIterator.h.

122 {
123 return (**this).template As< T >();
124 }

◆ GetImplementation() [1/2]

Iterator * bio::SmartIterator::GetImplementation ( )
Returns
the interface used by *this.

Definition at line 50 of file SmartIterator.cpp.

51{
52 return m_implementation;
53}

References m_implementation.

◆ GetImplementation() [2/2]

const Iterator * bio::SmartIterator::GetImplementation ( ) const
Returns
the interface used by *this.

Definition at line 55 of file SmartIterator.cpp.

56{
57 return m_implementation;
58}

References m_implementation.

◆ GetIndex()

Index bio::SmartIterator::GetIndex ( ) const
Returns
the index *this is currently at.

Definition at line 60 of file SmartIterator.cpp.

61{
62 return m_implementation->GetIndex();
63}
Index GetIndex() const
Definition: Iterator.cpp:43

References bio::Iterator::GetIndex(), and m_implementation.

Referenced by bio::Container::Access(), bio::Container::Erase(), and bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation().

◆ IsAtBeginning()

◆ IsAtEnd()

◆ MoveTo()

bool bio::SmartIterator::MoveTo ( Index  index) const

Make *this point somewhere else;

Parameters
index
Returns
whether or not *this was moved.

Definition at line 65 of file SmartIterator.cpp.

66{
67 return m_implementation->MoveTo(index);
68}
bool MoveTo(const Index index)
Definition: Iterator.cpp:48

References m_implementation, and bio::Iterator::MoveTo().

◆ operator const T()

template<typename T >
bio::SmartIterator::operator const T ( ) const
inline

Convenient casting wrapper.

Template Parameters
T
Returns
*this casted to the given value.

Definition at line 143 of file SmartIterator.h.

144 {
145 return As< T >();
146 }

◆ operator T()

template<typename T >
bio::SmartIterator::operator T ( )
inline

Convenient casting wrapper.

Template Parameters
T
Returns
*this casted to the given value.

Definition at line 132 of file SmartIterator.h.

133 {
134 return As< T >();
135 }

◆ operator*() [1/2]

ByteStream bio::SmartIterator::operator* ( )
virtual

Dereferencing gives the datum *this is currently pointing to.

Returns
a ByteStream containing the datum requested.

Definition at line 80 of file SmartIterator.cpp.

81{
82 return **m_implementation;
83}

References m_implementation.

◆ operator*() [2/2]

const ByteStream bio::SmartIterator::operator* ( ) const
virtual

Dereferencing gives the datum *this is currently pointing to.

Returns
a ByteStream containing the datum requested.

Definition at line 85 of file SmartIterator.cpp.

86{
87 return **m_implementation;
88}

References m_implementation.

◆ operator++() [1/2]

SmartIterator & bio::SmartIterator::operator++ ( ) const
Returns
*this after incrementing.

Definition at line 90 of file SmartIterator.cpp.

91{
93 return *const_cast< SmartIterator* >(this);
94}
virtual Iterator * Increment()
Definition: Iterator.cpp:68
SmartIterator(const Container *container)

References bio::Iterator::Increment(), and m_implementation.

◆ operator++() [2/2]

SmartIterator bio::SmartIterator::operator++ ( int  ) const
Returns
a copy of *this before incrementing.

Definition at line 96 of file SmartIterator.cpp.

97{
98 SmartIterator ret = *this;
100 return ret;
101}

References bio::Iterator::Increment(), and m_implementation.

◆ operator--() [1/2]

SmartIterator & bio::SmartIterator::operator-- ( ) const
Returns
*this following decrementing.

Definition at line 103 of file SmartIterator.cpp.

104{
106 return *const_cast< SmartIterator* >(this);
107}
virtual Iterator * Decrement()
Definition: Iterator.cpp:82

References bio::Iterator::Decrement(), and m_implementation.

◆ operator--() [2/2]

SmartIterator bio::SmartIterator::operator-- ( int  ) const
Returns
a copy of *this before decrementing.

Definition at line 109 of file SmartIterator.cpp.

110{
111 SmartIterator ret = *this;
113 return ret;
114}

References bio::Iterator::Decrement(), and m_implementation.

Member Data Documentation

◆ m_implementation

Iterator* bio::SmartIterator::m_implementation
mutableprotected

Whatever. Make it mutable. I don't care.

Definition at line 172 of file SmartIterator.h.

Referenced by ~SmartIterator(), GetImplementation(), GetIndex(), IsAtBeginning(), IsAtEnd(), MoveTo(), operator*(), operator++(), and operator--().


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