#ifndef ROOT_TTreeReaderArray
#define ROOT_TTreeReaderArray
#ifndef ROOT_TTreeReaderValue
#include "TTreeReaderValue.h"
#endif
#ifndef ROOT_TTreeReaderUtils
#include "TTreeReaderUtils.h"
#endif
namespace ROOT {
class TTreeReaderArrayBase: public TTreeReaderValueBase {
public:
TTreeReaderArrayBase(TTreeReader* reader, const char* branchname,
TDictionary* dict):
TTreeReaderValueBase(reader, branchname, dict), fImpl(0) {}
size_t GetSize() const { return fImpl->GetSize(GetProxy()); }
Bool_t IsEmpty() const { return !GetSize(); }
virtual EReadStatus GetReadStatus() const { return fImpl ? fImpl->fReadStatus : kReadError; }
protected:
void* UntypedAt(size_t idx) const { return fImpl->At(GetProxy(), idx); }
virtual void CreateProxy();
const char* GetBranchContentDataType(TBranch* branch,
TString& contentTypeName,
TDictionary* &dict) const;
TVirtualCollectionReader* fImpl;
};
}
template <typename T>
class TTreeReaderArray: public ROOT::TTreeReaderArrayBase {
public:
TTreeReaderArray(TTreeReader& tr, const char* branchname):
TTreeReaderArrayBase(&tr, branchname, TDictionary::GetDictionary(typeid(T)))
{
}
T& At(size_t idx) { return *(T*)UntypedAt(idx); }
T& operator[](size_t idx) { return At(idx); }
protected:
#define R__TTreeReaderArray_TypeString(T) #T
virtual const char* GetDerivedTypeName() const { return R__TTreeReaderArray_TypeString(T); }
#undef R__TTreeReaderArray_TypeString
};
#endif // ROOT_TTreeReaderArray