// Original Author: Rene Brun   05/02/97
// Modified for use in VEGA by D. Buskulic 13/05/03

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// A VViewerSelector object is used by the viewer to process              //
// set of frames and make selections.                                     //
//                                                                        //
//  The following members functions are called :                          //
//                                                                        //
//    Init:        called once per viewer session                         //
//    Begin:       called everytime a viewer loop on the data starts.     //
//                 a convenient place to create your histograms / plots.  //
//    ProcessVect: called in the viewer loop for all vectors that should  //
//                 be analyzed.                                           //
//    Terminate:   called at the end of a viewer loop.                    //
//                 a convenient place to draw/fit your histograms.        //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

#include "TROOT.h"
#include "TSystem.h"
#include "TError.h"
#include "VViewerSelectorCint.h"
#include "Api.h"

ClassImp(VViewerSelector)

//______________________________________________________________________________
VViewerSelector::VViewerSelector() : TObject()
{
   // Default selector ctor.

   mStatus = 0;
   mObject = 0;
}

//______________________________________________________________________________
VViewerSelector::~VViewerSelector()
{
   // Selector destructor.

}


//______________________________________________________________________________
 VViewerSelector *VViewerSelector::GetSelector(const char *filename)
{
//   The code in filename is loaded (interpreted or compiled , see below)
//   filename must contain a valid class implementation derived from VViewerSelector.
//   where VViewerSelector has the following member functions:
//
//    void VViewerSelector::Init():        called once per viewer session
//    void VViewerSelector::Begin():       called everytime a viewer loop on the data starts.
//                                         a convenient place to create your histograms.
//    void VViewerSelector::ProcessVect(): called in the viewer loop for all vectors that should
//                                         be analyzed.
//    void VViewerSelector::Terminate():   called at the end of a viewer loop.
//                                         a convenient place to draw/fit your histograms.
//
//   if filename is of the form file.C, the file will be interpreted.
//   if filename is of the form file.C++, the file file.C will be compiled
//      and dynamically loaded. The corresponding binary file and shared library
//      will be deleted at the end of the function.
//   if filename is of the form file.C+, the file file.C will be compiled
//      and dynamically loaded. At next call, if file.C is older than file.o
//      and file.so, the file.C is not compiled, only file.so is loaded.
//
//   The static function returns a pointer to a VViewerSelector object

   //Interpret/compile filename via CINT
   char localname[256];
   int olddispmsg = G__dispmsg;
   G__dispmsg = 0;
   sprintf(localname,".L %s",filename);
   gROOT->ProcessLine(localname);
   G__dispmsg = olddispmsg;

   //loop on all classes known to CINT to find the class on filename
   //that derives from VViewerSelector
   const char *basename = gSystem->BaseName(filename);
   if (basename==0) {
      ::Error("VViewerSelector::GetSelector","Unable to determine the classname for file %s",filename);
      return 0;
   }
   strcpy(localname,basename);
   char *IsCompiled = strchr(localname,'+');
   char *dot        = strchr(localname,'.');
   if (dot) dot[0] = 0;

   G__ClassInfo cl;
   Bool_t OK = kFALSE;
   while (cl.Next()) {
      if (strcmp(cl.Name(),localname)) continue;
      if (cl.IsBase("VViewerSelector")) OK = kTRUE;
      break;
   }
   if (!OK) {
      ::Error("VViewerSelector::GetSelector","file %s does not have a valid class deriving from VViewerSelector",filename);
      return 0;
   }

   // we can now create an instance of the class
   VViewerSelector *selector = (VViewerSelector*)cl.New();
   if (!selector || IsCompiled) return selector;
   //interpreted selector: cannot be used as such
   //create a fake selector
   VViewerSelectorCint *select = new VViewerSelectorCint();
   select->Build(selector,&cl);

   return select;
}



- ROOT page - VEGA page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to , or contact with any questions or problems regarding ROOT or VEGA.