Logo ROOT  
Reference Guide
REntry.cxx
Go to the documentation of this file.
1/// \file REntry.cxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-15
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#include <ROOT/REntry.hxx>
17#include <ROOT/RError.hxx>
18#include <ROOT/RFieldValue.hxx>
19
20#include <algorithm>
21
23{
24 for (auto idx : fManagedValues) {
25 fValues[idx].GetField()->DestroyValue(fValues[idx]);
26 }
27}
28
30{
31 fManagedValues.emplace_back(fValues.size());
32 fValues.push_back(value);
33}
34
36{
37 fValues.push_back(value);
38}
39
41{
42 for (std::size_t i = 0; i < fValues.size(); ++i) {
43 if (fValues[i].GetField()->GetName() != fieldName)
44 continue;
45 auto itr = std::find(fManagedValues.begin(), fManagedValues.end(), i);
46 if (itr != fManagedValues.end()) {
47 fValues[i].GetField()->DestroyValue(fValues[i]);
48 fManagedValues.erase(itr);
49 }
50 fValues[i] = fValues[i].GetField()->CaptureValue(where);
51 return;
52 }
53 throw RException(R__FAIL("invalid field name: " + std::string(fieldName)));
54}
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition: RError.hxx:291
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
std::vector< std::size_t > fManagedValues
Points into fValues and indicates the values that are owned by the entry and need to be destructed.
Definition: REntry.hxx:54
void AddValue(const Detail::RFieldValue &value)
Adds a value whose storage is managed by the entry.
Definition: REntry.cxx:29
void CaptureValueUnsafe(std::string_view fieldName, void *where)
Definition: REntry.cxx:40
void CaptureValue(const Detail::RFieldValue &value)
Adds a value whose storage is not managed by the entry.
Definition: REntry.cxx:35
std::vector< Detail::RFieldValue > fValues
Corresponds to the top-level fields of the linked model.
Definition: REntry.hxx:49
Base class for all ROOT issued exceptions.
Definition: RError.hxx:114
basic_string_view< char > string_view