Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TTreeReaderUtils.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Axel Naumann, 2010-10-12
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTreeReaderUtils
13 #define ROOT_TTreeReaderUtils
14 
15 
16 ////////////////////////////////////////////////////////////////////////////
17 // //
18 // TTreeReaderUtils //
19 // //
20 // TTreeReader's helpers. //
21 // //
22 // //
23 ////////////////////////////////////////////////////////////////////////////
24 
25 #include "TBranchProxyDirector.h"
26 #include "TBranchProxy.h"
27 #include "TTreeReaderValue.h"
28 
29 class TDictionary;
30 class TTree;
31 
32 namespace ROOT {
33  namespace Detail {
34  class TBranchProxy;
35  }
36 
37 namespace Internal {
38  class TBranchProxyDirector;
39  class TTreeReaderArrayBase;
40 
41  class TNamedBranchProxy {
42  public:
43  TNamedBranchProxy(): fDict(0), fContentDict(0) {}
44  TNamedBranchProxy(TBranchProxyDirector* boss, TBranch* branch, const char* fullname, const char* membername):
45  fProxy(boss, fullname, branch, membername), fDict(0), fContentDict(0), fFullName(fullname) {}
46 
47  // Constructor for friend case, the fullname (containing the name of the friend tree) may be different
48  // from the lookup name (without the name of the friend)
49  TNamedBranchProxy(TBranchProxyDirector* boss, TBranch* branch, const char* fullname, const char* proxyname, const char* membername):
50  fProxy(boss, proxyname, branch, membername), fDict(0), fContentDict(0), fFullName(fullname) {}
51 
52  const char* GetName() const { return fFullName.c_str(); }
53  const Detail::TBranchProxy* GetProxy() const { return &fProxy; }
54  Detail::TBranchProxy* GetProxy() { return &fProxy; }
55  TDictionary* GetDict() const { return fDict; }
56  void SetDict(TDictionary* dict) { fDict = dict; }
57  TDictionary* GetContentDict() const { return fContentDict; }
58  void SetContentDict(TDictionary* dict) { fContentDict = dict; }
59 
60  private:
61  Detail::TBranchProxy fProxy;
62  TDictionary* fDict;
63  TDictionary* fContentDict; // type of content, if a collection
64  std::string fFullName;
65  };
66 
67  // Used by TTreeReaderArray
68  class TVirtualCollectionReader {
69  public:
70  TTreeReaderValueBase::EReadStatus fReadStatus;
71 
72  TVirtualCollectionReader() : fReadStatus(TTreeReaderValueBase::kReadNothingYet) {}
73 
74  virtual ~TVirtualCollectionReader();
75  virtual size_t GetSize(Detail::TBranchProxy*) = 0;
76  virtual void* At(Detail::TBranchProxy*, size_t /*idx*/) = 0;
77  };
78 
79 }
80 }
81 
82 #endif // defined TTreeReaderUtils