File indexing completed on 2024-04-06 12:13:08
0001 #ifndef FWCore_SharedMemory_ROOTSerializer_h
0002 #define FWCore_SharedMemory_ROOTSerializer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "TClass.h"
0023 #include "TBufferFile.h"
0024
0025
0026
0027
0028
0029 namespace edm::shared_memory {
0030 template <typename T, typename WRITEBUFFER>
0031 class ROOTSerializer {
0032 public:
0033 ROOTSerializer(WRITEBUFFER& iBuffer)
0034 : buffer_(iBuffer), class_{TClass::GetClass(typeid(T))}, bufferFile_{TBuffer::kWrite} {}
0035
0036 ROOTSerializer(const ROOTSerializer&) = delete;
0037 const ROOTSerializer& operator=(const ROOTSerializer&) = delete;
0038 ROOTSerializer(ROOTSerializer&&) = delete;
0039 const ROOTSerializer& operator=(ROOTSerializer&&) = delete;
0040
0041
0042
0043
0044 void serialize(T& iValue) {
0045 bufferFile_.Reset();
0046 class_->WriteBuffer(bufferFile_, &iValue);
0047
0048 buffer_.copyToBuffer(bufferFile_.Buffer(), bufferFile_.Length());
0049 }
0050
0051 private:
0052
0053 WRITEBUFFER& buffer_;
0054 TClass* const class_;
0055 TBufferFile bufferFile_;
0056 };
0057 }
0058
0059 #endif