Aggiunto costruttore con puntatore a file a TRecord_cache e TFile_cache

git-svn-id: svn://10.65.10.50/trunk@5369 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
augusto 1997-10-14 15:26:48 +00:00
parent eefb4851ac
commit 8cd6b12aaa
2 changed files with 30 additions and 11 deletions

View File

@ -399,6 +399,13 @@ int TRecord_array::remove() const
// TFile_cache
///////////////////////////////////////////////////////////
TFile_cache::TFile_cache(TLocalisamfile *f , int key)
: _file(NULL), _key(key)
{
_code.format("%d", f->num());
init_file(f);
}
TFile_cache::TFile_cache(int num, int key)
: _file(NULL), _key(key)
{
@ -417,22 +424,28 @@ TFile_cache::~TFile_cache()
delete _file;
}
void TFile_cache::init_file()
void TFile_cache::init_file(TLocalisamfile* f)
{
CHECK(_file == NULL, "File already initialized");
int logicnum = atoi(_code);
if (logicnum == 0)
if (f==NULL)
{
_file = new TTable(_code);
logicnum = _file->num();
}
else
_file = new TLocalisamfile(logicnum);
int logicnum = atoi(_code);
if (logicnum == 0)
{
_file = new TTable(_code);
logicnum = _file->num();
}
else
{
_file = new TLocalisamfile(logicnum);
}
}
else
_file = f;
TDir dir;
dir.get(logicnum);
dir.get(_file->num());
// Se e' un file comune metti a -1, altrimenti alla ditta corrente
_last_firm = dir.is_com() ? -1 : prefix().get_codditta();
}
@ -571,6 +584,10 @@ const TString& TDecoder::decode(long code)
// TRecord_cache
///////////////////////////////////////////////////////////
TRecord_cache::TRecord_cache(TLocalisamfile *f, int key )
: TFile_cache(f, key)
{ }
TRecord_cache::TRecord_cache(int num, int key)
: TFile_cache(num, key)
{ }

View File

@ -155,7 +155,7 @@ protected:
TAssoc_array _cache;
protected:
void init_file();
void init_file(TLocalisamfile* f=NULL);
void test_firm();
const TObject& query(const char* chiave);
@ -170,6 +170,7 @@ public:
{return _cache.items();}
int fill();
TFile_cache(TLocalisamfile *f,int key = 1);
TFile_cache(int num, int key = 1);
TFile_cache(const char* table, int key = 1);
virtual ~TFile_cache();
@ -203,6 +204,7 @@ public:
virtual const TRectype& get(const char* chiave);
TRecord_cache(int num, int key = 1);
TRecord_cache(TLocalisamfile *f, int key = 1);
TRecord_cache(const char* table, int key = 1);
virtual ~TRecord_cache() { }
};