CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/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 TClass we need will be available
00060    fwlite::setRefStreamer(&s_getter);
00061    
00062    //Make it easy to load our headers
00063    TInterpreter* intrp= gROOT->GetInterpreter();
00064    const char* env = getenv("CMSSW_FWLITE_INCLUDE_PATH");
00065    if( 0 != env) {
00066      //this is a comma separated list
00067      const char* start = env;
00068      const char* end;
00069      do{
00070        //find end
00071        for(end=start; *end!=0 and *end != ':';++end);
00072        std::string dir(start, end);
00073        intrp->AddIncludePath(dir.c_str());
00074        start = end+1;
00075      }while(*end != 0);
00076    }
00077    
00078    bool foundCMSIncludes = false;
00079    env = getenv("CMSSW_BASE");
00080    if( 0 != env) {
00081      foundCMSIncludes = true;
00082      std::string dir(env);
00083      dir += "/src";
00084      intrp->AddIncludePath(dir.c_str());
00085    }
00086 
00087    env = getenv("CMSSW_RELEASE_BASE");
00088    if( 0 != env) {
00089      foundCMSIncludes = true;
00090      std::string dir(env);
00091      dir += "/src";
00092      intrp->AddIncludePath(dir.c_str());
00093    }
00094    if( not foundCMSIncludes) {
00095      std::cerr <<"Could not find the environment variables \n"
00096      <<"  CMSSW_BASE or\n"
00097      <<"  CMSSW_RELEASE_BASE\n"
00098      <<" therefore attempting to '#include' any CMS headers will not work"<<std::endl;
00099    }
00100    if (0 != gApplication) {
00101      gApplication->InitializeGraphics();
00102    }
00103 }
00104 
00105 void
00106 AutoLibraryLoader::loadAll()
00107 {
00108   // std::cout <<"LoadAllDictionaries"<<std::endl;
00109   enable();
00110   edm::RootAutoLibraryLoader::loadAll();
00111 }
00112