00001 #ifndef IOPool_Streamer_StreamSerializer_h
00002 #define IOPool_Streamer_StreamSerializer_h
00003
00011 #include "RVersion.h"
00012 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
00013 #include "TBufferFile.h"
00014 typedef TBufferFile RootBuffer;
00015 #else
00016 #include "TBuffer.h"
00017 typedef TBuffer RootBuffer;
00018 #endif
00019
00020 const int init_size = 1024*1024;
00021
00022
00023 struct SerializeDataBuffer
00024 {
00025 typedef std::vector<char> SBuffer;
00026
00027 SerializeDataBuffer():
00028 comp_buf_(init_size),
00029 curr_event_size_(),
00030 curr_space_used_(),
00031 rootbuf_(TBuffer::kWrite,init_size),
00032 ptr_((unsigned char*)rootbuf_.Buffer()),
00033 header_buf_(),
00034 bufs_()
00035 { }
00036
00037
00038
00039
00040
00041 unsigned char* bufferPointer() const { return ptr_; }
00042 unsigned int currentSpaceUsed() const { return curr_space_used_; }
00043 unsigned int currentEventSize() const { return curr_event_size_; }
00044
00045 std::vector<unsigned char> comp_buf_;
00046 unsigned int curr_event_size_;
00047 unsigned int curr_space_used_;
00048 RootBuffer rootbuf_;
00049 unsigned char* ptr_;
00050 SBuffer header_buf_;
00051 SBuffer bufs_;
00052 };
00053
00054 #include "DataFormats/Provenance/interface/Selections.h"
00055 #include <vector>
00056
00057 class EventMsgBuilder;
00058 class InitMsgBuilder;
00059 namespace edm
00060 {
00061
00062 class EventPrincipal;
00063 class StreamSerializer
00064 {
00065
00066 public:
00067
00068 StreamSerializer(Selections const* selections);
00069
00070 int serializeRegistry(SerializeDataBuffer &data_buffer);
00071 int serializeEvent(EventPrincipal const& eventPrincipal,
00072 bool use_compression, int compression_level,
00073 SerializeDataBuffer &data_buffer);
00074
00080 static unsigned int compressBuffer(unsigned char *inputBuffer,
00081 unsigned int inputSize,
00082 std::vector<unsigned char> &outputBuffer,
00083 int compressionLevel);
00084
00085 private:
00086
00087
00088 struct Arr
00089 {
00090 explicit Arr(int sz);
00091 ~Arr();
00092
00093 char* ptr_;
00094 };
00095
00096 Selections const* selections_;
00097
00098 TClass* tc_;
00099 };
00100
00101 }
00102
00103 #endif