ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 Abstract base class defining the interface for the plugins that
14 implement Draw, Scan, Process, MakeProxy, etc. for a TTree object.
15 See the individual documentations in TTree.
16 */
17 
18 #include "TROOT.h"
19 #include "TVirtualTreePlayer.h"
20 #include "TPluginManager.h"
21 #include "TClass.h"
22 
23 TClass *TVirtualTreePlayer::fgPlayer = 0;
24 TVirtualTreePlayer *TVirtualTreePlayer::fgCurrent = 0;
25 
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// Static function returning a pointer to a Tree player.
30 /// The player will process the specified obj. If the Tree player
31 /// does not exist a default player is created.
32 
34 {
35  // if no player set yet, create a default painter via the PluginManager
36  if (!fgPlayer) {
38  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualTreePlayer"))) {
39  if (h->LoadPlugin() == -1)
40  return 0;
42  }
43  if (!fgPlayer) return 0;
44  }
45 
46  //create an instance of the Tree player
47  TVirtualTreePlayer *p = (TVirtualTreePlayer*)fgPlayer->New();
48  if (p) p->SetTree(obj);
49  fgCurrent = p;
50  return p;
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Common destructor.
55 
57 {
58  if (fgCurrent==this) {
59  // Make sure fgCurrent does not point to a deleted player.
60  fgCurrent=0;
61  }
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Static function: return the current player (if any)
66 
68 {
69  return fgCurrent;
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Static function to set an alternative Tree player.
74 
75 void TVirtualTreePlayer::SetPlayer(const char *player)
76 {
77  fgPlayer = TClass::GetClass(player);
78 }
79 
virtual void SetTree(TTree *t)=0
TH1 * h
Definition: legend2.C:5
#define gROOT
Definition: TROOT.h:344
Int_t LoadPlugin()
Load the plugin library for this handler.
static TClass * fgPlayer
ClassImp(TVirtualTreePlayer) TVirtualTreePlayer *TVirtualTreePlayer
Static function returning a pointer to a Tree player.
static TVirtualTreePlayer * GetCurrentPlayer()
Static function: return the current player (if any)
static TVirtualTreePlayer * fgCurrent
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
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:2801
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
const char * GetClass() const
TObject * obj
virtual ~TVirtualTreePlayer()
Common destructor.