ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gzbuffer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file gzbuffer.cc
1 #include "gzbuffer.h"
2 #include <zlib.h>
3 
4 // the constructor first ----------------
5 gzbuffer::gzbuffer (PHDWORD *array , const int length )
6 
7 {
8  is_good =1;
9  bufferarray=0;
10  theBuffer=0;
11 
12  uLong bytes;
13  uLongf outputlength_in_bytes;
14  if (array[1] == GZBUFFERMARKER )
15  {
16  bytes = array[0]-4*BUFFERHEADERLENGTH;
17  outputlength_in_bytes = array[3];
18  }
19  else if ( u4swap(array[1]) == GZBUFFERMARKER)
20  {
21  bytes = i4swap(array[0])-16;
22  outputlength_in_bytes = i4swap(array[3]);
23  }
24 
25  else
26  {
27  COUT << " wrong buffer" << std::endl;
28  is_good = 0;
29  return;
30  }
31 
32 
33  int outputlength = (outputlength_in_bytes+3)/4;
34  bufferarray = new PHDWORD[outputlength];
35  uLongf i = outputlength_in_bytes;
36 
37  uncompress ( (Bytef*) bufferarray, &i, (Bytef*) &array[4], bytes);
38 
39  theBuffer = new prdfBuffer(bufferarray, outputlength);
40 
41 }
42 
43 // ---------------------------------------------------------
45 {
46  return theBuffer->getEvent();
47 }
48 
49 // ---------------------------------------------------------
50 
52 {
53  if ( bufferarray) delete [] bufferarray;
54  if ( theBuffer) delete theBuffer;
55 }
56 
57