Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE > Class Template Reference

EnumeratorContainer is based on some COLLECTION class that represents a collection class of some sort, i.e. More...

#include <vcf/FoundationKit/Enumerator.h>

Inheritance diagram for VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >:

VCF::Enumerator< COLLECTION_TYPE > List of all members.

Public Member Functions

 EnumeratorContainer (COLLECTION &container)
 EnumeratorContainer ()
virtual ~EnumeratorContainer ()
virtual void initContainer (COLLECTION &container)
 Initializes the container with a reference to an existing collection.
virtual bool hasMoreElements (const bool &backward=false)
 indicates whether there are any more children to enumerate through
virtual COLLECTION_TYPE nextElement ()
 returns the next element in the enumeration.
virtual COLLECTION_TYPE prevElement ()
 returns the previous element in the enumeration.
virtual void reset (const bool &backward=false)
 Resets the Enumerator's internal iterator back to the beginning (or end, if backward is true).
virtual Enumerator< COLLECTION_TYPE > * getEnumerator ()
 returns a pointer to the Enumerator interface of this container.

Detailed Description

template<class COLLECTION, class COLLECTION_TYPE>
class VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >

EnumeratorContainer is based on some COLLECTION class that represents a collection class of some sort, i.e.

std::vector<>, std::list, et al.

The internal implementation counts on the collection having a common interface to STL's collection classes.

The collection must support forward and reverse iterators

The COLLECTION type specifies the full collection associated with the enumerator.

For example, an enumerator container of Object* using a std::vector as it's collection type would look like this:

    EnumeratorContainer<std::vector<Object*>,Object*> objectVecEnumerator;
The COLLECTION_TYPE represents the type of an individual element in the enumerator. Passing in a reference to the collection variable in the contstructor will automatically set up the internal iterator, nothing further need be done. Alternatively, you may call the initContainer() method with a reference to the collection


Constructor & Destructor Documentation

template<class COLLECTION, class COLLECTION_TYPE>
VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::EnumeratorContainer COLLECTION &  container  )  [inline]
 

template<class COLLECTION, class COLLECTION_TYPE>
VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::EnumeratorContainer  )  [inline]
 

template<class COLLECTION, class COLLECTION_TYPE>
virtual VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::~EnumeratorContainer  )  [inline, virtual]
 


Member Function Documentation

template<class COLLECTION, class COLLECTION_TYPE>
virtual Enumerator<COLLECTION_TYPE>* VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::getEnumerator  )  [inline, virtual]
 

returns a pointer to the Enumerator interface of this container.

Automatically resets the collection before returning the pointer.

Returns:
Enumerator<COLLECTION_TYPE> a pointer to the collection as an Enumerator interface.

template<class COLLECTION, class COLLECTION_TYPE>
virtual bool VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::hasMoreElements const bool &  backward = false  )  [inline, virtual]
 

indicates whether there are any more children to enumerate through

Parameters:
bool specifies whether the enumeration should be forwards or backwards. The default value is true for enumerating forwards.
Returns:
bool true if there are any elements left to enumerate, otherwise returns false.

Implements VCF::Enumerator< COLLECTION_TYPE >.

template<class COLLECTION, class COLLECTION_TYPE>
virtual void VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::initContainer COLLECTION &  container  )  [inline, virtual]
 

Initializes the container with a reference to an existing collection.

template<class COLLECTION, class COLLECTION_TYPE>
virtual COLLECTION_TYPE VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::nextElement  )  [inline, virtual]
 

returns the next element in the enumeration.

Moves the internal iterator forward

Returns:
COLLECTION_TYPE returns a COLLECTION_TYPE value of whatever type was specified in the template argument to the Enumerator

Implements VCF::Enumerator< COLLECTION_TYPE >.

template<class COLLECTION, class COLLECTION_TYPE>
virtual COLLECTION_TYPE VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::prevElement  )  [inline, virtual]
 

returns the previous element in the enumeration.

Moves the internal iterator backward

Returns:
COLLECTION_TYPE returns a COLLECTION_TYPE value of whatever type was specified in the template argument to the Enumerator

Implements VCF::Enumerator< COLLECTION_TYPE >.

template<class COLLECTION, class COLLECTION_TYPE>
virtual void VCF::EnumeratorContainer< COLLECTION, COLLECTION_TYPE >::reset const bool &  backward = false  )  [inline, virtual]
 

Resets the Enumerator's internal iterator back to the beginning (or end, if backward is true).

Parameters:
bool specifies which direction to reset to

Implements VCF::Enumerator< COLLECTION_TYPE >.


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information