00001 #include "TClass.h" 00002 #include "artdaq/ArtModules/RootDAQOutput/detail/DummyProductCache.h" 00003 #include "canvas/Utilities/Exception.h" 00004 00005 namespace art { 00006 namespace detail { 00007 00008 EDProduct const* DummyProductCache::product(std::string const& wrappedName) 00009 { 00010 auto it = dummies_.find(wrappedName); 00011 if (it == dummies_.cend()) { 00012 TClass* cp = TClass::GetClass(wrappedName.c_str()); 00013 if (cp == nullptr) { 00014 throw art::Exception(art::errors::DictionaryNotFound) 00015 << "TClass::GetClass() returned null pointer for name: " 00016 << wrappedName 00017 << '\n'; 00018 } 00019 std::unique_ptr<EDProduct> dummy {reinterpret_cast<EDProduct*>(cp->New())}; 00020 it = dummies_.emplace(wrappedName, move(dummy)).first; 00021 } 00022 return it->second.get(); 00023 } 00024 00025 } 00026 }