Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:13:18

0001 // @(#)root/tree:$Id$
0002 // Author: Axel Naumann, 2010-10-12
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TTreeReaderUtils
0013 #define ROOT_TTreeReaderUtils
0014 
0015 
0016 ////////////////////////////////////////////////////////////////////////////
0017 //                                                                        //
0018 // TTreeReaderUtils                                                       //
0019 //                                                                        //
0020 // TTreeReader's helpers.                                                 //
0021 //                                                                        //
0022 //                                                                        //
0023 ////////////////////////////////////////////////////////////////////////////
0024 
0025 #include "TBranchProxyDirector.h"
0026 #include "TBranchProxy.h"
0027 #include "TTreeReaderValue.h"
0028 
0029 #include <string>
0030 
0031 class TDictionary;
0032 class TTree;
0033 
0034 namespace ROOT {
0035    namespace Detail {
0036       class TBranchProxy;
0037    }
0038 
0039 namespace Internal {
0040    class TBranchProxyDirector;
0041    class TTreeReaderArrayBase;
0042 
0043    class TNamedBranchProxy {
0044    public:
0045       TNamedBranchProxy() : fDict(nullptr), fContentDict(nullptr) {}
0046       TNamedBranchProxy(TBranchProxyDirector *boss, TBranch *branch, const char *fullname, const char *membername,
0047                         bool suppressMissingBranchError)
0048          : fProxy(boss, fullname, branch, membername, suppressMissingBranchError),
0049            fDict(nullptr),
0050            fContentDict(nullptr),
0051            fFullName(fullname)
0052       {
0053       }
0054 
0055       // Constructor for friend case, the fullname (containing the name of the friend tree) may be different
0056       // from the lookup name (without the name of the friend)
0057       TNamedBranchProxy(TBranchProxyDirector *boss, TBranch *branch, const char *fullname, const char *proxyname,
0058                         const char *membername, bool suppressMissingBranchError)
0059          : fProxy(boss, proxyname, branch, membername, suppressMissingBranchError),
0060            fDict(nullptr),
0061            fContentDict(nullptr),
0062            fFullName(fullname)
0063       {
0064       }
0065 
0066       const char* GetName() const { return fFullName.c_str(); }
0067       const Detail::TBranchProxy* GetProxy() const { return &fProxy; }
0068       Detail::TBranchProxy* GetProxy() { return &fProxy; }
0069       TDictionary* GetDict() const { return fDict; }
0070       void SetDict(TDictionary* dict) { fDict = dict; }
0071       TDictionary* GetContentDict() const { return fContentDict; }
0072       void SetContentDict(TDictionary* dict) { fContentDict = dict; }
0073 
0074    private:
0075       Detail::TBranchProxy fProxy;
0076       TDictionary*         fDict;
0077       TDictionary*         fContentDict; // type of content, if a collection
0078       std::string          fFullName;
0079    };
0080 
0081    // Used by TTreeReaderArray
0082    class TVirtualCollectionReader {
0083    public:
0084       TTreeReaderValueBase::EReadStatus fReadStatus;
0085 
0086       TVirtualCollectionReader() : fReadStatus(TTreeReaderValueBase::kReadNothingYet) {}
0087 
0088       virtual ~TVirtualCollectionReader();
0089       TVirtualCollectionReader(const TVirtualCollectionReader &) = delete;
0090       TVirtualCollectionReader &operator=(const TVirtualCollectionReader &) = delete;
0091       TVirtualCollectionReader(TVirtualCollectionReader &&) = delete;
0092       TVirtualCollectionReader &operator=(TVirtualCollectionReader &&) = delete;
0093 
0094       virtual size_t GetSize(Detail::TBranchProxy*) = 0;
0095       virtual void* At(Detail::TBranchProxy*, size_t /*idx*/) = 0;
0096       virtual bool IsContiguous(Detail::TBranchProxy *) = 0;
0097       virtual std::size_t GetValueSize(Detail::TBranchProxy *) = 0;
0098    };
0099 
0100 }
0101 }
0102 
0103 #endif // defined TTreeReaderUtils