12#ifndef ROOT_TTreeReaderArray
13#define ROOT_TTreeReaderArray
50 std::unique_ptr<TVirtualCollectionReader>
fImpl;
81 template <
typename ReaderArrayType>
88 using pointer =
typename std::conditional<std::is_const<ReaderArrayType>::value,
const T *,
T *>
::type;
89 using reference =
typename std::conditional<std::is_const<ReaderArrayType>::value,
const T &,
T &>
::type;
101 : fArray(array), fIndex(index), fSize(fArray ? fArray->GetSize() : 0u)
118 R__ASSERT(fArray &&
"invalid iterator!");
119 return fArray->
At(fIndex);
127 if (!IsValid() && !other.
IsValid())
129 return fArray == other.
fArray && fIndex == other.
fIndex;
175 const auto index = std::ptrdiff_t(fIndex);
176 const auto newIndex = index >=
n ? index -
n : std::numeric_limits<
decltype(fIndex)>::max();
195 bool IsValid()
const {
return fArray !=
nullptr; }
203 : TTreeReaderArrayBase(&tr, branchname,
TDictionary::GetDictionary(typeid(
T))) {}
206 const T &
At(std::size_t idx)
const {
return *
static_cast<T *
>(
UntypedAt(idx)); }
218#define R__TTreeReaderArray_TypeString(T) #T
220#undef R__TTreeReaderArray_TypeString
#define R__TTreeReaderArray_TypeString(T)
Base class of TTreeReaderArray.
std::unique_ptr< TVirtualCollectionReader > fImpl
bool GetBranchAndLeaf(TBranch *&branch, TLeaf *&myLeaf, TDictionary *&branchActualType)
Determine the branch / leaf and its type; reset fProxy / fSetupStatus on error.
std::size_t GetSize() const
TTreeReaderArrayBase(TTreeReader *reader, const char *branchname, TDictionary *dict)
void * UntypedAt(std::size_t idx) const
virtual void CreateProxy()
Create the proxy object for our branch.
virtual EReadStatus GetReadStatus() const
void SetImpl(TBranch *branch, TLeaf *myLeaf)
Create the TVirtualCollectionReader object for our branch.
const char * GetBranchContentDataType(TBranch *branch, TString &contentTypeName, TDictionary *&dict)
Access a branch's collection content (not the collection itself) through a proxy.
Base class of TTreeReaderValue.
Detail::TBranchProxy * GetProxy() const
A TTree is a list of TBranches.
This class defines an abstract interface that must be implemented by all classes that contain diction...
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Random access iterator to the elements of a TTreeReaderArray.
Iterator_t()
Default ctor: constructs a past-the-end iterator.
std::size_t fIndex
Current index in the array.
bool operator>(const Iterator_t &other) const
reference operator[](std::size_t index) const
Iterator_t & operator--()
Pre-decrement operator.
bool operator!=(const Iterator_t &other) const
std::ptrdiff_t difference_type
Iterator_t operator++(int)
Post-increment operator.
bool operator>=(const Iterator_t &other) const
reference operator*() const
Iterator_t(const Iterator_t &)=default
Iterator_t & operator++()
Pre-increment operator.
Iterator_t operator--(int)
Post-decrement operator.
typename std::conditional< std::is_const< ReaderArrayType >::value, const T *, T * >::type pointer
std::size_t fSize
Size of the TTreeReaderArray.
Iterator_t & operator-=(std::ptrdiff_t n)
Iterator_t & operator=(Iterator_t &&)=default
bool operator<(const Iterator_t &other) const
std::ptrdiff_t operator-(const Iterator_t &other) const
TTreeReaderArray * fArray
The array iterated over; nullptr if invalid/past-the-end.
Iterator_t & operator=(const Iterator_t &)=default
Iterator_t & operator+=(std::ptrdiff_t n)
Iterator_t(Iterator_t &&)=default
bool operator<=(const Iterator_t &other) const
Iterator_t operator-(std::ptrdiff_t n) const
bool operator==(const Iterator_t &other) const
typename std::conditional< std::is_const< ReaderArrayType >::value, const T &, T & >::type reference
friend auto operator+(std::ptrdiff_t n, const Iterator_t &it) -> decltype(it+n)
Iterator_t operator+(std::ptrdiff_t n) const
std::random_access_iterator_tag iterator_category
pointer operator->() const
Iterator_t(std::size_t index, TTreeReaderArray *array)
Construct iterator.
Iterator_t(std::size_t index, const TTreeReaderArray *array)
Construct iterator from a const TTreeReaderArray.
An interface for reading collections stored in ROOT columnar datasets.
TTreeReaderArray(TTreeReader &tr, const char *branchname)
Create an array reader of branch "branchname" for TTreeReader "tr".
const_iterator cend() const
virtual const char * GetDerivedTypeName() const
const_iterator cbegin() const
const T & At(std::size_t idx) const
const_iterator begin() const
const T & operator[](std::size_t idx) const
T & operator[](std::size_t idx)
const_iterator end() const
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Namespace for new ROOT classes and functions.