Modifiche alla write_rewrite
git-svn-id: svn://10.65.10.50/trunk@5070 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7be232bb33
commit
d4dbe18c39
include
@ -87,16 +87,21 @@ int TMultiple_rectype::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
else
|
||||
{
|
||||
// write:
|
||||
((TMultiple_rectype *)this)->renum_key();
|
||||
TMultiple_rectype & myself = *(TMultiple_rectype *)this;
|
||||
const bool to_complete = !myself.key_complete();
|
||||
if (to_complete)
|
||||
myself.renum();
|
||||
myself.renum_key();
|
||||
myself._nuovo |= to_complete;
|
||||
if (_nuovo)
|
||||
{
|
||||
do
|
||||
{
|
||||
err = TRectype::write(f);
|
||||
if (err == _isreinsert && ((TMultiple_rectype *)this)->renum())
|
||||
((TMultiple_rectype *)this)->renum_key();
|
||||
if (err == _isreinsert && myself.renum())
|
||||
myself.renum_key();
|
||||
} while (err == _isreinsert);
|
||||
((TMultiple_rectype *)this)->_nuovo = (err != NOERR);
|
||||
myself._nuovo = (err != NOERR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -244,7 +249,34 @@ void TMultiple_rectype::synchronize_bodies()
|
||||
}
|
||||
}
|
||||
|
||||
// @mfunc Copia il multiple rectype r su quello corrente
|
||||
TMultiple_rectype & TMultiple_rectype::copy(const TMultiple_rectype& r)
|
||||
{
|
||||
// copia..
|
||||
TAuto_variable_rectype::operator=(r);
|
||||
_files = r._files;
|
||||
_nuovo=r._nuovo;
|
||||
_nfiles=r._nfiles; // file delle righe
|
||||
for (int i = _nfiles - 1; i >= 0; i--)
|
||||
{
|
||||
_logicnums[i] = r._logicnums[i];
|
||||
_changed[i] = r._changed[i];
|
||||
_autoload[i] = r._autoload[i];
|
||||
}
|
||||
_numfields=r._numfields;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// @mfunc Copia il multiple rectype r su quello corrente
|
||||
int TMultiple_rectype::loaded_rows(int logicnum) const
|
||||
{
|
||||
const int index = log2ind(logicnum);
|
||||
TRecord_array * r = (TRecord_array *) ((TMultiple_rectype *) this)->_files.objptr(index);
|
||||
|
||||
if (_changed[index] || r == NULL)
|
||||
return 0;
|
||||
return r->rows();
|
||||
}
|
||||
|
||||
int TMultiple_rectype::remove(TBaseisamfile & f) const
|
||||
{
|
||||
@ -319,17 +351,9 @@ TMultiple_rectype::TMultiple_rectype(const TRectype & rec)
|
||||
|
||||
// @mfunc costruttore di copia
|
||||
TMultiple_rectype::TMultiple_rectype(const TMultiple_rectype& r)
|
||||
:TAuto_variable_rectype(r), _files(r._files)
|
||||
:TAuto_variable_rectype(r)
|
||||
{
|
||||
// copia..
|
||||
_nuovo=r._nuovo;
|
||||
_nfiles=r._nfiles; // file delle righe
|
||||
for (int i = _nfiles - 1; i >= 0; i--)
|
||||
{
|
||||
_logicnums[i] = r._logicnums[i];
|
||||
_changed[i] = r._changed[i];
|
||||
_autoload[i] = r._autoload[i];
|
||||
}
|
||||
_numfields=r._numfields;
|
||||
copy(r);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,12 @@ class TMultiple_rectype : public TAuto_variable_rectype
|
||||
|
||||
protected:
|
||||
const TArray & files() const { return _files;}
|
||||
// @cmember Documento nuovo (non presente sul database).
|
||||
bool nuovo() const { return _nuovo; }
|
||||
// @cmember funzione per costruire la chiave delle righe
|
||||
virtual void set_body_key(TRectype & rowrec);
|
||||
// @cmember verifica se la chiave della testata e' completa
|
||||
virtual bool key_complete() { return FALSE; }
|
||||
// @cmember setta la chiave della testata ad un valore nuovo (next-key)
|
||||
virtual bool renum() { return FALSE; }
|
||||
// @cmember renumera le chiavi di tutti i corpi in base alla testata
|
||||
@ -51,7 +55,7 @@ protected:
|
||||
virtual void load_rows_file(int logicnum);
|
||||
// @cmember Ritorna l'indice di <p _files> del numero logico passato
|
||||
int log2ind(int logicnum) const;
|
||||
// @cmember RIcerca la prima occorenza del corpo con fieldname uguale a s
|
||||
// @cmember RIcerca la prima occorrenza del corpo con fieldname uguale a s
|
||||
virtual int find(int logicnum, const char * fieldname, const char * s, int from = 0, bool reverse = FALSE) const ;
|
||||
// @cmember Scrive/riscrive un corpo
|
||||
virtual int write_rewrite(TBaseisamfile& f, bool re = FALSE) const;
|
||||
@ -62,6 +66,12 @@ protected:
|
||||
void add_file(int logicnum, const char * numfield);
|
||||
// @cmember sincronizza tutti i body (li legge, se necessario) in seguito ad una lettura della testata
|
||||
virtual void synchronize_bodies();
|
||||
virtual TMultiple_rectype & copy(const TMultiple_rectype & r);
|
||||
TObject* dup() const { return new TMultiple_rectype(*this); }
|
||||
|
||||
// @cmember restituisce il numero di record attualmente caricati nel corpo (da usare nella dirty fields)
|
||||
int loaded_rows(int logicnum = 0) const;
|
||||
|
||||
public:
|
||||
//***********************
|
||||
// struttura
|
||||
@ -77,9 +87,9 @@ public:
|
||||
int rows(int logicnum = 0) const { return body(logicnum).rows(); }
|
||||
|
||||
// @cmember restituisce il record n-esimo del del corpo
|
||||
virtual const TRecord_array & operator[](int logicnum) const { return (const TRecord_array &)((TMultiple_rectype *)this)->body(logicnum); }
|
||||
const TRecord_array & operator[](int logicnum) const { return (const TRecord_array &)((TMultiple_rectype *)this)->body(logicnum); }
|
||||
// @cmember restituisce il record n-esimo del del corpo
|
||||
virtual TRecord_array & operator[](int logicnum) { return (TRecord_array &)body(logicnum); }
|
||||
TRecord_array & operator[](int logicnum) { return (TRecord_array &)body(logicnum); }
|
||||
|
||||
// @cmember distrugge una riga del record array del corpo
|
||||
bool destroy_row(int n, bool pack = FALSE, int logicnum = 0) { return body(logicnum).destroy_row(n, pack); }
|
||||
@ -102,6 +112,7 @@ public:
|
||||
virtual void set_fields(TAuto_variable_rectype & rec) {}
|
||||
virtual void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); }
|
||||
|
||||
virtual TMultiple_rectype & operator =(const TMultiple_rectype & r) { return copy(r);}
|
||||
virtual TRectype & operator =(const TRectype & r);
|
||||
virtual TRectype & operator =(const char * r);
|
||||
virtual void zero(char c = '\0');
|
||||
|
Loading…
x
Reference in New Issue
Block a user