From 466c5c81c810d98261ea153f300ec1396e17da0b Mon Sep 17 00:00:00 2001 From: augusto Date: Tue, 14 Oct 1997 07:48:10 +0000 Subject: [PATCH] Aggiunto il metodo zap alle cache RW Aggiunto i costruttori basati su file* per le cache generiche e delle statistiche git-svn-id: svn://10.65.10.50/trunk@5359 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- sv/svlib01.cpp | 27 +++++++++++++++++++++++++-- sv/svlib01.h | 5 ++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/sv/svlib01.cpp b/sv/svlib01.cpp index cef56744c..83f18e7bf 100755 --- a/sv/svlib01.cpp +++ b/sv/svlib01.cpp @@ -729,6 +729,14 @@ THash_object * TRWrecord_cache::get_some_obj() return o; } +TRWrecord_cache::TRWrecord_cache(TLocalisamfile *f, int key, bool lock) + :TRecord_cache(f,key) +{ + if (lock) + file().lock(); +} + + TRWrecord_cache::TRWrecord_cache(int num, int key, bool lock) :TRecord_cache(num,key) { @@ -736,6 +744,7 @@ TRWrecord_cache::TRWrecord_cache(int num, int key, bool lock) file().lock(); } + TRWrecord_cache::~TRWrecord_cache() { flush(); @@ -757,7 +766,21 @@ const TString & TStat_cache::getkey2discard() return o->key(); } -TStat_cache ::TStat_cache (bool lock): - TRWrecord_cache( LF_SVSTAT,1,lock) +TStat_cache::TStat_cache (TLocalisamfile *f, bool lock): + TRWrecord_cache( f,1,lock) { } + +// azzera la cache e distrugge il file! +void TStat_cache::zap() +{ + clear(); + + int err=NOERR; + while (err==NOERR) + { + err=file().first(); + if (err==NOERR) + err=file().remove(); + } +} diff --git a/sv/svlib01.h b/sv/svlib01.h index 3366dc780..3749e64f9 100755 --- a/sv/svlib01.h +++ b/sv/svlib01.h @@ -125,6 +125,7 @@ public: void clear(); void flush(); + TRWrecord_cache(TLocalisamfile *f, int key = 1, bool lock=FALSE); TRWrecord_cache(int num, int key = 1, bool lock=FALSE); TRWrecord_cache(const char* table, int key = 1, bool lock=FALSE); virtual ~TRWrecord_cache() ; @@ -135,9 +136,11 @@ class TStat_cache : public TRWrecord_cache protected: virtual const TString & getkey2discard(); public: - TStat_cache (bool lock=FALSE); + TStat_cache (TLocalisamfile &f, bool lock=FALSE); + TStat_cache (TLocalisamfile *f, bool lock=FALSE); virtual ~TStat_cache() {} + void zap(); }; #endif