CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ROOTSerializer.h
Go to the documentation of this file.
1 #ifndef FWCore_SharedMemory_ROOTSerializer_h
2 #define FWCore_SharedMemory_ROOTSerializer_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SharedMemory
6 // Class : ROOTSerializer
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: 22/01/2020
19 //
20 
21 // system include files
22 #include "TClass.h"
23 #include "TBufferFile.h"
24 
25 // user include files
26 
27 // forward declarations
28 
29 namespace edm::shared_memory {
30  template <typename T, typename WRITEBUFFER>
32  public:
33  ROOTSerializer(WRITEBUFFER& iBuffer)
34  : buffer_(iBuffer), class_{TClass::GetClass(typeid(T))}, bufferFile_{TBuffer::kWrite} {}
35 
36  ROOTSerializer(const ROOTSerializer&) = delete;
37  const ROOTSerializer& operator=(const ROOTSerializer&) = delete;
38  ROOTSerializer(ROOTSerializer&&) = delete;
39  const ROOTSerializer& operator=(ROOTSerializer&&) = delete;
40 
41  // ---------- const member functions ---------------------
42 
43  // ---------- member functions ---------------------------
44  void serialize(T& iValue) {
45  bufferFile_.Reset();
46  class_->WriteBuffer(bufferFile_, &iValue);
47 
48  buffer_.copyToBuffer(bufferFile_.Buffer(), bufferFile_.Length());
49  }
50 
51  private:
52  // ---------- member data --------------------------------
53  WRITEBUFFER& buffer_;
54  TClass* const class_;
55  TBufferFile bufferFile_;
56  };
57 } // namespace edm::shared_memory
58 
59 #endif
const ROOTSerializer & operator=(const ROOTSerializer &)=delete
ROOTSerializer(WRITEBUFFER &iBuffer)
long double T