CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/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 #include "DataFormats/Common/interface/CacheStreamers.h"
00026 
00027 #include "FWCore/FWLite/interface/setRefStreamer.h"
00028 //
00029 // constants, enums and typedefs
00030 //
00031 
00032 //
00033 // static data member definitions
00034 //
00035 
00036 bool AutoLibraryLoader::enabled_(false);
00037 
00038 //
00039 // constructors and destructor
00040 //
00041 AutoLibraryLoader::AutoLibraryLoader()
00042 {
00043 }
00044 
00045 
00046 //
00047 // member functions
00048 //
00049 
00050 void
00051 AutoLibraryLoader::enable()
00052 {
00053    if (enabled_) { return; }
00054    enabled_ = true;
00055 
00056    edmplugin::PluginManager::configure(edmplugin::standard::config());
00057    static BareRootProductGetter s_getter;
00058    edm::RootAutoLibraryLoader::enable();
00059    edm::setCacheStreamers();
00060    //this function must be called after enabling the autoloader
00061    // so that the Reflex dictionaries will be converted to ROOT 
00062    // dictionaries and the TClass we need will be available
00063    fwlite::setRefStreamer(&s_getter);
00064    
00065    //Make it easy to load our headers
00066    TInterpreter* intrp= gROOT->GetInterpreter();
00067    const char* env = getenv("CMSSW_FWLITE_INCLUDE_PATH");
00068    if( 0 != env) {
00069      //this is a comma separated list
00070      const char* start = env;
00071      const char* end = env;
00072      do{
00073        //find end
00074        for(end=start; *end!=0 and *end != ':';++end);
00075        std::string dir(start, end);
00076        intrp->AddIncludePath(dir.c_str());
00077        start = end+1;
00078      }while(*end != 0);
00079    }
00080    
00081    bool foundCMSIncludes = false;
00082    env = getenv("CMSSW_BASE");
00083    if( 0 != env) {
00084      foundCMSIncludes = true;
00085      std::string dir(env);
00086      dir += "/src";
00087      intrp->AddIncludePath(dir.c_str());
00088    }
00089 
00090    env = getenv("CMSSW_RELEASE_BASE");
00091    if( 0 != env) {
00092      foundCMSIncludes = true;
00093      std::string dir(env);
00094      dir += "/src";
00095      intrp->AddIncludePath(dir.c_str());
00096    }
00097    if( not foundCMSIncludes) {
00098      std::cerr <<"Could not find the environment variables \n"
00099      <<"  CMSSW_BASE or\n"
00100      <<"  CMSSW_RELEASE_BASE\n"
00101      <<" therefore attempting to '#include' any CMS headers will not work"<<std::endl;
00102    }
00103    if (0 != gApplication) {
00104      gApplication->InitializeGraphics();
00105    }
00106 }
00107 
00108 void
00109 AutoLibraryLoader::loadAll()
00110 {
00111   // std::cout <<"LoadAllDictionaries"<<std::endl;
00112   enable();
00113   edm::RootAutoLibraryLoader::loadAll();
00114 }
00115