Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TChainElement.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 11/02/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 /** \class TChainElement
13 \ingroup tree
14 
15 A TChainElement describes a component of a TChain.
16 */
17 
18 #include "TChainElement.h"
19 #include "TBuffer.h"
20 #include "TTree.h"
21 #include "Riostream.h"
22 #include "TROOT.h"
23 
24 ClassImp(TChainElement);
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Default constructor for a chain element.
28 
29 TChainElement::TChainElement() : TNamed(),fBaddress(0),fBaddressType(0),
30  fBaddressIsPtr(kFALSE), fBranchPtr(0), fLoadResult(0)
31 {
32  fNPackets = 0;
33  fPackets = 0;
34  fEntries = 0;
35  fPacketSize = 100;
36  fStatus = -1;
37  ResetBit(kHasBeenLookedUp);
38 }
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Create a chain element.
42 
43 TChainElement::TChainElement(const char *name, const char *title)
44  :TNamed(name,title),fBaddress(0),fBaddressType(0),
45  fBaddressIsPtr(kFALSE), fBranchPtr(0), fLoadResult(0)
46 {
47  fNPackets = 0;
48  fPackets = 0;
49  fEntries = 0;
50  fPacketSize = 100;
51  fStatus = -1;
52  ResetBit(kHasBeenLookedUp);
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Default destructor for a chain element.
57 
58 TChainElement::~TChainElement()
59 {
60  delete [] fPackets;
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Initialize the packet descriptor string.
65 
66 void TChainElement::CreatePackets()
67 {
68  fNPackets = 1 + Int_t(fEntries/fPacketSize);
69  delete [] fPackets;
70  fPackets = new char[fNPackets+1];
71  for (Int_t i=0;i<fNPackets;i++) fPackets[i] = ' ';
72  fPackets[fNPackets] = 0;
73 
74 }
75 
76 ////////////////////////////////////////////////////////////////////////////////
77 /// List files in the chain.
78 
79 void TChainElement::ls(Option_t *) const
80 {
81  TROOT::IndentLevel();
82  std::cout << GetTitle() << "tree:" << GetName() << " entries=";
83  if (fEntries == TTree::kMaxEntries)
84  std::cout << "<not calculated>";
85  else
86  std::cout << fEntries;
87  std::cout << '\n';
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// Set number of entries per packet for parallel root.
92 
93 void TChainElement::SetPacketSize(Int_t size)
94 {
95  fPacketSize = size;
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Set/Reset the looked-up bit
100 
101 void TChainElement::SetLookedUp(Bool_t y)
102 {
103  if (y)
104  SetBit(kHasBeenLookedUp);
105  else
106  ResetBit(kHasBeenLookedUp);
107 }
108