CMS 3D CMS Logo

ROOTDeserializer.h
Go to the documentation of this file.
1 #ifndef FWCore_SharedMemory_ROOTDeserializer_h
2 #define FWCore_SharedMemory_ROOTDeserializer_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SharedMemory
6 // Class : ROOTDeserializer
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 READBUFFER>
32  public:
33  ROOTDeserializer(READBUFFER& iBuffer)
34  : buffer_{iBuffer}, class_{TClass::GetClass(typeid(T))}, bufferFile_(TBuffer::kRead) {}
35 
36  ROOTDeserializer(const ROOTDeserializer&) = delete;
37  const ROOTDeserializer& operator=(const ROOTDeserializer&) = delete;
39  const ROOTDeserializer& operator=(ROOTDeserializer&&) = delete;
40 
41  // ---------- const member functions ---------------------
42 
43  // ---------- member functions ---------------------------
45  T value;
46  if (previousBufferIdentifier_ != buffer_.bufferIdentifier()) {
47  auto buff = buffer_.buffer();
48  bufferFile_.SetBuffer(buff.first, buff.second, kFALSE);
49  previousBufferIdentifier_ = buffer_.bufferIdentifier();
50  }
51 
52  class_->ReadBuffer(bufferFile_, &value);
53  bufferFile_.Reset();
54  return value;
55  }
56 
57  private:
58  // ---------- member data --------------------------------
59  READBUFFER& buffer_;
60  TClass* const class_;
61  TBufferFile bufferFile_;
63  };
64 } // namespace edm::shared_memory
65 
66 #endif
ROOTDeserializer
edm::shared_memory::ROOTDeserializer
Definition: ROOTDeserializer.h:31
edm::shared_memory::ROOTDeserializer::previousBufferIdentifier_
int previousBufferIdentifier_
Definition: ROOTDeserializer.h:62
edm::shared_memory::ROOTDeserializer::operator=
const ROOTDeserializer & operator=(const ROOTDeserializer &)=delete
edm::shared_memory::ROOTDeserializer::bufferFile_
TBufferFile bufferFile_
Definition: ROOTDeserializer.h:61
value
Definition: value.py:1
edm::shared_memory
Definition: buffer_names.h:27
edm::shared_memory::ROOTDeserializer::deserialize
T deserialize()
Definition: ROOTDeserializer.h:44
edm::shared_memory::ROOTDeserializer::class_
TClass *const class_
Definition: ROOTDeserializer.h:60
edm::shared_memory::ROOTDeserializer::buffer_
READBUFFER & buffer_
Definition: ROOTDeserializer.h:59
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
edm::shared_memory::ROOTDeserializer::ROOTDeserializer
ROOTDeserializer(READBUFFER &iBuffer)
Definition: ROOTDeserializer.h:33