Begin by defining the record source:
class TFibonacciRecordSource : public TRecordSource { protected: TFibonacciRecordSource() : fCurrent(0), fNext(1) {} ELength GetRecordCount(long&) const {return TRecordSourceHandle::kInfinite;} ELength GetRecordsRemaining(long&) const {return TRecordSourceHandle::kInfinite;} long GetColumnCount() const {return 1;} long GetColumnTitle(TText title, ColumnPosition) {title.Replace("Fibonacci");} EColumnType GetColumnType(ColumnPosition) {return TRecordSourceHandle::kLong;} Boolean GetField(long& value, ColumnPosition) const {value = fCurrent;} Boolean FetchRecord() { long value = fCurrent + fNext; fCurrent = fNext; fNext = value; return TRUE; } private: long fCurrent; long fNext; friend class TFibonacciRecordSourceHandle; };
class TFibonacciRecordSourceHandle : public TRecordSourceHandle { public: TFibonacciRecordSourceHandle() : TRecordSourceHandle(* new TFibonacciRecordSource); };