CMS 3D CMS Logo

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
edm::shared_memory::ROOTSerializer::bufferFile_
TBufferFile bufferFile_
Definition: ROOTSerializer.h:55
edm::shared_memory::ROOTSerializer
Definition: ROOTSerializer.h:31
ROOTSerializer
edm::shared_memory::ROOTSerializer::buffer_
WRITEBUFFER & buffer_
Definition: ROOTSerializer.h:53
edm::shared_memory::ROOTSerializer::ROOTSerializer
ROOTSerializer(WRITEBUFFER &iBuffer)
Definition: ROOTSerializer.h:33
edm::shared_memory::ROOTSerializer::serialize
void serialize(T &iValue)
Definition: ROOTSerializer.h:44
edm::shared_memory::ROOTSerializer::class_
TClass *const class_
Definition: ROOTSerializer.h:54
edm::shared_memory
Definition: buffer_names.h:27
T
long double T
Definition: Basic3DVectorLD.h:48
edm::shared_memory::ROOTSerializer::operator=
const ROOTSerializer & operator=(const ROOTSerializer &)=delete