Logo ROOT   6.08/07
Reference Guide
TVirtualTreePlayer.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 30/08/99
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 TVirtualTreePlayer
13 \ingroup tree
14 
15 Abstract base class defining the interface for the plugins that
16 implement Draw, Scan, Process, MakeProxy, etc. for a TTree object.
17 See the individual documentations in TTree.
18 */
19 
20 #include "TROOT.h"
21 #include "TVirtualTreePlayer.h"
22 #include "TPluginManager.h"
23 #include "TClass.h"
24 
27 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Static function returning a pointer to a Tree player.
32 /// The player will process the specified obj. If the Tree player
33 /// does not exist a default player is created.
34 
36 {
37  // if no player set yet, create a default painter via the PluginManager
38  if (!fgPlayer) {
40  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualTreePlayer"))) {
41  if (h->LoadPlugin() == -1)
42  return 0;
44  }
45  if (!fgPlayer) return 0;
46  }
47 
48  //create an instance of the Tree player
49  TVirtualTreePlayer *p = (TVirtualTreePlayer*)fgPlayer->New();
50  if (p) p->SetTree(obj);
51  fgCurrent = p;
52  return p;
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Common destructor.
57 
59 {
60  if (fgCurrent==this) {
61  // Make sure fgCurrent does not point to a deleted player.
62  fgCurrent=0;
63  }
64 }
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Static function: return the current player (if any)
68 
70 {
71  return fgCurrent;
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Static function to set an alternative Tree player.
76 
77 void TVirtualTreePlayer::SetPlayer(const char *player)
78 {
79  fgPlayer = TClass::GetClass(player);
80 }
81 
virtual void SetTree(TTree *t)=0
TH1 * h
Definition: legend2.C:5
#define gROOT
Definition: TROOT.h:364
Int_t LoadPlugin()
Load the plugin library for this handler.
static TClass * fgPlayer
Pointer to class of Tree player.
static TVirtualTreePlayer * GetCurrentPlayer()
Static function: return the current player (if any)
static TVirtualTreePlayer * fgCurrent
Pointer to current Tree player.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
#define ClassImp(name)
Definition: Rtypes.h:279
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2893
static void SetPlayer(const char *player)
Static function to set an alternative Tree player.
Abstract base class defining the interface for the plugins that implement Draw, Scan, Process, MakeProxy, etc.
A TTree object has a header with a name and a title.
Definition: TTree.h:98
virtual ~TVirtualTreePlayer()
Common destructor.
const char * GetClass() const