artdaq  v3_00_01
DummyProductCache.cc
1 #include "TClass.h"
2 #include "artdaq/ArtModules/detail/DummyProductCache.h"
3 #include "canvas/Utilities/Exception.h"
4 
5 namespace art {
6  namespace detail {
7 
8  EDProduct const* DummyProductCache::product(std::string const& wrappedName)
9  {
10  auto it = dummies_.find(wrappedName);
11  if (it == dummies_.cend()) {
12  TClass* cp = TClass::GetClass(wrappedName.c_str());
13  if (cp == nullptr) {
14  throw art::Exception(art::errors::DictionaryNotFound)
15  << "TClass::GetClass() returned null pointer for name: "
16  << wrappedName
17  << '\n';
18  }
19  std::unique_ptr<EDProduct> dummy {reinterpret_cast<EDProduct*>(cp->New())};
20  it = dummies_.emplace(wrappedName, move(dummy)).first;
21  }
22  return it->second.get();
23  }
24 
25  }
26 }
EDProduct const * product(std::string const &wrappedName)
Retrieve a product handle from the cache.