File indexing completed on 2024-04-06 12:03:55
0001 #include "DataFormats/Common/interface/RefCoreStreamer.h"
0002 #include "DataFormats/Common/interface/RefCore.h"
0003 #include "DataFormats/Common/interface/RefCoreWithIndex.h"
0004 #include "FWCore/Utilities/interface/EDMException.h"
0005 #include "DataFormats/Common/interface/EDProductGetter.h"
0006 #include "DataFormats/Provenance/interface/ProductID.h"
0007 #include "TBuffer.h"
0008 #include "TClass.h"
0009
0010 namespace edm {
0011
0012
0013
0014
0015
0016
0017
0018
0019 void RefCoreStreamer::operator()(TBuffer& R__b, void* objp) {
0020 if (R__b.IsReading()) {
0021 cl_->ReadBuffer(R__b, objp);
0022 } else {
0023
0024 RefCore* obj = static_cast<RefCore*>(objp);
0025 if (obj->isTransient()) {
0026 throw Exception(errors::InvalidReference, "Inconsistency")
0027 << "RefCoreStreamer: transient Ref or Ptr cannot be made persistent.";
0028 }
0029 #if 1
0030 R__b << cl_->GetClassVersion();
0031 #else
0032 R__b.WriteVersion(cl_, kFALSE);
0033 #endif
0034
0035 const ProductID& id = obj->id();
0036 R__b << id.processIndex();
0037 R__b << id.productIndex();
0038 }
0039 }
0040
0041 void RefCoreWithIndexStreamer::operator()(TBuffer& R__b, void* objp) {
0042 if (R__b.IsReading()) {
0043 cl_->ReadBuffer(R__b, objp);
0044 } else {
0045
0046 RefCoreWithIndex* obj = static_cast<RefCoreWithIndex*>(objp);
0047 if (obj->isTransient()) {
0048 throw Exception(errors::InvalidReference, "Inconsistency")
0049 << "RefCoreStreamer: transient Ref or Ptr cannot be made persistent.";
0050 }
0051 #if 1
0052 R__b << cl_->GetClassVersion();
0053 #else
0054 R__b.WriteVersion(cl_, kFALSE);
0055 #endif
0056
0057 const ProductID& id = obj->id();
0058 R__b << id.processIndex();
0059 R__b << id.productIndex();
0060 R__b << obj->index();
0061 }
0062 }
0063
0064 TClassStreamer* RefCoreStreamer::Generate() const { return new RefCoreStreamer(*this); }
0065
0066 TClassStreamer* RefCoreWithIndexStreamer::Generate() const { return new RefCoreWithIndexStreamer(*this); }
0067
0068 void setRefCoreStreamerInTClass() {
0069 {
0070 TClass* tClass = TClass::GetClass("edm::RefCore");
0071 if (tClass->GetStreamer() == nullptr) {
0072 tClass->AdoptStreamer(new RefCoreStreamer());
0073 }
0074 }
0075 {
0076 TClass* tClass = TClass::GetClass("edm::RefCoreWithIndex");
0077 if (tClass->GetStreamer() == nullptr) {
0078 tClass->AdoptStreamer(new RefCoreWithIndexStreamer());
0079 }
0080 }
0081 }
0082
0083 void setRefCoreStreamer(bool) { EDProductGetter::switchProductGetter(nullptr); }
0084
0085 EDProductGetter const* setRefCoreStreamer(EDProductGetter const* ep) {
0086 EDProductGetter const* returnValue = nullptr;
0087 if (ep != nullptr) {
0088 returnValue = edm::EDProductGetter::switchProductGetter(ep);
0089 }
0090 return returnValue;
0091 }
0092 }