12 #ifndef ROOT_TTreeReaderArray 13 #define ROOT_TTreeReaderArray 27 #include <type_traits> 67 template <
typename ReaderArrayType>
74 using pointer =
typename std::conditional<std::is_const<ReaderArrayType>::value,
const T *, T *>
::type;
75 using reference =
typename std::conditional<std::is_const<ReaderArrayType>::value,
const T &, T &>
::type;
87 : fArray(array), fIndex(index), fSize(fArray ? fArray->
GetSize() : 0u)
104 R__ASSERT(fArray &&
"invalid iterator!");
105 return fArray->
At(fIndex);
115 return fArray == other.
fArray && fIndex == other.
fIndex;
161 const auto index = std::ptrdiff_t(fIndex);
162 const auto newIndex = index >= n ? index -
n : std::numeric_limits<decltype(fIndex)>::max();
181 bool IsValid()
const {
return fArray !=
nullptr; }
192 const T &
At(std::size_t idx)
const {
return *
static_cast<T *
>(
UntypedAt(idx)); }
204 #define R__TTreeReaderArray_TypeString(T) #T 206 #undef R__TTreeReaderArray_TypeString 211 #endif // ROOT_TTreeReaderArray const_iterator begin() const
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
TTreeReaderArray(TTreeReader &tr, const char *branchname)
Create an array reader of branch "branchname" for TTreeReader "tr".
const char * GetBranchContentDataType(TBranch *branch, TString &contentTypeName, TDictionary *&dict)
Access a branch's collection content (not the collection itself) through a proxy. ...
Iterator_t operator+(std::ptrdiff_t n) const
reference operator[](std::size_t index) const
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
Namespace for new ROOT classes and functions.
typename std::conditional< std::is_const< ReaderArrayType >::value, const T &, T & >::type reference
bool operator>(const Iterator_t &other) const
Iterator_t operator++(int)
Post-increment operator.
Iterator_t operator-(std::ptrdiff_t n) const
pointer operator->() const
virtual void CreateProxy()
Create the proxy object for our branch.
std::ptrdiff_t difference_type
Iterator_t & operator--()
Pre-decrement operator.
std::random_access_iterator_tag iterator_category
Iterator_t & operator+=(std::ptrdiff_t n)
std::size_t GetSize() const
TTreeReaderArray * fArray
The array iterated over; nullptr if invalid/past-the-end.
Detail::TBranchProxy * GetProxy() const
bool operator<=(const Iterator_t &other) const
TTreeReaderArrayBase(TTreeReader *reader, const char *branchname, TDictionary *dict)
T & operator[](std::size_t idx)
Iterator_t(std::size_t index, TTreeReaderArray *array)
Construct iterator.
TTreeReaderValueBase & operator=(const TTreeReaderValueBase &)
Copy-assign.
virtual const char * GetDerivedTypeName() const
TTreeReaderValueBase::EReadStatus fReadStatus
Iterator_t(std::size_t index, const TTreeReaderArray *array)
Construct iterator from a const TTreeReaderArray.
bool GetBranchAndLeaf(TBranch *&branch, TLeaf *&myLeaf, TDictionary *&branchActualType)
Determine the branch / leaf and its type; reset fProxy / fSetupStatus on error.
const T & At(std::size_t idx) const
typename std::conditional< std::is_const< ReaderArrayType >::value, const T *, T * >::type pointer
This class defines an abstract interface that must be implemented by all classes that contain diction...
bool operator!=(const Iterator_t &other) const
bool operator>=(const Iterator_t &other) const
Iterator_t()
Default ctor: constructs a past-the-end iterator.
std::size_t fSize
Size of the TTreeReaderArray.
const T & operator[](std::size_t idx) const
Iterator_t operator--(int)
Post-decrement operator.
std::ptrdiff_t operator-(const Iterator_t &other) const
virtual EReadStatus GetReadStatus() const
void * UntypedAt(std::size_t idx) const
Extracts array data from a TTree.
std::size_t fIndex
Current index in the array.
Random access iterator to the elements of a TTreeReaderArray.
Iterator_t & operator++()
Pre-increment operator.
#define R__TTreeReaderArray_TypeString(T)
const_iterator cbegin() const
Iterator_t & operator-=(std::ptrdiff_t n)
const_iterator end() const
TVirtualCollectionReader * fImpl
bool operator==(const Iterator_t &other) const
Iterator_t< TTreeReaderArray< Int_t > > iterator
virtual void * At(Detail::TBranchProxy *, size_t)=0
friend auto operator+(std::ptrdiff_t n, const Iterator_t &it) -> decltype(it+n)
A TTree is a list of TBranches.
reference operator*() const
bool operator<(const Iterator_t &other) const
Iterator_t< const TTreeReaderArray< Int_t > > const_iterator
void SetImpl(TBranch *branch, TLeaf *myLeaf)
Create the TVirtualCollectionReader object for our branch.
const_iterator cend() const
virtual size_t GetSize(Detail::TBranchProxy *)=0