//===========================================================================// // File: iterator.hh // // Project: MUNGA Brick: Connection Library // // Contents: Interface specifications for the abstract iterator // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 10/19/94 ECH Initial coding. // // 10/20/94 JMA Fixed style stuff. // // 10/23/94 ECH Added Begin, End, Forward, Backward style iteration // // methods // // 10/23/94 ECH Added higher level of deletion safety // // 10/28/94 JMA Made compatible with SGI CC // // 11/03/94 ECH Made compatible with BC4.0 // // 01/04/95 ECH Added base methods for some iterator methods // //---------------------------------------------------------------------------// // Copyright (C) 1994-1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #pragma once #include "Stuff.hpp" namespace Stuff { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Iterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class _declspec(novtable) Iterator #if defined(_ARMOR) : public Stuff::Signature #endif { public: // //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Public interface to abstract class // // NOTE: All unsafe, untyped public methods are named XXXItem. The // safe, typed public methods are named XXX and are declared in the // template sub-classes. //-------------------------------------------------------------------- //-------------------------------------------------------------------- // // //-------------------------------------------------------------------- // Destructor and testing //-------------------------------------------------------------------- // virtual ~Iterator() {} virtual Iterator* MakeClone() = 0; void TestInstance() {} // //-------------------------------------------------------------------- // First - Moves to next item // Last - Moves to last item //-------------------------------------------------------------------- // virtual Iterator& First()=0; virtual Iterator& Last()=0; // //-------------------------------------------------------------------- // Next - Moves to next item // Previous - Moves to previous item //-------------------------------------------------------------------- // virtual Iterator& Next()=0; virtual Iterator& Previous()=0; // //-------------------------------------------------------------------- // ReadAndNextItem - Returns current item and moves to next item // ReadAndPreviousItem - Returns current item and moves to prev item // GetCurrentItem - Returns current item //-------------------------------------------------------------------- // virtual void* GetCurrentItem()=0; virtual void* ReadAndNextItem()=0; virtual void* ReadAndPreviousItem()=0; virtual unsigned GetSize()=0; virtual void* GetNthItem(unsigned index)=0; Iterator& operator++() {return Next();} Iterator& operator--() {return Previous();} protected: // //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Protected interface to abstract class //-------------------------------------------------------------------- //-------------------------------------------------------------------- // explicit Iterator() {} }; }