CMS 3D CMS Logo

Namespaces | Macros | Functions
PortableHostObjectReadRules.h File Reference
#include <TGenericClassInfo.h>
#include <TVirtualObject.h>
#include "DataFormats/Portable/interface/PortableHostObject.h"
#include "FWCore/Utilities/interface/concatenate.h"
#include "FWCore/Utilities/interface/stringize.h"

Go to the source code of this file.

Namespaces

 ROOT
 

Macros

#define SET_PORTABLEHOSTOBJECT_READ_RULES(OBJECT)
 

Functions

template<typename T >
static void readPortableHostObject_v1 (char *target, TVirtualObject *from_buffer)
 
template<typename T >
static bool ROOT::set_PortableHostObject_read_rules (std::string const &type)
 

Macro Definition Documentation

◆ SET_PORTABLEHOSTOBJECT_READ_RULES

#define SET_PORTABLEHOSTOBJECT_READ_RULES (   OBJECT)
Value:
static bool EDM_CONCATENATE(set_PortableHostObject_read_rules_done_at_, __LINE__) [[maybe_unused]] = \
ROOT::set_PortableHostObject_read_rules<OBJECT>(EDM_STRINGIZE(OBJECT))
#define EDM_CONCATENATE(a, b)
Definition: concatenate.h:6
#define EDM_STRINGIZE(token)
Definition: stringize.h:6

Definition at line 72 of file PortableHostObjectReadRules.h.

Function Documentation

◆ readPortableHostObject_v1()

template<typename T >
static void readPortableHostObject_v1 ( char *  target,
TVirtualObject *  from_buffer 
)
static

Definition at line 13 of file PortableHostObjectReadRules.h.

References filterCSVwithJSON::target.

13  {
14  // extract the actual types
15  using Object = T;
16  using Product = typename Object::Product;
17 
18  // valid only for PortableHostObject<T>
19  static_assert(std::is_same_v<Object, PortableHostObject<Product>>);
20 
21  // proxy for the object being read from file
22  struct OnFile {
23  Product *product_;
24  };
25 
26  // address in memory of the buffer containing the object being read from file
27  char *address = static_cast<char *>(from_buffer->GetObject());
28  // offset of the "product_" data member
29  static ptrdiff_t product_offset = from_buffer->GetClass()->GetDataMemberOffset("product_");
30  // pointer to the Product object being read from file
31  OnFile onfile = {*(Product **)(address + product_offset)};
32 
33  // pointer to the Object object being constructed in memory
34  Object *newObj = (Object *)target;
35 
36  // move the data from the on-file layout to the newly constructed object
37  Object::ROOTReadStreamer(newObj, *onfile.product_);
38 }
long double T