/******************************************************************************  		
 * Company:         SINED GmbH
 * Author:          Andriy Kurhanevych
 * Created:         6.10.2004
 * Last modified:   $Modtime: 11.05.07 13:13 $
 * Purpose:         Declaration of the RingEnumerator class
 ******************************************************************************/

#ifndef POLYGONLIBRARY_RINGENUMERATOR_H
#define POLYGONLIBRARY_RINGENUMERATOR_H

namespace PolygonLibrary
{
	class Ring;
	
	//////////////////////////////////////////////////////////////////////////
	/// An iterator over Rings of a Polygon: points to a Ring and allows 
	/// to move the pointer over the Ring collection. 
	/// Initially, the enumerator is positioned before the first element.
	///
	/// The enumerator must not be used after modification of the collection or their items.
	//////////////////////////////////////////////////////////////////////////
	class RingEnumerator
	{
		
	// --- Interface ---
	public:
		RingEnumerator();
		
		/// Returns the current value of the enumerator pointer.
		/// @exception Exceptions::InvalidOperationException - if the enumerator is not positioned  
		/// at an element of the collection (MoveNext() was not called after creation or Reset() or 
		/// last MoveNext() returned false). 
		Ring* Current() const;				
		
		/// Advances the enumerator pointer (Current()) to the next Ring. 
		/// Returns a value indicating if the enumerator was successfully advanced 
		/// (there is a next Ring).
		bool MoveNext();
		
		/// Sets the enumerator pointer to its initial position,
		/// which is before the first Ring.
		void Reset();

	// --- Implementation ---
	private:
		friend class PolygonImpl;

		enum RING_FILTER
		{
			FILTER_EXTERIOR = 1,
			FILTER_INTERIOR = 2, // only till next exterior ring
			FILTER_ALL = 3
		};
		// pRing - pointer to first Ring of the collection
		RingEnumerator(const Ring* pRing, RING_FILTER nFilter);
		// fields
		const Ring* m_pFirstRing;
		const Ring* m_pCurrentRing;
		RING_FILTER m_nFilter;
		bool m_bEnd;
	};

}
#endif