CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StreamSerializer.h
Go to the documentation of this file.
1 #ifndef IOPool_Streamer_StreamSerializer_h
2 #define IOPool_Streamer_StreamSerializer_h
3 
11 #include "TBufferFile.h"
12 
15 #include <stdint.h>
16 #include <vector>
17 
18 
19 const int init_size = 1024*1024;
20 
21 // Data structure to be shared by all output modules for event serialization
23 {
24  typedef std::vector<char> SBuffer;
25 
30  rootbuf_(TBuffer::kWrite,init_size),
31  ptr_((unsigned char*)rootbuf_.Buffer()),
32  header_buf_(),
33  bufs_(),
35  { }
36 
37  // This object caches the results of the last INIT or event
38  // serialization operation. You get access to the data using the
39  // following member functions.
40 
41  unsigned char* bufferPointer() const { return ptr_; }
42  unsigned int currentSpaceUsed() const { return curr_space_used_; }
43  unsigned int currentEventSize() const { return curr_event_size_; }
44  uint32_t adler32_chksum() const { return adler32_chksum_; }
45 
46  std::vector<unsigned char> comp_buf_; // space for compressed data
47  unsigned int curr_event_size_;
48  unsigned int curr_space_used_; // less than curr_event_size_ if compressed
49  TBufferFile rootbuf_;
50  unsigned char* ptr_; // set to the place where the last event stored
51  SBuffer header_buf_; // place for INIT message creation
52  SBuffer bufs_; // place for EVENT message creation
53  uint32_t adler32_chksum_; // adler32 check sum for the (compressed) data
54 };
55 
56 class EventMsgBuilder;
57 class InitMsgBuilder;
58 namespace edm
59 {
60 
61  class EventPrincipal;
63  {
64 
65  public:
66 
67  StreamSerializer(Selections const* selections);
68 
69  int serializeRegistry(SerializeDataBuffer &data_buffer);
70  int serializeEvent(EventPrincipal const& eventPrincipal,
71  ParameterSetID const& selectorConfig,
73  SerializeDataBuffer &data_buffer);
74 
80  static unsigned int compressBuffer(unsigned char *inputBuffer,
81  unsigned int inputSize,
82  std::vector<unsigned char> &outputBuffer,
83  int compressionLevel);
84 
85  private:
86 
88  TClass* tc_;
89  };
90 
91 }
92 
93 #endif
std::vector< char > SBuffer
static unsigned int compressBuffer(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, int compressionLevel)
unsigned int currentSpaceUsed() const
std::vector< unsigned char > comp_buf_
unsigned int curr_event_size_
StreamSerializer(Selections const *selections)
unsigned int curr_space_used_
int serializeEvent(EventPrincipal const &eventPrincipal, ParameterSetID const &selectorConfig, bool use_compression, int compression_level, SerializeDataBuffer &data_buffer)
unsigned char * bufferPointer() const
uint32_t adler32_chksum() const
const int init_size
Selections const * selections_
int serializeRegistry(SerializeDataBuffer &data_buffer)
unsigned int currentEventSize() const
unsigned char * ptr_