Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TBranchProxyDirector.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Philippe Canal 13/05/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun, Fons Rademakers and al. *
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_TBranchProxyDirector
13 #define ROOT_TBranchProxyDirector
14 
15 #include "Rtypes.h"
16 #include <vector>
17 #include <list>
18 #include <algorithm>
19 
20 class TH1F;
21 class TTree;
22 
23 namespace ROOT {
24 namespace Detail {
25  class TBranchProxy;
26  class TFriendProxy;
27 }
28 
29 namespace Internal{
30  class TFriendProxy;
31 
32  // Helper function to call SetReadEntry on all TFriendProxy
33  void ResetReadEntry(TFriendProxy *fp);
34 
35  class TBranchProxyDirector {
36 
37  //This class could actually be the selector itself.
38  TTree *fTree; // TTree we are currently looking at.
39  Long64_t fEntry; // Entry currently being read (in the local TTree rather than the TChain)
40 
41  std::list<Detail::TBranchProxy*> fDirected;
42  std::vector<TFriendProxy*> fFriends;
43 
44  TBranchProxyDirector(const TBranchProxyDirector &) : fTree(0), fEntry(-1) {;}
45  TBranchProxyDirector& operator=(const TBranchProxyDirector&) {return *this;}
46 
47  public:
48 
49  TBranchProxyDirector(TTree* tree, Long64_t i);
50  TBranchProxyDirector(TTree* tree, Int_t i); // cint has (had?) a problem casting int to long long
51 
52  void Attach(Detail::TBranchProxy* p);
53  void Attach(TFriendProxy* f);
54  TH1F* CreateHistogram(const char *options);
55 
56  /// Return the current 'local' entry number; i.e. in the 'local' TTree rather than the TChain.
57  /// This value will be passed directly to TBranch::GetEntry.
58  Long64_t GetReadEntry() const { return fEntry; }
59 
60  TTree* GetTree() const { return fTree; };
61  // void Print();
62 
63  /// Move to a new entry to read
64  /// entry is the 'local' entry number; i.e. in the 'local' TTree rather than the TChain.
65  /// This value will be passed directly to TBranch::GetEntry.
66  void SetReadEntry(Long64_t entry) {
67  fEntry = entry;
68  if (!fFriends.empty()) {
69  std::for_each(fFriends.begin(), fFriends.end(), ResetReadEntry);
70  }
71  }
72  TTree* SetTree(TTree *newtree);
73  Bool_t Notify();
74 
75  };
76 
77 } // namespace Internal
78 } // namespace ROOT
79 
80 #endif