Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:19

0001 #include "IOPool/Streamer/interface/ClassFiller.h"
0002 #include "FWCore/Utilities/interface/EDMException.h"
0003 #include "FWCore/Utilities/interface/DebugMacros.h"
0004 #include "FWCore/Reflection/interface/DictionaryTools.h"
0005 #include "FWCore/Utilities/interface/TypeID.h"
0006 #include "FWCore/Reflection/interface/TypeWithDict.h"
0007 
0008 #include "TClass.h"
0009 
0010 #include <set>
0011 #include <algorithm>
0012 #include <iostream>
0013 
0014 namespace edm {
0015 
0016   bool loadCap(std::string const& name, std::vector<std::string>& missingDictionaries) {
0017     FDEBUG(1) << "Loading dictionary for " << name << "\n";
0018     TypeWithDict typeWithDict = TypeWithDict::byName(name);
0019     return checkClassDictionaries(missingDictionaries, name, typeWithDict);
0020   }
0021 
0022   void doBuildRealData(std::string const& name) {
0023     FDEBUG(3) << "doing BuildRealData for " << name << "\n";
0024     TClass* ttest = TClass::GetClass(name.c_str());
0025     if (ttest != nullptr) {
0026       ttest->BuildRealData();
0027     } else {
0028       throw edm::Exception(errors::Configuration) << "Could not find TClass for " << name << "\n";
0029     }
0030   }
0031   // ---------------------
0032 
0033   void loadExtraClasses() {
0034     static bool done = false;
0035     if (done == false) {
0036       std::vector<std::string> missingDictionaries;
0037       loadCap(std::string("edm::StreamedProduct"), missingDictionaries);
0038       loadCap(std::string("std::vector<edm::StreamedProduct>"), missingDictionaries);
0039       loadCap(std::string("edm::SendEvent"), missingDictionaries);
0040       loadCap(std::string("std::vector<edm::BranchDescription>"), missingDictionaries);
0041       loadCap(std::string("edm::SendJobHeader"), missingDictionaries);
0042       if (!missingDictionaries.empty()) {
0043         std::string context("Calling loadExtraClasses, checking dictionaries");
0044         throwMissingDictionariesException(missingDictionaries, context);
0045       }
0046     }
0047     done = true;
0048   }
0049 
0050   namespace {
0051     TClass* getRootClass(std::string const& name) {
0052       TClass* tc = TClass::GetClass(name.c_str());
0053 
0054       if (tc == nullptr) {
0055         throw edm::Exception(errors::Configuration, "getRootClass") << "could not find TClass for " << name << "\n";
0056       }
0057 
0058       return tc;
0059     }
0060   }  // namespace
0061 
0062   // ---------------------
0063   TClass* getTClass(std::type_info const& ti) {
0064     TypeID const type(ti);
0065     return getRootClass(type.className());
0066   }
0067 }  // namespace edm