22 #include "Riostream.h"
28 #include "TGo4LockGuard.h"
30 #if ROOT_VERSION_CODE > ROOT_VERSION(4,3,2)
46 GO4TRACE((14,
"TGo4BufferQueue::TGo4BufferQueue()", __LINE__, __FILE__));
59 GO4TRACE((14,
"TGo4BufferQueue::TGo4BufferQueue(const char*)", __LINE__, __FILE__));
67 GO4TRACE((14,
"TGo4BufferQueue::InitBuffers()", __LINE__, __FILE__));
82 GO4TRACE((14,
"TGo4BufferQueue::~TTGo4BufferQueue()", __LINE__, __FILE__));
86 TCollection::EmptyGarbageCollection();
99 GO4TRACE((19,
"TGo4BufferQueue::WaitBuffer()", __LINE__, __FILE__));
100 TObject* ob =
Wait();
101 return dynamic_cast<TBuffer*
> ( ob );
106 GO4TRACE((19,
"TGo4BufferQueue::WaitObjectFromBuffer()", __LINE__, __FILE__));
114 TDirectory* savdir=gDirectory;
116 buffer->SetReadMode();
123 TClass* cl = buffer->ReadClass();
125 if(cl == (TClass*) -1)
128 std::cout <<
" Could not receive object of unknown class on buffer queue "<<GetName() <<
" !!!" <<std::endl;
135 obj = buffer->ReadObject(cl);
137 if(savdir) savdir->cd();
147 GO4TRACE((19,
"TGo4BufferQueue::AddBuffer(TBuffer*, Bool_t)", __LINE__, __FILE__));
150 Bool_t entryisnew=kFALSE;
177 Int_t srcsize=buffer->BufferSize();
178 Int_t destsize=entry->BufferSize();
179 if (srcsize>destsize)
181 Realloc(entry,destsize,srcsize);
188 char* source= buffer->Buffer();
189 char* destination= entry->Buffer();
190 memcpy(destination,source,destsize);
192 Int_t messlen = buffer->Length();
193 entry->SetBufferOffset(messlen);
194 entry->SetByteCount(0);
210 std::cout <<
"Buffer queue "<< GetName()<<
" is full, dropping new entry "<< entry <<
" !!!" << std::endl;
222 GO4TRACE((12,
"TGo4BufferQueue::AddBufferFromObject(TObject*)", __LINE__, __FILE__));
223 if(
object==0)
return;
228 TFile *filsav = gFile;
230 entry->WriteObject(
object);
261 std::cout <<
"Buffer queue "<< GetName()<<
" is full, dropping new entry "<< entry <<
" !!!" << std::endl;
269 GO4TRACE((19,
"TGo4BufferQueue::FreeBuffer(TBuffer*, Bool_t)", __LINE__, __FILE__));
279 Int_t memsize=buffer->BufferSize();
306 while((ob=
Next()) !=0) {
315 if(buffer==0)
return;
318 char* memfield = buffer->Buffer();
326 memfield = TStorage::ReAllocChar(memfield,
327 (newsize+extraspace),
328 (oldsize+extraspace));
334 buffer->SetBuffer(memfield, newsize);
342 buffer->SetBufferOffset(newsize);
351 TNamed* dummy=
new TNamed(
"This is a default buffer filler",
"GO4 is fun!");
352 TFile *filsav = gFile;
354 buf->WriteObject(dummy);
363 char* field= buf->Buffer() +
sizeof(UInt_t);
365 buf->SetBufferOffset(
sizeof(UInt_t)+
sizeof(UInt_t) );
366 buf->SetByteCount(0);
373 if(buf==0)
return -1;
374 UInt_t len= buf->Length();
375 if(len != (
sizeof(UInt_t)+
sizeof(UInt_t)))
return -2;
378 char* field=buf->Buffer();
379 char* temp= field +
sizeof(UInt_t);
TObject * WaitObjectFromBuffer()
virtual void Clear(Option_t *opt="")
void Realloc(TBuffer *buffer, Int_t oldsize, Int_t newsize)
static const Int_t fgiBUFINITSIZE
void AddBuffer(TBuffer *buffer, Bool_t clone=kFALSE)
static Int_t DecodeValueBuffer(TBuffer *buf)
static const Int_t fgiISOWNER
static TBuffer * CreateValueBuffer(UInt_t val)
static const Int_t fgiBUFEXTRASPACE
void FreeBuffer(TBuffer *buffer)
void AddBufferFromObject(TObject *object)
virtual ~TGo4BufferQueue()
static void Debug(const char *text,...)