CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/FWCore/FWLite/src/AutoLibraryLoader.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     LibraryLoader
00004 // Class  :     AutoLibraryLoader
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  
00010 //         Created:  Wed Nov 30 14:55:01 EST 2005
00011 //
00012 
00013 // system include files
00014 #include <iostream>
00015 #include "TROOT.h"
00016 #include "TInterpreter.h"
00017 #include "TApplication.h"
00018 
00019 // user include files
00020 #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
00021 #include "FWCore/RootAutoLibraryLoader/interface/RootAutoLibraryLoader.h"
00022 #include "FWCore/FWLite/src/BareRootProductGetter.h"
00023 #include "FWCore/PluginManager/interface/PluginManager.h"
00024 #include "FWCore/PluginManager/interface/standard.h"
00025 
00026 #include "FWCore/FWLite/interface/setRefStreamer.h"
00027 //
00028 // constants, enums and typedefs
00029 //
00030 
00031 //
00032 // static data member definitions
00033 //
00034 
00035 bool AutoLibraryLoader::enabled_(false);
00036 
00037 //
00038 // constructors and destructor
00039 //
00040 AutoLibraryLoader::AutoLibraryLoader()
00041 {
00042 }
00043 
00044 
00045 //
00046 // member functions
00047 //
00048 
00049 void
00050 AutoLibraryLoader::enable()
00051 {
00052    if (enabled_) { return; }
00053    enabled_ = true;
00054 
00055    edmplugin::PluginManager::configure(edmplugin::standard::config());
00056    static BareRootProductGetter s_getter;
00057    edm::RootAutoLibraryLoader::enable();
00058    //this function must be called after enabling the autoloader
00059    // so that the Reflex dictionaries will be converted to ROOT 
00060    // dictionaries and the TClass we need will be available
00061    fwlite::setRefStreamer(&s_getter);
00062    
00063    //Make it easy to load our headers
00064    TInterpreter* intrp= gROOT->GetInterpreter();
00065    const char* env = getenv("CMSSW_FWLITE_INCLUDE_PATH");
00066    if( 0 != env) {
00067      //this is a comma separated list
00068      const char* start = env;
00069      const char* end = env;
00070      do{
00071        //find end
00072        for(end=start; *end!=0 and *end != ':';++end);
00073        std::string dir(start, end);
00074        intrp->AddIncludePath(dir.c_str());
00075        start = end+1;
00076      }while(*end != 0);
00077    }
00078    
00079    bool foundCMSIncludes = false;
00080    env = getenv("CMSSW_BASE");
00081    if( 0 != env) {
00082      foundCMSIncludes = true;
00083      std::string dir(env);
00084      dir += "/src";
00085      intrp->AddIncludePath(dir.c_str());
00086    }
00087 
00088    env = getenv("CMSSW_RELEASE_BASE");
00089    if( 0 != env) {
00090      foundCMSIncludes = true;
00091      std::string dir(env);
00092      dir += "/src";
00093      intrp->AddIncludePath(dir.c_str());
00094    }
00095    if( not foundCMSIncludes) {
00096      std::cerr <<"Could not find the environment variables \n"
00097      <<"  CMSSW_BASE or\n"
00098      <<"  CMSSW_RELEASE_BASE\n"
00099      <<" therefore attempting to '#include' any CMS headers will not work"<<std::endl;
00100    }
00101    if (0 != gApplication) {
00102      gApplication->InitializeGraphics();
00103    }
00104 }
00105 
00106 void
00107 AutoLibraryLoader::loadAll()
00108 {
00109   // std::cout <<"LoadAllDictionaries"<<std::endl;
00110   enable();
00111   edm::RootAutoLibraryLoader::loadAll();
00112 }
00113