Logo ROOT   6.18/05
Reference Guide
RFieldValue.hxx
Go to the documentation of this file.
1/// \file ROOT/RFieldValue.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-09
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RFieldValue
17#define ROOT7_RFieldValue
18
20
21#include <new>
22
23namespace ROOT {
24namespace Experimental {
25
26namespace Detail {
27
28class RFieldBase;
29
30// clang-format off
31/**
32\class ROOT::Experimental::RFieldValue
33\ingroup NTuple
34\brief Represents transient storage of simple or complex C++ values.
35
36The data carried by the value is used by the computational code and it is supposed to be serialized on Fill
37or deserialized into by reading. Only fields can generate their corresponding values. This class is a mere
38wrapper around the memory location, it does not own it. Memory ownership is managed through the REntry.
39*/
40// clang-format on
42 friend class RFieldBase;
43
44protected:
45 /// Every value is connected to a field of the corresponding type that has created the value.
47 /// The memory location containing (constructed) data of a certain C++ type
48 void* fRawPtr;
49
50 /// For simple types, the mapped element drills through the layers from the C++ data representation
51 /// to the primitive columns. Otherwise, using fMappedElements is undefined.
52 /// Only RFieldBase uses fMappedElement
54
55public:
56 RFieldValue() : fField(nullptr), fRawPtr(nullptr) {}
57
58 // Constructors that wrap around existing objects; prefixed with a bool in order to help the constructor overload
59 // selection.
60 RFieldValue(bool /*captureTag*/, Detail::RFieldBase* field, void* value) : fField(field), fRawPtr(value) {}
61 RFieldValue(bool /*captureTag*/, const Detail::RColumnElementBase& elem, Detail::RFieldBase* field, void* value)
62 : fField(field), fRawPtr(value), fMappedElement(elem) {}
63
64 // Typed constructors that initialize the given memory location
65 template <typename T, typename... ArgsT>
66 RFieldValue(RFieldBase* field, T* where, ArgsT&&... args) : fField(field), fRawPtr(where)
67 {
68 new (where) T(std::forward<ArgsT>(args)...);
69 }
70
71 template <typename T, typename... ArgsT>
72 RFieldValue(const Detail::RColumnElementBase& elem, Detail::RFieldBase* field, T* where, ArgsT&&... args)
73 : fField(field), fRawPtr(where), fMappedElement(elem)
74 {
75 new (where) T(std::forward<ArgsT>(args)...);
76 }
77
78 template <typename T>
79 T* Get() const { return static_cast<T*>(fRawPtr); }
80
81 void* GetRawPtr() const { return fRawPtr; }
82 RFieldBase* GetField() const { return fField; }
83};
84
85} // namespace Detail
86} // namespace Experimental
87} // namespace ROOT
88
89#endif
RFieldValue(const Detail::RColumnElementBase &elem, Detail::RFieldBase *field, T *where, ArgsT &&... args)
Definition: RFieldValue.hxx:72
RFieldValue(RFieldBase *field, T *where, ArgsT &&... args)
Definition: RFieldValue.hxx:66
RFieldValue(bool, Detail::RFieldBase *field, void *value)
Definition: RFieldValue.hxx:60
RFieldValue(bool, const Detail::RColumnElementBase &elem, Detail::RFieldBase *field, void *value)
Definition: RFieldValue.hxx:61
RColumnElementBase fMappedElement
For simple types, the mapped element drills through the layers from the C++ data representation to th...
Definition: RFieldValue.hxx:53
void * fRawPtr
The memory location containing (constructed) data of a certain C++ type.
Definition: RFieldValue.hxx:48
RFieldBase * fField
Every value is connected to a field of the corresponding type that has created the value.
Definition: RFieldValue.hxx:46
A field translates read and write calls from/to underlying columns to/from tree values.
Definition: RField.hxx:53
double T(double x)
Definition: ChebyshevPol.h:34
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21