Aggiunti/modificati oggetti per la gestione anche della struttura ad albero
dei saldi, movimenti e dettagli git-svn-id: svn://10.65.10.50/trunk@5972 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f3ff2fe98a
commit
2039d9bb9e
@ -2,15 +2,16 @@
|
|||||||
#include "ablib01.h"
|
#include "ablib01.h"
|
||||||
|
|
||||||
|
|
||||||
void TTest::main_loop()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
void test_analisi()
|
||||||
|
{
|
||||||
//Questa parte di funzione serve per testare la read, write, delete_node, delete_tree, delete_subtree ecc
|
//Questa parte di funzione serve per testare la read, write, delete_node, delete_tree, delete_subtree ecc
|
||||||
|
|
||||||
TLocalisamfile anas(LF_ANALISI);
|
TLocalisamfile anas(LF_ANALISI);
|
||||||
anas.set_curr(new TAnalisi_bil());
|
anas.set_curr(new TAnalisi_bil());
|
||||||
anas.put(ABAN_CODAN,"A1");
|
anas.put(ABAN_CODAN,"A1");
|
||||||
anas.read();
|
anas.read();
|
||||||
|
// readat -> vedi dopo
|
||||||
anas.remove(); //Solo per il test della delete_node o la rimozione di una intera tabella
|
anas.remove(); //Solo per il test della delete_node o la rimozione di una intera tabella
|
||||||
//anas.write();
|
//anas.write();
|
||||||
|
|
||||||
@ -18,9 +19,9 @@ void TTest::main_loop()
|
|||||||
/*Questa parte della funzione serve solo per testare la readat
|
/*Questa parte della funzione serve solo per testare la readat
|
||||||
|
|
||||||
|
|
||||||
TRecnotype nrec = 10; //Per capire quale numero ci va scommenta la riga successiva e provare col debug
|
TRecnotype nrec = 14; //Per capire quale numero ci va scommenta la riga di nrec e provare col debug
|
||||||
//nrec = anas.recno(); //nrec è un TRecnotype: dice quale numero ci va dopo
|
|
||||||
TLocalisamfile anas1(LF_ANALISI);
|
TLocalisamfile anas1(LF_ANALISI);
|
||||||
|
// nrec = anas1.recno(); //nrec è un TRecnotype: dice quale numero ci va dopo
|
||||||
anas1.set_curr(new TAnalisi_bil());
|
anas1.set_curr(new TAnalisi_bil());
|
||||||
anas1.readat(nrec);
|
anas1.readat(nrec);
|
||||||
//Abilitare solo una di queste funzioni
|
//Abilitare solo una di queste funzioni
|
||||||
@ -30,6 +31,33 @@ void TTest::main_loop()
|
|||||||
E deve esserci solo questo pezzo: tutto il resto deve essere commentato */
|
E deve esserci solo questo pezzo: tutto il resto deve essere commentato */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_saldi()
|
||||||
|
{
|
||||||
|
TLocalisamfile saldo(LF_ABSALDI);
|
||||||
|
// TRecnotype nrec = 96; //Abilitare questa riga per testare la readat
|
||||||
|
|
||||||
|
saldo.set_curr(new TABsaldo());
|
||||||
|
saldo.put(ABMD_CODDITTA,"00001");
|
||||||
|
saldo.put(ABMD_ANNO,"1996");
|
||||||
|
saldo.put(ABMD_CODPDB,"001");
|
||||||
|
saldo.put(ABMD_TIPOBIL,"E2");
|
||||||
|
saldo.put(ABMD_CODCBL,"000000000200");
|
||||||
|
// saldo.readat(nrec); //Se si abilita il test della readat, commentare le righe che riguardano la read
|
||||||
|
int err=saldo.read();
|
||||||
|
if (err!=NOERR)
|
||||||
|
CHECK (FALSE,"Errore nella letture del record di testata");
|
||||||
|
|
||||||
|
saldo.write();
|
||||||
|
//saldo.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TTest::main_loop()
|
||||||
|
{
|
||||||
|
test_analisi(); //Esegue il test delle funzioni e degli oggetti per l'analisi
|
||||||
|
//test_saldi(); //Esegue il test delle funzioni e degli oggetti per l'analisi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ab3100(int argc, char **argv)
|
void ab3100(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
481
ab/ablib01.cpp
481
ab/ablib01.cpp
@ -5,9 +5,8 @@
|
|||||||
#define NODO_MODIFICATO "M"
|
#define NODO_MODIFICATO "M"
|
||||||
#define NODO_RIMOSSO "R"
|
#define NODO_RIMOSSO "R"
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
// TAnalisi_bil
|
// TAlbero_AB
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
|
|
||||||
TAlbero_AB::TAlbero_AB(int filenum)
|
TAlbero_AB::TAlbero_AB(int filenum)
|
||||||
@ -22,6 +21,10 @@ int TAlbero_AB::write(TBaseisamfile &analisi) const
|
|||||||
{
|
{
|
||||||
commit_body();
|
commit_body();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = rewrite(analisi);
|
||||||
|
}
|
||||||
if (err)
|
if (err)
|
||||||
CHECK (FALSE,"Errore di scrittura del record sull'isamfile");
|
CHECK (FALSE,"Errore di scrittura del record sull'isamfile");
|
||||||
return err;
|
return err;
|
||||||
@ -40,9 +43,9 @@ int TAlbero_AB::rewrite(TBaseisamfile &analisi) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Leggo la "testata" del record
|
//Leggo la "testata" del record
|
||||||
int TAlbero_AB::read(TBaseisamfile& analisi, word isop, word lockop)
|
int TAlbero_AB::read(TBaseisamfile& saldi, word isop, word lockop)
|
||||||
{
|
{
|
||||||
int err=TRectype::read(analisi, isop, lockop);
|
int err=TRectype::read(saldi, isop, lockop);
|
||||||
if (err==NOERR)
|
if (err==NOERR)
|
||||||
read_body(FALSE);
|
read_body(FALSE);
|
||||||
return err;
|
return err;
|
||||||
@ -60,23 +63,23 @@ int TAlbero_AB::readat(TBaseisamfile& analisi, TRecnotype nrec, word lockop)
|
|||||||
|
|
||||||
int TAlbero_AB::remove(TBaseisamfile& f) const
|
int TAlbero_AB::remove(TBaseisamfile& f) const
|
||||||
{
|
{
|
||||||
/*Abilitare questa parte solo per effettuare un debug della delete_node
|
//*Abilitare questa parte solo per effettuare un debug della delete_node
|
||||||
// anche se messa in questa posizione, la chiamata non ha senso
|
// anche se messa in questa posizione, la chiamata non ha senso
|
||||||
TLocalisamfile lf(LF_RELANA);
|
// TLocalisamfile lf(LF_RELANA);
|
||||||
TNumeric_id id;
|
TNumeric_id id;
|
||||||
id = 17;
|
id = 17;
|
||||||
_inter_tree->delete_node(id);
|
_inter_tree->delete_node(id);
|
||||||
int errc = commit_body(lf);
|
int errc = commit_body();
|
||||||
if (errc != NOERR)
|
if (errc != NOERR)
|
||||||
{
|
{
|
||||||
message_box("Errore nell'aggiornameno del file dati");
|
message_box("Errore nell'aggiornameno del file dati");
|
||||||
//return errc;
|
//return errc;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//*Abilitare solo questa parte per il test della remove_tree
|
|
||||||
|
/*Abilitare solo questa parte per il test della remove_tree
|
||||||
_inter_tree->delete_tree();
|
_inter_tree->delete_tree();
|
||||||
int errc = commit_body();
|
int errc = commit_body();
|
||||||
if (errc != NOERR)
|
if (errc != NOERR)
|
||||||
@ -85,7 +88,7 @@ int TAlbero_AB::remove(TBaseisamfile& f) const
|
|||||||
//return errc;
|
//return errc;
|
||||||
}
|
}
|
||||||
int err = TRectype::remove(f);
|
int err = TRectype::remove(f);
|
||||||
return err;
|
return err; */
|
||||||
}
|
}
|
||||||
|
|
||||||
void TAlbero_AB::zero()
|
void TAlbero_AB::zero()
|
||||||
@ -95,6 +98,148 @@ void TAlbero_AB::zero()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************************************/
|
||||||
|
// TABsaldo
|
||||||
|
/**************************************************************************************************/
|
||||||
|
TABsaldo::TABsaldo()
|
||||||
|
:TAlbero_AB(LF_ABSALDI)
|
||||||
|
{
|
||||||
|
_saldi = new TLocalisamfile(LF_ABSALDI);
|
||||||
|
_movdett = new TLocalisamfile(LF_MOVDETT);
|
||||||
|
// _relaz = NULL;
|
||||||
|
// _ana = NULL;
|
||||||
|
_inter_tree = new TLocal_balance3();
|
||||||
|
_newrec = new TRectype(LF_MOVDETT);
|
||||||
|
}
|
||||||
|
|
||||||
|
TABsaldo::~TABsaldo()
|
||||||
|
{
|
||||||
|
delete _saldi;
|
||||||
|
delete _movdett;
|
||||||
|
delete _inter_tree;
|
||||||
|
delete _newrec;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TABsaldo::put_headkey(TRectype &rec) const
|
||||||
|
{
|
||||||
|
rec.put(ABMD_CODDITTA, get(ABS_CODDITTA));
|
||||||
|
rec.put(ABMD_ANNO, get(ABS_ANNO));
|
||||||
|
rec.put(ABMD_CODPDB, get(ABS_CODPDB));
|
||||||
|
rec.put(ABMD_TIPOBIL, get(ABS_TIPOBIL));
|
||||||
|
rec.put(ABMD_CODCBL, get(ABS_CODCBL));
|
||||||
|
}
|
||||||
|
|
||||||
|
int TABsaldo::commit_body() const
|
||||||
|
{
|
||||||
|
_inter_tree->write_cache();
|
||||||
|
TRectype rec(_inter_tree->current().num());
|
||||||
|
TLocalisamfile filebody(rec.num());
|
||||||
|
TString status;
|
||||||
|
//Estraggo un nodo per volta basandomi sull'assoc_array degli status
|
||||||
|
while (_inter_tree->dirty_nodes() > 0)
|
||||||
|
{
|
||||||
|
TNumeric_id id;
|
||||||
|
//int prova = _inter_tree->dirty_nodes(); //solo debug
|
||||||
|
|
||||||
|
id=ID_NULLO;
|
||||||
|
rec= _inter_tree->extract_dirtynode(id, status);
|
||||||
|
put_headkey(rec);
|
||||||
|
|
||||||
|
//Ho un rectype e uno status node
|
||||||
|
if (status == NODO_AGGIUNTO)
|
||||||
|
{
|
||||||
|
if (filebody.curr().empty())
|
||||||
|
{ //Se il cursor di relana è posizionato in modo errato:
|
||||||
|
//lo sistemo sull'ultimo record del file
|
||||||
|
//DOMANDA: - Perchè ???
|
||||||
|
//TENATATIVO DI RISPOSTA: - Quando l'ultima azione effettuata (prima di questa "aggiunta") è la rimozione
|
||||||
|
// dell'ultimo record probabilmente (ma non sono sicuro) il cursore non è posizionato (o forse
|
||||||
|
// è posizionato in modo errato come ad es. dopo l'EOF, visto che l'EOF era sull'ultimo record rimosso)
|
||||||
|
// e quando eseguo un tentativo di scrittura da un errore di chiave duplicata (anche se questa non esiste);
|
||||||
|
// In tutti gli altri casi (quando l'ultima azione è stata una write o una rewrite o una remove di un record
|
||||||
|
// che non sia l'ultimo) questo problema non esiste.
|
||||||
|
//RISPOSTA ESATTA: - Bho !!!
|
||||||
|
filebody.last();
|
||||||
|
}
|
||||||
|
int err = filebody.write(rec);
|
||||||
|
if (err != NOERR)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (status == NODO_MODIFICATO)
|
||||||
|
{
|
||||||
|
int err = filebody.rewrite(rec);
|
||||||
|
if (err != NOERR)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (status == NODO_RIMOSSO)
|
||||||
|
{
|
||||||
|
filebody.read(rec); //Devo leggere sul file per posizionare il cursore: stesso motivo di prima
|
||||||
|
int err = filebody.remove(rec);
|
||||||
|
if (err != NOERR)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
// In tutti gli altri casi il nodo non viene modificato
|
||||||
|
}
|
||||||
|
return NOERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Leggo il "corpo" del record
|
||||||
|
int TABsaldo::read_body(bool lockstruct)
|
||||||
|
{
|
||||||
|
//_ana = new TAlbero_relana(get(ABAN_CODAN));
|
||||||
|
TString codditta = get(ABS_CODDITTA);
|
||||||
|
TToken_string key = codditta.right_just(5,'0');
|
||||||
|
key.add(get(ABS_ANNO));
|
||||||
|
key.add(get(ABS_CODPDB));
|
||||||
|
key.add(get(ABS_TIPOBIL));
|
||||||
|
key.add(get(ABS_CODCBL));
|
||||||
|
_mov = new TAlbero_movdett(key);
|
||||||
|
|
||||||
|
if (_mov->goto_root())
|
||||||
|
{
|
||||||
|
//TNumeric_id id_movdett;
|
||||||
|
//id_movdett = _mov->curr().get_real(ABMD_ID);
|
||||||
|
naviga_movdett();
|
||||||
|
}
|
||||||
|
//_inter_tree->write_cache(); //solo per debug
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Naviga l'albero dei movimenti-dettagli
|
||||||
|
void TABsaldo::naviga_movdett()
|
||||||
|
{
|
||||||
|
TNodeId key_rel;
|
||||||
|
_mov->curr_id(key_rel);
|
||||||
|
TNumeric_id lbrother_id, pather_id, my_id;
|
||||||
|
TRectype new_node(LF_MOVDETT);
|
||||||
|
|
||||||
|
my_id = _mov->curr().get_real(ABMD_ID);
|
||||||
|
pather_id = _mov->curr().get_real(ABMD_IDPADRE);
|
||||||
|
lbrother_id = _mov->curr().get_real(ABMD_IDPREC);
|
||||||
|
new_node = _mov->curr();
|
||||||
|
_inter_tree->insert_node(new_node,lbrother_id,pather_id,my_id);
|
||||||
|
|
||||||
|
if (_mov->has_rbrother())
|
||||||
|
{
|
||||||
|
if (_mov->goto_rbrother())
|
||||||
|
{ //Fratello di movdett trovato
|
||||||
|
naviga_movdett();
|
||||||
|
_mov->goto_node(key_rel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_mov->has_son())
|
||||||
|
{
|
||||||
|
if (_mov->goto_firstson())
|
||||||
|
{ //Fratello di movdett trovato
|
||||||
|
naviga_movdett();
|
||||||
|
_mov->goto_node(key_rel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
// TAnalisi_bil
|
// TAnalisi_bil
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
@ -137,7 +282,7 @@ int TAlbero_AB::commit_body() const
|
|||||||
while (_inter_tree->dirty_nodes() > 0)
|
while (_inter_tree->dirty_nodes() > 0)
|
||||||
{
|
{
|
||||||
TNumeric_id id;
|
TNumeric_id id;
|
||||||
int prova = _inter_tree->dirty_nodes();
|
// int prova = _inter_tree->dirty_nodes(); solo debug
|
||||||
|
|
||||||
id=ID_NULLO;
|
id=ID_NULLO;
|
||||||
rec= _inter_tree->extract_dirtynode(id, status);
|
rec= _inter_tree->extract_dirtynode(id, status);
|
||||||
@ -212,6 +357,7 @@ int TAnalisi_bil::read_body(bool lock_struct )
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Naviga l'albero delle relazioni
|
//Naviga l'albero delle relazioni
|
||||||
void TAnalisi_bil::naviga_relazioni(const TNumeric_id & begin_relana, const TNumeric_id & id_prec,const TNumeric_id & id_padre)
|
void TAnalisi_bil::naviga_relazioni(const TNumeric_id & begin_relana, const TNumeric_id & id_prec,const TNumeric_id & id_padre)
|
||||||
{
|
{
|
||||||
@ -345,8 +491,9 @@ bool TAnalisi_bil::TArray_fratelli::used(TObject *o)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
// TAlbero_locale
|
// TLocal_relana3 & TLocal_balance3
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
|
|
||||||
TLocal_relana3::TLocal_relana3() :
|
TLocal_relana3::TLocal_relana3() :
|
||||||
TAlbero_locale(LF_RELANA)
|
TAlbero_locale(LF_RELANA)
|
||||||
{
|
{
|
||||||
@ -364,26 +511,29 @@ TLocal_balance3::~TLocal_balance3()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************************************/
|
||||||
|
// TAlbero_locale
|
||||||
|
/**************************************************************************************************/
|
||||||
TAlbero_locale::TAlbero_locale(int filenum)
|
TAlbero_locale::TAlbero_locale(int filenum)
|
||||||
{
|
{
|
||||||
// versione definitiva:
|
// versione definitiva:
|
||||||
// _currnode = new TRectype(filenum);
|
// _currnode = new TRectype(filenum);
|
||||||
// _local_cahe = new TRWrecord_cache(new TIsamtempfile(filenum,"",TRUE,TRUE));
|
// _local_cache = new TRWrecord_cache(new TIsamtempfile(filenum,"",TRUE,TRUE));
|
||||||
|
|
||||||
// debug mods:
|
// debug mods:
|
||||||
_currnode = new TRectype(filenum);
|
_currnode = new TRectype(filenum);
|
||||||
if (filenum==LF_RELANA)
|
if (filenum==LF_RELANA)
|
||||||
_f= new TIsamtempfile(filenum,"/com/relana",FALSE,FALSE);
|
_f= new TIsamtempfile(filenum,"/com/relana",FALSE,FALSE);
|
||||||
else
|
else
|
||||||
_f= new TIsamtempfile(filenum,"",FALSE,FALSE);
|
_f= new TIsamtempfile(filenum,"/com/movdett",FALSE,FALSE);
|
||||||
_local_cahe = new TRWrecord_cache(_f);
|
_local_cache = new TRWrecord_cache(_f);
|
||||||
|
|
||||||
//zero(); // resetta l'albero locale
|
//zero(); // resetta l'albero locale
|
||||||
}
|
}
|
||||||
|
|
||||||
TAlbero_locale::~TAlbero_locale()
|
TAlbero_locale::~TAlbero_locale()
|
||||||
{
|
{
|
||||||
delete _local_cahe;
|
delete _local_cache;
|
||||||
delete _f;
|
delete _f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,12 +568,12 @@ TRectype TAlbero_locale::extract_dirtynode(TNumeric_id &id, TString &status)
|
|||||||
if (status != NODO_RIMOSSO)
|
if (status != NODO_RIMOSSO)
|
||||||
{
|
{
|
||||||
key.add(id.string()); //La chiave è completamente ricostruita per la ricerca sulla cache
|
key.add(id.string()); //La chiave è completamente ricostruita per la ricerca sulla cache
|
||||||
rec = _local_cahe->get(key); //passo la chiave (formata da codtab e id) e ritorna il rectype
|
rec = _local_cache->get(key); //passo la chiave (formata da codtab e id) e ritorna il rectype
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ //Riempio manualmente il record che deve essere rimosso: inserisco solo la chiave
|
{ //Riempio manualmente il record che deve essere rimosso: inserisco solo la chiave
|
||||||
//rec.put(ABRA_CODAN, ??? );
|
//rec.put(ABRA_CODAN, ??? );
|
||||||
rec.put(ABRA_ID,id.string());
|
rec.put(id_fieldname(),id.string());
|
||||||
}
|
}
|
||||||
//A questo punto il record è completo e so già quale operazione devo compierci sopra
|
//A questo punto il record è completo e so già quale operazione devo compierci sopra
|
||||||
|
|
||||||
@ -503,9 +653,9 @@ bool TAlbero_locale::insert_node(TRectype & node,const TNumeric_id id_prec, cons
|
|||||||
if (id_prec != ID_NULLO)
|
if (id_prec != ID_NULLO)
|
||||||
{ //Aggiorno il successivo del mio precedente dicendogli che il suo successivo sono io
|
{ //Aggiorno il successivo del mio precedente dicendogli che il suo successivo sono io
|
||||||
key.add(id_prec.string());
|
key.add(id_prec.string());
|
||||||
parente = _local_cahe->get(key);
|
parente = _local_cache->get(key);
|
||||||
parente.put(ABRA_IDSUCC,id.string());
|
parente.put(idsucc_fieldname(),id.string());
|
||||||
_local_cahe->put(parente);
|
_local_cache->put(parente);
|
||||||
set_status_node(id_prec,NODO_MODIFICATO); //Setto l'eventuale flag di array modificato per il fratello
|
set_status_node(id_prec,NODO_MODIFICATO); //Setto l'eventuale flag di array modificato per il fratello
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -513,19 +663,21 @@ bool TAlbero_locale::insert_node(TRectype & node,const TNumeric_id id_prec, cons
|
|||||||
if (id_padre != ID_NULLO)
|
if (id_padre != ID_NULLO)
|
||||||
{ //Sono un primo figlio: rintraccio mio padre e gli dico che il suo primo figlio ora, sono io
|
{ //Sono un primo figlio: rintraccio mio padre e gli dico che il suo primo figlio ora, sono io
|
||||||
key.add(id_padre.string());
|
key.add(id_padre.string());
|
||||||
parente = _local_cahe->get(key);
|
parente = _local_cache->get(key);
|
||||||
parente.put(ABRA_IDFIGLIO,id.string());
|
parente.put(idson_fieldname(),id.string());
|
||||||
_local_cahe->put(parente);
|
_local_cache->put(parente);
|
||||||
set_status_node(id_padre,NODO_MODIFICATO); //Setto l'eventuale flag di array modificato per il padre
|
set_status_node(id_padre,NODO_MODIFICATO); //Setto l'eventuale flag di array modificato per il padre
|
||||||
} // Sono una radice principale e quindi sono orfana di padre
|
} // Sono una radice principale e quindi sono orfana di padre
|
||||||
}
|
}
|
||||||
|
|
||||||
//Ora aggiorno me stesso
|
//Ora aggiorno me stesso
|
||||||
node.put(ABRA_IDPREC,id_prec.string());
|
madekey(node);
|
||||||
node.put(ABRA_IDPADRE,id_padre.string());
|
// node.put(ABRA_CODAN,get_headkey()); //Eseguo un combio della chiave: non serve avere il codice della tabella nella cache
|
||||||
node.put(ABRA_IDSUCC,id_succ.string());
|
node.put(idprec_fieldname(),id_prec.string());
|
||||||
node.put(ABRA_IDFIGLIO,ID_NULLO);
|
node.put(idfather_fieldname(),id_padre.string());
|
||||||
_local_cahe->put(node);
|
node.put(idsucc_fieldname(),id_succ.string());
|
||||||
|
node.put(idson_fieldname(),ID_NULLO);
|
||||||
|
_local_cache->put(node);
|
||||||
//set_current(node);
|
//set_current(node);
|
||||||
goto_node(node);
|
goto_node(node);
|
||||||
set_status_node(id,NODO_MODIFICATO);
|
set_status_node(id,NODO_MODIFICATO);
|
||||||
@ -541,23 +693,25 @@ bool TAlbero_locale::delete_node(const TNumeric_id &id)
|
|||||||
TNumeric_id id_padre, id_figlio, id_prec, id_succ;
|
TNumeric_id id_padre, id_figlio, id_prec, id_succ;
|
||||||
|
|
||||||
goto_node(id);
|
goto_node(id);
|
||||||
TToken_string key = get_headkey();
|
TToken_string key;
|
||||||
|
|
||||||
// id = _currnode->get_real(ABRA_ID);
|
// id = _currnode->get_real(ABRA_ID);
|
||||||
id_padre = _currnode->get_real(ABRA_IDPADRE);
|
id_padre = _currnode->get_real(idfather_fieldname());
|
||||||
id_figlio = _currnode->get_real(ABRA_IDFIGLIO);
|
id_figlio = _currnode->get_real(idson_fieldname());
|
||||||
id_prec = _currnode->get_real(ABRA_IDPREC);
|
id_prec = _currnode->get_real(idprec_fieldname());
|
||||||
id_succ = _currnode->get_real(ABRA_IDSUCC);
|
id_succ = _currnode->get_real(idsucc_fieldname());
|
||||||
|
|
||||||
//Ricerco il padre per modificare il suo primo figlio, solo se io sono il suo primo figlio
|
//Ricerco il padre per modificare il suo primo figlio, solo se io sono il suo primo figlio
|
||||||
if (id_padre != ID_NULLO)
|
if (id_padre != ID_NULLO)
|
||||||
{
|
{
|
||||||
key.add(id_padre.string(),1);
|
key.cut(0);
|
||||||
parente=_local_cahe->get(key); //padre
|
key = get_headkey();
|
||||||
if (parente.get(ABRA_IDFIGLIO) == id.string())
|
key.add(id_padre.string());
|
||||||
|
parente=_local_cache->get(key); //padre
|
||||||
|
if (parente.get(idson_fieldname()) == id.string())
|
||||||
{ //Il nodo che sta per essere rimosso è il primo figlio di un padre
|
{ //Il nodo che sta per essere rimosso è il primo figlio di un padre
|
||||||
parente.put(ABRA_IDFIGLIO,id_succ.string()); //Aggiorno il padre
|
parente.put(idson_fieldname(),id_succ.string()); //Aggiorno il padre
|
||||||
_local_cahe->put(parente);
|
_local_cache->put(parente);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,30 +719,36 @@ bool TAlbero_locale::delete_node(const TNumeric_id &id)
|
|||||||
//suo fratello successivo, e gli dico anche quale sarà il suo successivo
|
//suo fratello successivo, e gli dico anche quale sarà il suo successivo
|
||||||
if (id_prec != ID_NULLO)
|
if (id_prec != ID_NULLO)
|
||||||
{
|
{
|
||||||
key.add(id_prec.string(),1);
|
key.cut(0);
|
||||||
parente=_local_cahe->get(key); //fratello sinistro
|
key = get_headkey();
|
||||||
parente.put(ABRA_IDSUCC,id_succ.string()); //Assegno al mio fratello sinistro il mio fratello destro
|
key.add(id_prec.string());
|
||||||
_local_cahe->put(parente);
|
parente=_local_cache->get(key); //fratello sinistro
|
||||||
|
parente.put(idsucc_fieldname(),id_succ.string()); //Assegno al mio fratello sinistro il mio fratello destro
|
||||||
|
_local_cache->put(parente);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dico a mio fratello successivo chi il suo precedente non sono più io,
|
//Dico a mio fratello successivo chi il suo precedente non sono più io,
|
||||||
//e gli dico che il suo precedente è il MIO precedente
|
//e gli dico che il suo precedente è il MIO precedente
|
||||||
if (id_succ != ID_NULLO)
|
if (id_succ != ID_NULLO)
|
||||||
{
|
{
|
||||||
key.add(id_succ.string(),1);
|
key.cut(0);
|
||||||
parente=_local_cahe->get(key); //fratello destro
|
key = get_headkey();
|
||||||
parente.put(ABRA_IDPREC,id_prec.string()); //Assegno al mio fratello destro il mio fratello sinistro
|
key.add(id_succ.string());
|
||||||
_local_cahe->put(parente);
|
parente=_local_cache->get(key); //fratello destro
|
||||||
|
parente.put(idprec_fieldname(),id_prec.string()); //Assegno al mio fratello destro il mio fratello sinistro
|
||||||
|
_local_cache->put(parente);
|
||||||
}
|
}
|
||||||
|
|
||||||
//I miei vicini mi hanno già escluso: non sono più raggiungibile
|
//I miei vicini mi hanno già escluso: non sono più raggiungibile
|
||||||
//Ricostruisco la chiave
|
//Ricostruisco la chiave
|
||||||
//Elimino i miei link dai fratelli
|
//Elimino i miei link dai fratelli
|
||||||
key.add(id.string(),1);
|
key.cut(0);
|
||||||
|
key = get_headkey();
|
||||||
|
key.add(id.string());
|
||||||
//node.put(ABRA_IDPADRE,ID_NULLO);
|
//node.put(ABRA_IDPADRE,ID_NULLO);
|
||||||
_currnode->put(ABRA_IDPREC,ID_NULLO);
|
_currnode->put(idprec_fieldname(),ID_NULLO);
|
||||||
_currnode->put(ABRA_IDSUCC,ID_NULLO);
|
_currnode->put(idsucc_fieldname(),ID_NULLO);
|
||||||
_local_cahe->put(*_currnode);
|
_local_cache->put(*_currnode);
|
||||||
//Elimino i miei figli
|
//Elimino i miei figli
|
||||||
|
|
||||||
TNumeric_id nextnode_id;
|
TNumeric_id nextnode_id;
|
||||||
@ -624,11 +784,12 @@ void TAlbero_locale::zero()
|
|||||||
{
|
{
|
||||||
delete_tree(); // cancella l'albero
|
delete_tree(); // cancella l'albero
|
||||||
_status_node.destroy();
|
_status_node.destroy();
|
||||||
_currnode->put(ABRA_ID,ID_NULLO);
|
_currnode->put(id_fieldname(),ID_NULLO);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAlbero_locale::delete_tree()
|
bool TAlbero_locale::delete_tree()
|
||||||
{
|
{
|
||||||
|
//write_cache();
|
||||||
goto_root();
|
goto_root();
|
||||||
remove_subtree(ID_NULLO); //Non eliminando il link coi fratelli della radice, remove_subtree naviga tutto l'albero
|
remove_subtree(ID_NULLO); //Non eliminando il link coi fratelli della radice, remove_subtree naviga tutto l'albero
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -641,7 +802,7 @@ bool TAlbero_locale::remove_subtree(const TNumeric_id return_id)
|
|||||||
//cerco il figlio
|
//cerco il figlio
|
||||||
if (has_son())
|
if (has_son())
|
||||||
{
|
{
|
||||||
myself_id = _currnode->get_real(ABRA_ID);
|
myself_id = _currnode->get_real(id_fieldname());
|
||||||
goto_firstson();
|
goto_firstson();
|
||||||
remove_subtree(myself_id);
|
remove_subtree(myself_id);
|
||||||
}
|
}
|
||||||
@ -649,11 +810,11 @@ bool TAlbero_locale::remove_subtree(const TNumeric_id return_id)
|
|||||||
//cerco il fratello
|
//cerco il fratello
|
||||||
if (has_rbrother())
|
if (has_rbrother())
|
||||||
{
|
{
|
||||||
myself_id = _currnode->get_real(ABRA_ID);
|
myself_id = _currnode->get_real(id_fieldname());
|
||||||
goto_rbrother();
|
goto_rbrother();
|
||||||
remove_subtree(myself_id);
|
remove_subtree(myself_id);
|
||||||
}
|
}
|
||||||
TNumeric_id id = _currnode->get(ABRA_ID);
|
TNumeric_id id = _currnode->get(id_fieldname());
|
||||||
|
|
||||||
//Questa parte esegue la gestione dell'assoc_array degli stati
|
//Questa parte esegue la gestione dell'assoc_array degli stati
|
||||||
//in modo tale da mantenerlo allineato con il contenuto della cache
|
//in modo tale da mantenerlo allineato con il contenuto della cache
|
||||||
@ -679,30 +840,30 @@ bool TAlbero_locale::remove_subtree(const TNumeric_id return_id)
|
|||||||
if (return_id != ID_NULLO)
|
if (return_id != ID_NULLO)
|
||||||
goto_node(return_id);
|
goto_node(return_id);
|
||||||
else
|
else
|
||||||
_currnode->put(ABRA_ID,ID_NULLO);
|
_currnode->put(id_fieldname(),ID_NULLO);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAlbero_locale::has_son()
|
bool TAlbero_locale::has_son()
|
||||||
{
|
{
|
||||||
return (_currnode->get_real(ABRA_IDFIGLIO) != ID_NULLO);
|
return (_currnode->get_real(idson_fieldname()) != ID_NULLO);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAlbero_locale::goto_firstson()
|
bool TAlbero_locale::goto_firstson()
|
||||||
{
|
{
|
||||||
goto_node(_currnode->get_real(ABRA_IDFIGLIO));
|
goto_node(_currnode->get_real(idson_fieldname()));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAlbero_locale::has_rbrother()
|
bool TAlbero_locale::has_rbrother()
|
||||||
{
|
{
|
||||||
return (_currnode->get_real(ABRA_IDSUCC) != ID_NULLO);
|
return (_currnode->get_real(idsucc_fieldname()) != ID_NULLO);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAlbero_locale::goto_rbrother()
|
bool TAlbero_locale::goto_rbrother()
|
||||||
{
|
{
|
||||||
goto_node(_currnode->get_real(ABRA_IDSUCC));
|
goto_node(_currnode->get_real(idsucc_fieldname()));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,20 +874,26 @@ bool TAlbero_locale::goto_root()
|
|||||||
TToken_string key;
|
TToken_string key;
|
||||||
TNumeric_id id_prec, id_padre;
|
TNumeric_id id_prec, id_padre;
|
||||||
key=get_headkey();
|
key=get_headkey();
|
||||||
key.add(_currnode->get(ABRA_ID));
|
key.add(_currnode->get(id_fieldname()));
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*_currnode = _local_cahe->get(key);
|
*_currnode = _local_cache->get(key);
|
||||||
id_prec = _currnode->get_real(ABRA_IDPREC);
|
id_prec = _currnode->get_real(idprec_fieldname());
|
||||||
id_padre = _currnode->get_real(ABRA_IDPADRE);
|
id_padre = _currnode->get_real(idfather_fieldname());
|
||||||
if (id_prec != ID_NULLO)
|
if (id_prec != ID_NULLO)
|
||||||
{
|
{
|
||||||
key.add(id_prec.string(),1);
|
key.cut(0);
|
||||||
|
key=get_headkey();
|
||||||
|
key.add(id_prec.string());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (id_padre != ID_NULLO)
|
if (id_padre != ID_NULLO)
|
||||||
key.add(id_padre.string(),1);
|
{
|
||||||
|
key.cut(0);
|
||||||
|
key=get_headkey();
|
||||||
|
key.add(id_padre.string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (id_prec != ID_NULLO || id_padre != ID_NULLO);
|
} while (id_prec != ID_NULLO || id_padre != ID_NULLO);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -737,7 +904,7 @@ void TAlbero_locale::goto_node(const TNumeric_id id)
|
|||||||
TToken_string key;
|
TToken_string key;
|
||||||
key=get_headkey();
|
key=get_headkey();
|
||||||
key.add(id.string());
|
key.add(id.string());
|
||||||
*_currnode = _local_cahe->get(key);
|
*_currnode = _local_cache->get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1066,3 +1233,183 @@ void TAlbero_relvoci::node2id(const TObject * node,TNodeId & id) const
|
|||||||
{
|
{
|
||||||
id.format("%ld",_relvoci->recno());
|
id.format("%ld",_relvoci->recno());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************************/
|
||||||
|
// TAlbero_movdett
|
||||||
|
/**************************************************************************************************/
|
||||||
|
TAlbero_movdett::TAlbero_movdett( const char * tabcode)
|
||||||
|
{
|
||||||
|
_codtab=tabcode;
|
||||||
|
_movdett=new TLocalisamfile(LF_MOVDETT);
|
||||||
|
|
||||||
|
/* _relana->put(ABRA_CODAN,_codtab);
|
||||||
|
_relana->put(ABRA_ID,MAX_ID_REL);
|
||||||
|
|
||||||
|
//Trova l'ultimo id usato in relana: DA COMPLETARE !!!
|
||||||
|
int err = _relana->read(_isgteq); //Codifica errori in TIsamerr
|
||||||
|
if (err == NOERR)
|
||||||
|
{ // Ho trovato il primo della tabella successiva: leggendo il precedente
|
||||||
|
// ho l'ultimo record dalla tabella cercata
|
||||||
|
_relana->prev();
|
||||||
|
if (_relana->get(ABRA_CODAN) != _codtab)
|
||||||
|
{ // Non esiste la tabella
|
||||||
|
; //_last_id viene lasciato a 0
|
||||||
|
}
|
||||||
|
_last_id = _relana->get_real(ABRA_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err == _isemptyfile)
|
||||||
|
{ //Il file è vuoto
|
||||||
|
;//_last_id viene lasciato a 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err == _iseof)
|
||||||
|
{ // La tabella successiva non esiste: provo a leggere l'ultimo record
|
||||||
|
_relana->last();
|
||||||
|
if (_relana->get(ABRA_CODAN) != _codtab)
|
||||||
|
{ //Tabella non trovata
|
||||||
|
; //_last_id viene lasciato a 0
|
||||||
|
}
|
||||||
|
//Tabella trovata: prendo l'id dell'ultimo record
|
||||||
|
_last_id = _relana->get_real(ABRA_ID);
|
||||||
|
} */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Posiziona relana sul record voluto
|
||||||
|
bool TAlbero_movdett::goto_id(const TNumeric_id &id)
|
||||||
|
{
|
||||||
|
_movdett->put(ABMD_CODDITTA,_codtab);
|
||||||
|
_movdett->put(ABMD_ID,id);
|
||||||
|
if (_movdett->read() == NOERR)
|
||||||
|
return TRUE;
|
||||||
|
return FALSE; //Non sono riuscito a posizionarmi sul nodo
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ricerca la radice di relana
|
||||||
|
bool TAlbero_movdett::goto_root()
|
||||||
|
{
|
||||||
|
_movdett->put(ABMD_CODDITTA,_codtab.get(0));
|
||||||
|
_movdett->put(ABMD_ANNO,_codtab.get(1));
|
||||||
|
_movdett->put(ABMD_CODPDB,_codtab.get(2));
|
||||||
|
_movdett->put(ABMD_TIPOBIL,_codtab.get(3));
|
||||||
|
_movdett->put(ABMD_CODCBL,_codtab.get(4));
|
||||||
|
//No so nulla sull'id
|
||||||
|
_movdett->read(_isgteq); //Leggo la prima chiave che si avvicina a quella specificata
|
||||||
|
TString fctrl = _movdett->get(ABMD_CODDITTA);
|
||||||
|
TToken_string controllo = fctrl.right_just(5,'0');
|
||||||
|
controllo.add(_movdett->get(ABMD_ANNO));
|
||||||
|
controllo.add(_movdett->get(ABMD_CODPDB));
|
||||||
|
controllo.add(_movdett->get(ABMD_TIPOBIL));
|
||||||
|
controllo.add(_movdett->get(ABMD_CODCBL));
|
||||||
|
|
||||||
|
if (controllo == _codtab)
|
||||||
|
{
|
||||||
|
while (has_father())
|
||||||
|
{
|
||||||
|
goto_father();
|
||||||
|
} // Ho raggiunto il primo livello
|
||||||
|
while (has_lbrother())
|
||||||
|
{
|
||||||
|
goto_lbrother();
|
||||||
|
}// Ho raggiunto la radice
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
//Non ho trovato una voce con codice tabella richiesta
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Dice se un nodo di relana ha il primo figlio
|
||||||
|
bool TAlbero_movdett::has_son() const
|
||||||
|
{
|
||||||
|
return _movdett->get_real(ABMD_IDFIGLIO)!=ID_NULLO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ricerca il primo filglio di un nodo di relana
|
||||||
|
bool TAlbero_movdett::goto_firstson()
|
||||||
|
{
|
||||||
|
TNumeric_id id_figlio(_movdett->get_real(ABMD_IDFIGLIO));
|
||||||
|
if (id_figlio > 0)
|
||||||
|
{ //Ci deve essere un figlio: lo cerco
|
||||||
|
//Il CODAN deve rimanere uguale a quello del padre
|
||||||
|
_movdett->put(ABMD_ID,_movdett->get(ABMD_IDFIGLIO));
|
||||||
|
if (_movdett->read() == NOERR)
|
||||||
|
return TRUE; //Figlio trovato con successo
|
||||||
|
}
|
||||||
|
//Non c'è un figlio: non si dovrebbe mai verificare visto che
|
||||||
|
//si entra in questa funzione solo quando è previsto che ci sia un figlio.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Dice se un nodo di relana ha un fratello destro
|
||||||
|
bool TAlbero_movdett::has_rbrother() const
|
||||||
|
{
|
||||||
|
return _movdett->get_real(ABMD_IDSUCC) != ID_NULLO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ricerca il fratello destro di un nodo di relana
|
||||||
|
bool TAlbero_movdett::goto_rbrother()
|
||||||
|
{
|
||||||
|
TNumeric_id id_fratello(_movdett->get_real(ABMD_IDSUCC));
|
||||||
|
if (id_fratello > 0)
|
||||||
|
{ //Ci deve essere un fratello: lo cerco
|
||||||
|
//Il CODAN deve rimanere uguale a quello del fratello precedente
|
||||||
|
_movdett->put(ABMD_ID,_movdett->get(ABMD_IDSUCC));
|
||||||
|
if (_movdett->read() == NOERR)
|
||||||
|
return TRUE; //Fratello trovato con successo
|
||||||
|
}
|
||||||
|
//Non c'è un fratello: non si dovrebbe mai verificare visto che
|
||||||
|
//si entra in questa funzione solo quando è previsto che ci sia un fratello.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Dice se un nodo di relana ha un padre
|
||||||
|
bool TAlbero_movdett::has_father() const
|
||||||
|
{
|
||||||
|
return _movdett->get_real(ABMD_IDPADRE) != ID_NULLO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ricerca il padre del nodo di relana
|
||||||
|
bool TAlbero_movdett::goto_father()
|
||||||
|
{
|
||||||
|
_movdett->put(ABMD_ID,_movdett->get(ABMD_IDPADRE));
|
||||||
|
if (_movdett->read() != NOERR)
|
||||||
|
CHECK (FALSE,"ERRORE DI PADRE"); //*!*!*!*! DA gestire
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ritrona il nodo corrente di relana
|
||||||
|
TObject *TAlbero_movdett::curr_node() const
|
||||||
|
{
|
||||||
|
return &_movdett->curr();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Dice se un nodo di relana ha un fratello sinistro
|
||||||
|
bool TAlbero_movdett::has_lbrother() const
|
||||||
|
{
|
||||||
|
return _movdett->get_real(ABMD_IDPREC) != ID_NULLO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ricerca il fratello sinistro di un nodo di relana
|
||||||
|
bool TAlbero_movdett::goto_lbrother()
|
||||||
|
{
|
||||||
|
TNumeric_id id_fratello(_movdett->get_real(ABMD_IDPREC));
|
||||||
|
if (id_fratello > 0)
|
||||||
|
{//Ci deve essere un fratello: lo cerco
|
||||||
|
//Il CODAN deve rimanere uguale a quello del fratello successivo
|
||||||
|
_movdett->put(ABMD_ID,_movdett->get(ABMD_IDPREC));
|
||||||
|
if (_movdett->read() == NOERR)
|
||||||
|
return TRUE; //Fratello trovato con successo
|
||||||
|
}
|
||||||
|
//ERRORE !!!
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TAlbero_movdett::node2id(const TObject * node,TNodeId & id) const
|
||||||
|
{
|
||||||
|
id.format("%ld",_movdett->recno());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
102
ab/ablib01.h
102
ab/ablib01.h
@ -118,10 +118,60 @@ public:
|
|||||||
{}
|
{}
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
|
|
||||||
|
class TAlbero_movdett : public TAlbero_bidir
|
||||||
|
{
|
||||||
|
TToken_string _codtab;
|
||||||
|
TLocalisamfile *_movdett;
|
||||||
|
TNumeric_id _last_id;
|
||||||
|
protected:
|
||||||
|
virtual void node2id(const TObject * node,TNodeId & id) const;
|
||||||
|
public:
|
||||||
|
// @cmember Ritorna TRUE se riesce a trovare il primo figlio
|
||||||
|
virtual bool has_son() const;
|
||||||
|
// @cmember Ritorna TRUE se riesce a trovare il fratello destro
|
||||||
|
virtual bool has_rbrother() const;
|
||||||
|
// @cmember Ritorna TRUE se riesce a trovare il padre
|
||||||
|
virtual bool has_father() const;
|
||||||
|
// @cmember Ritorna TRUE se riesce a trovare il fratello sinistro
|
||||||
|
virtual bool has_lbrother() const;
|
||||||
|
// @cmember Si posiziona sulla radice principale
|
||||||
|
virtual bool goto_root();
|
||||||
|
// @cmember Si posiziona sul primo figlio
|
||||||
|
virtual bool goto_firstson();
|
||||||
|
// @cmember Si posiziona sul padre
|
||||||
|
virtual bool goto_father();
|
||||||
|
// @cmember Si posiziona sul fratello destro
|
||||||
|
virtual bool goto_rbrother();
|
||||||
|
// @cmember Si posiziona sul fratello sinistro
|
||||||
|
virtual bool goto_lbrother();
|
||||||
|
// @cmember Ritorna TRUE se può posizionarsi sul nodo indicato dall'id specificato
|
||||||
|
virtual bool goto_node(TNodeId & id)
|
||||||
|
{return(_movdett->readat(atol(id))==NOERR); }
|
||||||
|
// @cmember Si posiziona sul nodo specificato dall'id
|
||||||
|
bool goto_id(const TNumeric_id &id);
|
||||||
|
// @cmember Ritorna il nodo corrente
|
||||||
|
virtual TObject * curr_node() const;
|
||||||
|
// @cmember Ritorna il nodo corrente
|
||||||
|
TRectype & curr() {return (TRectype &)*curr_node();}
|
||||||
|
// @cmember Esegue un lock
|
||||||
|
// bool lock();
|
||||||
|
// @cmember Esegue un unlock
|
||||||
|
// void unlock();
|
||||||
|
// @cmember Inserisce un nodo nella struttura ad albero
|
||||||
|
//bool insert_node(real id);
|
||||||
|
// @cmember Restituisce un nuovo id (il primo disponibile)
|
||||||
|
TNumeric_id &new_id(real id);
|
||||||
|
// @cmember Costruttore
|
||||||
|
TAlbero_movdett( const char * tabcode);
|
||||||
|
// @cmember Distruttore
|
||||||
|
virtual ~TAlbero_movdett() {;}
|
||||||
|
};
|
||||||
|
|
||||||
//Classe per gestire l'albero di relana
|
//Classe per gestire l'albero di relana
|
||||||
class TAlbero_relana : public TAlbero_bidir
|
class TAlbero_relana : public TAlbero_bidir
|
||||||
{
|
{
|
||||||
TString16 _codtab;
|
TString _codtab;
|
||||||
TLocalisamfile *_relana;
|
TLocalisamfile *_relana;
|
||||||
TNumeric_id _last_id;
|
TNumeric_id _last_id;
|
||||||
protected:
|
protected:
|
||||||
@ -172,7 +222,7 @@ public:
|
|||||||
// basandosi sull'albero di relvoci
|
// basandosi sull'albero di relvoci
|
||||||
class TAlbero_relvoci : public TAlbero
|
class TAlbero_relvoci : public TAlbero
|
||||||
{
|
{
|
||||||
TString16 _codtab;
|
TString _codtab;
|
||||||
TLocalisamfile *_relvoci;
|
TLocalisamfile *_relvoci;
|
||||||
protected:
|
protected:
|
||||||
virtual void node2id(const TObject * node, TNodeId & id) const;
|
virtual void node2id(const TObject * node, TNodeId & id) const;
|
||||||
@ -210,10 +260,11 @@ public:
|
|||||||
// @cmember Distruttore
|
// @cmember Distruttore
|
||||||
virtual ~TAlbero_relvoci() ;
|
virtual ~TAlbero_relvoci() ;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Struttura da albero basata su un file temporaneo cached
|
// Struttura da albero basata su un file temporaneo cached
|
||||||
class TAlbero_locale : public TAlbero_bidir
|
class TAlbero_locale : public TAlbero_bidir
|
||||||
{
|
{
|
||||||
TRWrecord_cache * _local_cahe;
|
TRWrecord_cache * _local_cache;
|
||||||
|
|
||||||
TLocalisamfile *_f; // da rimuovere !!
|
TLocalisamfile *_f; // da rimuovere !!
|
||||||
|
|
||||||
@ -222,8 +273,6 @@ class TAlbero_locale : public TAlbero_bidir
|
|||||||
TAssoc_array _status_node;
|
TAssoc_array _status_node;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// debug
|
|
||||||
void write_cache() { _local_cahe->flush(); }
|
|
||||||
|
|
||||||
// @cmember Elimina il sottoalbero dei figli di un nodo
|
// @cmember Elimina il sottoalbero dei figli di un nodo
|
||||||
// @cmember che sta per essere eliminato da un struttura di tipo lista doppiamente lincata
|
// @cmember che sta per essere eliminato da un struttura di tipo lista doppiamente lincata
|
||||||
@ -234,13 +283,17 @@ protected:
|
|||||||
void goto_node(const TNumeric_id id);
|
void goto_node(const TNumeric_id id);
|
||||||
void goto_node(TRectype &node) {*_currnode = node;}
|
void goto_node(TRectype &node) {*_currnode = node;}
|
||||||
|
|
||||||
|
virtual void madekey(TRectype &) pure;
|
||||||
virtual const char * idfather_fieldname() pure ;
|
virtual const char * idfather_fieldname() pure ;
|
||||||
virtual const char * idson_fieldname() pure;
|
virtual const char * idson_fieldname() pure;
|
||||||
virtual const char * idsucc_fieldname() pure;
|
virtual const char * idsucc_fieldname() pure;
|
||||||
virtual const char * idprec_fieldname() pure;
|
virtual const char * idprec_fieldname() pure;
|
||||||
virtual const char * id_fieldname() pure;
|
virtual const char * id_fieldname() pure;
|
||||||
virtual const char * get_headkey();
|
virtual const char * get_headkey() pure; // {return " ";} //DA FARE
|
||||||
public:
|
public:
|
||||||
|
// debug
|
||||||
|
void write_cache() { _local_cache->flush(); }
|
||||||
|
|
||||||
// @cmember Inserisce un nodo in una struttura di tipo lista doppiamente lincata
|
// @cmember Inserisce un nodo in una struttura di tipo lista doppiamente lincata
|
||||||
bool insert_node(TRectype &node, const TNumeric_id id_prec, const TNumeric_id id_padre, TNumeric_id id);
|
bool insert_node(TRectype &node, const TNumeric_id id_prec, const TNumeric_id id_padre, TNumeric_id id);
|
||||||
// @cmember Elimina un nodo da una struttura di tipo lista doppiamente lincata
|
// @cmember Elimina un nodo da una struttura di tipo lista doppiamente lincata
|
||||||
@ -287,11 +340,12 @@ class TLocal_relana3 : public TAlbero_locale
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
virtual void madekey(TRectype & node) {node.put(ABRA_CODAN,get_headkey());}
|
||||||
virtual const char * idfather_fieldname() {return ABRA_IDPADRE;}
|
virtual const char * idfather_fieldname() {return ABRA_IDPADRE;}
|
||||||
virtual const char * idson_fieldname(){return ABRA_IDFIGLIO;}
|
virtual const char * idson_fieldname(){return ABRA_IDFIGLIO;}
|
||||||
virtual const char * idsucc_fieldname(){return ABRA_IDSUCC;}
|
virtual const char * idsucc_fieldname(){return ABRA_IDSUCC;}
|
||||||
virtual const char * idprec_fieldname(){return ABRA_IDPREC;}
|
virtual const char * idprec_fieldname(){return ABRA_IDPREC;}
|
||||||
virtual const char * id_fieldname(){return ABRA_IDPADRE;}
|
virtual const char * id_fieldname(){return ABRA_ID;}
|
||||||
virtual const char * get_headkey() {return " ";}
|
virtual const char * get_headkey() {return " ";}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -306,13 +360,20 @@ protected:
|
|||||||
class TLocal_balance3 : public TAlbero_locale
|
class TLocal_balance3 : public TAlbero_locale
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
virtual void madekey(TRectype & node)
|
||||||
|
{
|
||||||
|
node.put(ABMD_CODDITTA," ");
|
||||||
|
node.put(ABMD_ANNO," ");
|
||||||
|
node.put(ABMD_CODPDB," ");
|
||||||
|
node.put(ABMD_TIPOBIL," ");
|
||||||
|
node.put(ABMD_CODCBL," ");
|
||||||
|
}
|
||||||
virtual const char * idfather_fieldname() {return ABMD_IDPADRE;}
|
virtual const char * idfather_fieldname() {return ABMD_IDPADRE;}
|
||||||
virtual const char * idson_fieldname(){return ABMD_IDFIGLIO;}
|
virtual const char * idson_fieldname(){return ABMD_IDFIGLIO;}
|
||||||
virtual const char * idsucc_fieldname(){return ABMD_IDSUCC;}
|
virtual const char * idsucc_fieldname(){return ABMD_IDSUCC;}
|
||||||
virtual const char * idprec_fieldname(){return ABMD_IDPREC;}
|
virtual const char * idprec_fieldname(){return ABMD_IDPREC;}
|
||||||
virtual const char * id_fieldname(){return ABMD_IDPADRE;}
|
virtual const char * id_fieldname(){return ABMD_ID;}
|
||||||
virtual const char * get_headkey() {return " | | | ";}
|
virtual const char * get_headkey() {return " | | | | ";}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -329,14 +390,14 @@ class TAlbero_AB: public TRectype
|
|||||||
// @cmember Esegue la scrittura del body del record
|
// @cmember Esegue la scrittura del body del record
|
||||||
virtual int commit_body() const;
|
virtual int commit_body() const;
|
||||||
// @cmember Esegue la lettura del body del rocord
|
// @cmember Esegue la lettura del body del rocord
|
||||||
virtual int read_body(bool lockstruct);
|
virtual int read_body(bool lockstruct) {return 0;} //DA FARE
|
||||||
// @cmember Copia la chiave sul record dei nodi dell'albero
|
// @cmember Copia la chiave sul record dei nodi dell'albero
|
||||||
virtual void put_headkey(TRectype &rec) const;
|
virtual void put_headkey(TRectype &rec) const {;} //DA FARE
|
||||||
public:
|
public:
|
||||||
// @cmember Costruttore
|
// @cmember Costruttore
|
||||||
TAlbero_AB(int filenum);
|
TAlbero_AB(int filenum);
|
||||||
// #cmember Distruttore
|
// #cmember Distruttore
|
||||||
virtual ~TAlbero_AB() ;
|
virtual ~TAlbero_AB() {;} //DA FARE
|
||||||
// @cmember Esegue la lettura della testata di un record da LF_ANALISI e del suo "body"
|
// @cmember Esegue la lettura della testata di un record da LF_ANALISI e del suo "body"
|
||||||
virtual int read(TBaseisamfile& analisi, word isop=_isequal, word lockop=_nolock);
|
virtual int read(TBaseisamfile& analisi, word isop=_isequal, word lockop=_nolock);
|
||||||
// @cmember Esegue la lettura della testata di un record alla posizione nrec da LF_ANALISI e del suo "body"
|
// @cmember Esegue la lettura della testata di un record alla posizione nrec da LF_ANALISI e del suo "body"
|
||||||
@ -353,8 +414,6 @@ class TAlbero_AB: public TRectype
|
|||||||
{return _inter_tree;}
|
{return _inter_tree;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TAnalisi_bil: public TAlbero_AB
|
class TAnalisi_bil: public TAlbero_AB
|
||||||
{
|
{
|
||||||
class TArray_fratelli: public TAssoc_array
|
class TArray_fratelli: public TAssoc_array
|
||||||
@ -370,7 +429,7 @@ class TAnalisi_bil: public TAlbero_AB
|
|||||||
TLocalisamfile *_voci;
|
TLocalisamfile *_voci;
|
||||||
TAlbero_relvoci *_relaz;
|
TAlbero_relvoci *_relaz;
|
||||||
TAlbero_relana *_ana;
|
TAlbero_relana *_ana;
|
||||||
TLocal_relana3 *_inter_tree;
|
//TLocal_relana3 *_inter_tree;
|
||||||
TRectype * _newrec; //buffer per l'inserimento dodo per nodo
|
TRectype * _newrec; //buffer per l'inserimento dodo per nodo
|
||||||
protected:
|
protected:
|
||||||
// @cmember Esegue una navigazione dell'albero di rel_voci e di rel_ana
|
// @cmember Esegue una navigazione dell'albero di rel_voci e di rel_ana
|
||||||
@ -387,7 +446,7 @@ class TAnalisi_bil: public TAlbero_AB
|
|||||||
// @cmember Sblocca una tabella di analisi
|
// @cmember Sblocca una tabella di analisi
|
||||||
bool unlock_tabella();
|
bool unlock_tabella();
|
||||||
// @cmember Esegue la scrittura del body del record scrive il contenuto di una tabella di analisi
|
// @cmember Esegue la scrittura del body del record scrive il contenuto di una tabella di analisi
|
||||||
virtual int commit_body() const;
|
//virtual int commit_body() const;
|
||||||
// @cmember Esegue la lettura del body del rocord: legge il contenuto di una tabella di analisi
|
// @cmember Esegue la lettura del body del rocord: legge il contenuto di una tabella di analisi
|
||||||
virtual int read_body(bool lockstruct);
|
virtual int read_body(bool lockstruct);
|
||||||
// @cmember Copia la chiave sul record dei nodi dell'albero
|
// @cmember Copia la chiave sul record dei nodi dell'albero
|
||||||
@ -403,11 +462,12 @@ class TAnalisi_bil: public TAlbero_AB
|
|||||||
void set_type(const char * tipo) {put(ABAN_TIPOAN,tipo);}
|
void set_type(const char * tipo) {put(ABAN_TIPOAN,tipo);}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TABsaldo: public TRectype
|
class TABsaldo: public TAlbero_AB
|
||||||
{
|
{
|
||||||
TLocalisamfile *_saldi;
|
TLocalisamfile *_saldi;
|
||||||
TAlbero_relana *_movdett;
|
TAlbero_movdett *_mov;
|
||||||
TLocal_balance3 *_inter_tree;
|
TLocalisamfile *_movdett;
|
||||||
|
//TLocal_balance3 *_inter_tree;
|
||||||
TRectype * _newrec; //buffer per l'inserimento dodo per nodo
|
TRectype * _newrec; //buffer per l'inserimento dodo per nodo
|
||||||
protected:
|
protected:
|
||||||
// @cmember Esegue la scrittura del body del record scrive il contenuto di una tabella di analisi
|
// @cmember Esegue la scrittura del body del record scrive il contenuto di una tabella di analisi
|
||||||
@ -416,6 +476,8 @@ class TABsaldo: public TRectype
|
|||||||
virtual int read_body(bool lockstruct);
|
virtual int read_body(bool lockstruct);
|
||||||
// @cmember Copia la chiave sul record dei nodi dell'albero
|
// @cmember Copia la chiave sul record dei nodi dell'albero
|
||||||
virtual void put_headkey(TRectype &rec) const;
|
virtual void put_headkey(TRectype &rec) const;
|
||||||
|
//
|
||||||
|
void naviga_movdett();
|
||||||
public:
|
public:
|
||||||
// @cmember Costruttore
|
// @cmember Costruttore
|
||||||
TABsaldo();
|
TABsaldo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user