00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00020 #ifndef flc_sequence_H
00021 #define flc_sequence_H
00022
00023 #include <falcon/setup.h>
00024 #include <falcon/falcondata.h>
00025
00026 namespace Falcon {
00027
00028 class VMachine;
00029 class Iterator;
00030 class Item;
00031 class Garbageable;
00032
00044 class FALCON_DYN_CLASS Sequence: public FalconData
00045 {
00046 Garbageable* m_owner;
00047 protected:
00048 mutable Iterator* m_iterList;
00049
00050 public:
00051 Sequence():
00052 m_owner(0),
00053 m_iterList(0)
00054 {}
00055
00056 virtual ~Sequence()
00057 {
00058 invalidateAllIters();
00059 }
00060
00068 void invalidateAllIters();
00069
00076 void invalidateAnyOtherIter( Iterator* iter );
00077
00084 virtual void invalidateIteratorOnCriterion() const;
00085
00090 virtual bool onCriterion( Iterator* elem ) const {return false;}
00091
00092
00094 virtual bool isSequence() const { return true; }
00095
00097 virtual bool isDictionary() const { return false; }
00098
00108 virtual const Item &front() const = 0;
00109
00122 virtual const Item &back() const = 0;
00123
00125 virtual void clear() = 0;
00126
00131 virtual bool empty() const =0;
00132
00134 virtual void append( const Item &data ) = 0;
00135
00137 virtual void prepend( const Item &data ) = 0;
00138
00150 virtual void comprehension( VMachine* vm, const Item& compounder, const Item& filter );
00151
00158 void owner( Garbageable* owner ) { m_owner = owner; }
00159 Garbageable* owner() { return m_owner; }
00160 virtual void gcMark( uint32 gen );
00161
00162
00163
00164
00165
00166 protected:
00167 friend class Iterator;
00168
00190 virtual void getIterator( Iterator& tgt, bool tail = false ) const;
00191
00200 virtual void copyIterator( Iterator& tgt, const Iterator& source ) const;
00201
00214 virtual void disposeIterator( Iterator& tgt ) const;
00215
00216
00238 virtual void insert( Iterator &iter, const Item &data ) = 0;
00239
00258 virtual void erase( Iterator &iter ) = 0;
00259 virtual bool hasNext( const Iterator &iter ) const = 0;
00260 virtual bool hasPrev( const Iterator &iter ) const = 0;
00261 virtual bool hasCurrent( const Iterator &iter ) const = 0;
00262
00263 virtual bool next( Iterator &iter ) const = 0;
00264 virtual bool prev( Iterator &iter ) const = 0;
00265
00266 virtual Item& getCurrent( const Iterator &iter ) = 0;
00267 virtual Item& getCurrentKey( const Iterator &iter ) = 0;
00268
00269 virtual bool equalIterator( const Iterator &first, const Iterator &second ) const = 0;
00270
00271 };
00272
00273 }
00274
00275 #endif
00276
00277