CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/IOPool/Streamer/src/ClassFiller.cc

Go to the documentation of this file.
00001 #include "FWCore/Utilities/interface/Exception.h"
00002 #include "FWCore/Utilities/interface/EDMException.h"
00003 #include "FWCore/Utilities/interface/Algorithms.h"
00004 #include "FWCore/Utilities/interface/DebugMacros.h"
00005 #include "FWCore/Utilities/interface/ReflexTools.h"
00006 #include "Cintex/Cintex.h"
00007 #include "FWCore/PluginManager/interface/PluginCapabilities.h"
00008 
00009 
00010 #include "TClass.h"
00011 #include "G__ci.h"
00012 
00013 #include <string>
00014 #include <set>
00015 #include <algorithm>
00016 
00017 namespace edm {
00018   std::string getName(Reflex::Type& cc) {
00019     return cc.Name(Reflex::SCOPED);
00020   }
00021 
00022   void loadCap(std::string const& name) {
00023     static std::string const fname("LCGReflex/");
00024     FDEBUG(1) << "Loading dictionary for " << name << "\n";
00025     edmplugin::PluginCapabilities::get()->load(fname + name);
00026     checkDictionaries(name);
00027     if (!missingTypes().empty()) {
00028       StringSet missing = missingTypes();
00029       missingTypes().clear();
00030       for_all(missing, loadCap);
00031     }
00032   }
00033 
00034   void doBuildRealData(std::string const& name) {
00035     FDEBUG(3) << "doing BuildRealData for " << name << "\n";
00036     Reflex::Type cc = Reflex::Type::ByName(name);
00037     TClass* ttest = TClass::GetClass(getName(cc).c_str());
00038     if (ttest != 0) {
00039       ttest->BuildRealData();
00040     } else {
00041       throw edm::Exception(errors::Configuration)
00042                         << "Could not find TClass for " << name << "\n";
00043     }
00044   }
00045   // ---------------------
00046 
00047   void loadExtraClasses() {
00048     static bool done = false;
00049     if (done == false) {
00050         loadCap(std::string("edm::StreamedProduct"));
00051         loadCap(std::string("std::vector<edm::StreamedProduct>"));
00052         loadCap(std::string("edm::SendEvent"));
00053         loadCap(std::string("std::vector<edm::BranchDescription>"));
00054         loadCap(std::string("edm::SendJobHeader"));
00055     }
00056     G__SetCatchException(0);
00057     ROOT::Cintex::Cintex::Enable();
00058     done=true;
00059   }
00060 
00061   namespace {
00062     Reflex::Type const getReflectClass(std::type_info const& ti) {
00063       Reflex::Type const typ = Reflex::Type::ByTypeInfo(ti);
00064       return typ;
00065     }
00066 
00067     TClass* getRootClass(std::string const& name) {
00068       TClass* tc = TClass::GetClass(name.c_str());    
00069       
00070       // get ROOT TClass for this product
00071       // CINT::Type* cint_type = CINT::Type::get(typ_ref);
00072       // tc_ = cint_type->rootClass();
00073       // TClass* tc = TClass::GetClass(typeid(se));
00074       // tc_ = TClass::GetClass("edm::SendEvent");
00075       
00076       if(tc == 0) {
00077         throw edm::Exception(errors::Configuration,"getRootClass")
00078           << "could not find TClass for " << name
00079           << "\n";
00080       }
00081       
00082       return tc;
00083     }
00084   }
00085 
00086   // ---------------------
00087   TClass* getTClass(std::type_info const& ti) {
00088     Reflex::Type const typ = getReflectClass(ti);
00089     return getRootClass(typ.Name(Reflex::SCOPED));
00090   }
00091 }