CMS 3D CMS Logo

RefCoreStreamer.cc
Go to the documentation of this file.
7 #include "TBuffer.h"
8 #include "TClass.h"
9 
10 namespace edm {
11 
12  /*NOTE: This design came from Philippe Canal as the minimum storage (2bytes) we can do but still
13  have ROOT call our custom streamer. The trick is to only store the version # and not the class ID.
14  The '#if #else #endif' are there because the default choice is known to work for root 5.27-5.28 and
15  Philippe believes is unlikely to ever change but the alternate choice is slightly slower but more
16  guaranteed to be forwards compatible.
17  */
18 
19  void
20  RefCoreStreamer::operator()(TBuffer &R__b, void *objp) {
21  if (R__b.IsReading()) {
22  cl_->ReadBuffer(R__b, objp);
23  } else {
24  //If transient, throw
25  RefCore* obj = static_cast<RefCore*>(objp);
26  if (obj->isTransient()) {
27  throw Exception(errors::InvalidReference,"Inconsistency")
28  << "RefCoreStreamer: transient Ref or Ptr cannot be made persistent.";
29  }
30 #if 1
31  R__b << cl_->GetClassVersion();
32 #else
33  R__b.WriteVersion(cl_, kFALSE);
34 #endif
35  //Must match the order the data appears in the class declaration
36  const ProductID& id = obj->id();
37  R__b << id.processIndex();
38  R__b << id.productIndex();
39  }
40  }
41 
42  void
43  RefCoreWithIndexStreamer::operator()(TBuffer &R__b, void *objp) {
44  if (R__b.IsReading()) {
45  cl_->ReadBuffer(R__b, objp);
46  } else {
47  //If transient, throw
48  RefCoreWithIndex* obj = static_cast<RefCoreWithIndex*>(objp);
49  if (obj->isTransient()) {
50  throw Exception(errors::InvalidReference,"Inconsistency")
51  << "RefCoreStreamer: transient Ref or Ptr cannot be made persistent.";
52  }
53 #if 1
54  R__b << cl_->GetClassVersion();
55 #else
56  R__b.WriteVersion(cl_, kFALSE);
57 #endif
58  //Must match the order the data appears in the class declaration
59  const ProductID& id = obj->id();
60  R__b << id.processIndex();
61  R__b << id.productIndex();
62  R__b << obj->index();
63  }
64  }
65 
66  TClassStreamer*
68  return new RefCoreStreamer(*this);
69  }
70 
71  TClassStreamer*
73  return new RefCoreWithIndexStreamer(*this);
74  }
75 
76 
78 
79  TClass *cl = TClass::GetClass("edm::RefCore");
80  TClassStreamer *st = cl->GetStreamer();
81  if (st == nullptr) {
82  cl->AdoptStreamer(new RefCoreStreamer());
83  }
84  {
85  TClass *cl = TClass::GetClass("edm::RefCoreWithIndex");
86  TClassStreamer *st = cl->GetStreamer();
87  if (st == nullptr) {
88  cl->AdoptStreamer(new RefCoreWithIndexStreamer());
89  }
90  }
91  }
92 
93  void setRefCoreStreamer(bool) {
95  }
96 
98  EDProductGetter const* returnValue=nullptr;
99  if (ep != nullptr) {
101  }
102  return returnValue;
103  }
104 }
void setRefCoreStreamerInTClass()
unsigned int index() const
void setRefCoreStreamer(bool resetAll=false)
ProductID id() const
void operator()(TBuffer &R__b, void *objp) override
TClassStreamer * Generate() const override
ProductID id() const
Definition: RefCore.h:49
bool isTransient() const
Definition: RefCore.h:106
HLT enums.
TClassStreamer * Generate() const override
ProcessIndex processIndex() const
Definition: ProductID.h:36
static EDProductGetter const * switchProductGetter(EDProductGetter const *)
These can only be used internally by the framework.
void operator()(TBuffer &R__b, void *objp) override