#ifndef Iterator_First #define Iterator_First #ifdef __GNUG__ #pragma interface #endif #include "Types.h" class Container; class Object; class IterIter; //---- IteratorBase ------------------------------------------------------------ class IteratorBase { protected: IteratorBase() { } public: virtual ~IteratorBase(); virtual Object *operator()(); virtual void Reset(); }; //---- Iterator ---------------------------------------------------------------- class Iterator : public IteratorBase { friend Container; friend IterIter; protected: Iterator(); public: ~Iterator(); void Reset(); protected: bool IsActive(); bool Activate(); void Terminate(); bool Activated(); bool Terminated(); virtual Container *GetContainer(); virtual void Detach(); private: //---- only used by Container void ChainIn(Iterator *anchor); void ChainOut(); void Init() { next= this; prev= this; }; private: bool activated, terminated; Iterator *next, *prev; // linking iterators - only used by Container }; //---- Iterator0 --------------------------------------------------------------- class Iterator0 : public Iterator { public: Iterator0(); Object *operator()(); void Reset(); }; //---- Iterator1 --------------------------------------------------------------- class Iterator1 : public Iterator { public: Iterator1(Object*); Object *operator()(); void Reset(); protected: Object *op; int n; }; //---- Iterator inlines -------------------------------------------------------- inline bool Iterator::IsActive() { return activated && ! terminated; } inline bool Iterator::Activated() { return activated; } inline bool Iterator::Terminated() { return terminated; } #endif