// TSchedaPE : ovvero scheda percipienti

#ifndef __M70101_H
#define __M70101_H

#ifndef __RELATION_H
#include <relation.h>
#endif

class TSchedaPE : public TRelation
{
  TArray    _pag,_ver;    
  int       _old_pag, _old_ver;
//  long            _lastvers, _lastpag;  

protected:
  int write_rec(bool re,const TRectype& r,TLocalisamfile& f);
  int cancella (TLocalisamfile& f,int da,int a);
  int registra (bool re,bool force);
  int read_scperc_rows();
  
public:
  virtual int next (TReclock lockop = _nolock) {return (file().next(lockop) || read_scperc_rows());}
  virtual int prev (TReclock lockop = _nolock) {return (file().prev(lockop) || read_scperc_rows());}
  virtual int first(TReclock lockop = _nolock) {return (file().first(lockop) || read_scperc_rows());}
  virtual int last (TReclock lockop = _nolock) {return (file().last(lockop) || read_scperc_rows());}
  virtual int skip (TRecnotype nrec,TReclock lockop = _nolock) {return (file().skip(nrec,lockop) || read_scperc_rows());}
  virtual int read (TIsamop op = _isgteq,TReclock lockop = _nolock,TDate& atdate = (TDate&)botime);
  virtual int write(bool force = TRUE,TDate& atdate = (TDate&)botime);
  virtual int rewrite(bool force = TRUE,TDate& atdate = (TDate&)botime);
  virtual int remove(TDate& atdate = (TDate&)botime);
  
  TRectype& pag(int i);
  TRectype& ver(int i);

  int pag_items() const { return _pag.items(); }
  int ver_items() const { return _ver.items(); }
  
  bool empty_vers(TRectype& ver);

  void destroy_rows();
  
  TSchedaPE();
  virtual ~TSchedaPE() {}
}; 

#endif
  