00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef FALCON_GENERATORSEQ_H
00018 #define FALCON_GENERATORSEQ_H
00019
00020 #include <falcon/setup.h>
00021 #include <falcon/sequence.h>
00022 #include <falcon/item.h>
00023
00024 namespace Falcon {
00025
00026 class FALCON_DYN_CLASS GeneratorSeq: public Sequence
00027 {
00028 VMachine* m_vm;
00029
00030 Item m_callable;
00031 mutable Item m_cache_cur;
00032 mutable Item m_cache_next;
00033
00034 mutable bool m_bHasCachedCur;
00035 mutable bool m_bHasCachedNext;
00036 mutable bool m_bComplete;
00037
00038 bool fillCurrentValue() const;
00039 bool fillNextValue() const;
00040
00041 public:
00042 GeneratorSeq( VMachine* runEvn, const Item& callable );
00043 GeneratorSeq( const GeneratorSeq& other );
00044
00045 virtual ~GeneratorSeq();
00046
00047 virtual const Item &front() const;
00048 virtual const Item &back() const;
00049 virtual void clear();
00050 virtual bool empty() const;
00051 virtual void append( const Item &data );
00052 virtual void prepend( const Item &data );
00053 virtual FalconData* clone() const;
00054 virtual void gcMark( uint32 gen );
00055
00056
00057
00058
00059
00060 protected:
00061 virtual void getIterator( Iterator& tgt, bool tail = false ) const;
00062 virtual void copyIterator( Iterator& tgt, const Iterator& source ) const;
00063 virtual void insert( Iterator &iter, const Item &data );
00064 virtual void erase( Iterator &iter );
00065 virtual bool hasNext( const Iterator &iter ) const;
00066 virtual bool hasPrev( const Iterator &iter ) const;
00067 virtual bool hasCurrent( const Iterator &iter ) const;
00068
00069 virtual bool next( Iterator &iter ) const;
00070 virtual bool prev( Iterator &iter ) const;
00071
00072 virtual Item& getCurrent( const Iterator &iter );
00073 virtual Item& getCurrentKey( const Iterator &iter );
00074
00075 virtual bool equalIterator( const Iterator &first, const Iterator &second ) const;
00076 };
00077
00078 }
00079
00080 #endif
00081
00082