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 
13 #include <stdint.h>
14 #include <vector>
15 
19 
20 const int init_size = 1024*1024;
21 
22 // Data structure to be shared by all output modules for event serialization
24 {
25  typedef std::vector<char> SBuffer;
26 
31  rootbuf_(TBuffer::kWrite,init_size),
32  ptr_((unsigned char*)rootbuf_.Buffer()),
33  header_buf_(),
34  bufs_(),
36  { }
37 
38  // This object caches the results of the last INIT or event
39  // serialization operation. You get access to the data using the
40  // following member functions.
41 
42  unsigned char* bufferPointer() const { return ptr_; }
43  unsigned int currentSpaceUsed() const { return curr_space_used_; }
44  unsigned int currentEventSize() const { return curr_event_size_; }
45  uint32_t adler32_chksum() const { return adler32_chksum_; }
46 
47  std::vector<unsigned char> comp_buf_; // space for compressed data
48  unsigned int curr_event_size_;
49  unsigned int curr_space_used_; // less than curr_event_size_ if compressed
50  TBufferFile rootbuf_;
51  unsigned char* ptr_; // set to the place where the last event stored
52  SBuffer header_buf_; // place for INIT message creation
53  SBuffer bufs_; // place for EVENT message creation
54  uint32_t adler32_chksum_; // adler32 check sum for the (compressed) data
55 };
56 
57 class EventMsgBuilder;
58 class InitMsgBuilder;
59 namespace edm
60 {
61 
62  class EventPrincipal;
64  {
65 
66  public:
67 
68  StreamSerializer(Selections const* selections);
69 
70  int serializeRegistry(SerializeDataBuffer &data_buffer, const BranchIDLists &branchIDLists);
71  int serializeEvent(EventPrincipal const& eventPrincipal,
72  ParameterSetID const& selectorConfig,
74  SerializeDataBuffer &data_buffer);
75 
81  static unsigned int compressBuffer(unsigned char *inputBuffer,
82  unsigned int inputSize,
83  std::vector<unsigned char> &outputBuffer,
84  int compressionLevel);
85 
86  private:
87 
89  TClass* tc_;
90  };
91 
92 }
93 
94 #endif
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
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_
unsigned int currentEventSize() const
int serializeRegistry(SerializeDataBuffer &data_buffer, const BranchIDLists &branchIDLists)
unsigned char * ptr_