TVirtualTreePlayer.cxx

Go to the documentation of this file.
00001 // @(#)root/tree:$Id: TVirtualTreePlayer.cxx 21510 2007-12-19 20:55:57Z pcanal $
00002 // Author: Rene Brun   30/08/99
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TVirtualTreePlayer
00015 // 
00016 // Abstract base class defining the interface for the plugins that
00017 // implement Draw, Scan, Process, MakeProxy, etc. for a TTree object.
00018 // See the individual documentations in TTree. 
00019 //                                                                      //
00020 //////////////////////////////////////////////////////////////////////////
00021 
00022 #include "TROOT.h"
00023 #include "TVirtualTreePlayer.h"
00024 #include "TPluginManager.h"
00025 #include "TClass.h"
00026 
00027 TClass              *TVirtualTreePlayer::fgPlayer  = 0;
00028 TVirtualTreePlayer  *TVirtualTreePlayer::fgCurrent = 0;
00029 
00030 ClassImp(TVirtualTreePlayer)
00031 
00032 //______________________________________________________________________________
00033 TVirtualTreePlayer *TVirtualTreePlayer::TreePlayer(TTree *obj)
00034 {
00035    // Static function returning a pointer to a Tree player.
00036    // The player will process the specified obj. If the Tree player
00037    // does not exist a default player is created.
00038 
00039    // if no player set yet,  create a default painter via the PluginManager
00040    if (!fgPlayer) {
00041       TPluginHandler *h;
00042       if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualTreePlayer"))) {
00043          if (h->LoadPlugin() == -1)
00044             return 0;
00045          TVirtualTreePlayer::SetPlayer(h->GetClass());
00046       }
00047       if (!fgPlayer) return 0;
00048    }
00049 
00050    //create an instance of the Tree player
00051    TVirtualTreePlayer *p = (TVirtualTreePlayer*)fgPlayer->New();
00052    if (p) p->SetTree(obj);
00053    fgCurrent = p;
00054    return p;
00055 }
00056 
00057 //______________________________________________________________________________
00058 TVirtualTreePlayer::~TVirtualTreePlayer()
00059 {
00060    // Common destructor.
00061 
00062    if (fgCurrent==this) {
00063       // Make sure fgCurrent does not point to a deleted player.
00064       fgCurrent=0;
00065    }
00066 }
00067 
00068 //______________________________________________________________________________
00069 TVirtualTreePlayer *TVirtualTreePlayer::GetCurrentPlayer()
00070 {
00071    // Static function: return the current player (if any)
00072 
00073    return fgCurrent;
00074 }
00075 
00076 //______________________________________________________________________________
00077 void TVirtualTreePlayer::SetPlayer(const char *player)
00078 {
00079    // Static function to set an alternative Tree player.
00080 
00081    fgPlayer = TClass::GetClass(player);
00082 }
00083 

Generated on Tue Jul 5 15:34:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1