ProductTables.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
7 
8 #include <array>
9 
10 using namespace art;
11 
12 namespace {
13 
14  auto
15  descriptions_for_branch_type(BranchType const bt,
16  ProductDescriptions const& descriptions)
17  {
19  for (auto const& pd : descriptions) {
20  if (pd.branchType() != bt) {
21  continue;
22  }
23  result.try_emplace(pd.productID(), pd);
24  }
25  return result;
26  }
27 
28  using ProductTables_t = std::array<ProductTable, NumBranchTypes>;
29 
30  auto
31  createProductTables(ProductDescriptions const& descriptions)
32  {
33  ProductTables_t result{{}};
34  for (std::size_t bt{}; bt < NumBranchTypes; ++bt) {
35  result[bt] = ProductTable{descriptions, static_cast<BranchType>(bt)};
36  }
37  return result;
38  }
39 
40 } // unnamed namespace
41 
43  BranchType const bt)
44  : isValid{true}
45  , descriptions{descriptions_for_branch_type(bt, descs)}
47  , viewLookup{detail::createViewLookups(descriptions)}
48 {}
49 
52 {
53  if (auto it = descriptions.find(pid); it != cend(descriptions)) {
54  return cet::make_exempt_ptr(&it->second);
55  }
56  return nullptr;
57 }
58 
61 {
62  return ProductTables{};
63 }
64 
66  : tables_{createProductTables(descriptions)}
67 {}
ProductTable()=default
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
static QCString result
std::vector< BranchDescription > ProductDescriptions
ViewLookup_t createViewLookups(ProductDescriptionsByID const &descriptions)
bt
Definition: tracks.py:83
constexpr exempt_ptr< E > make_exempt_ptr(E *) noexcept
cet::exempt_ptr< BranchDescription const > description(ProductID) const
ProductLookup_t createProductLookups(ProductDescriptionsByID const &descriptions)
ViewLookup_t viewLookup
Definition: ProductTables.h:29
static ProductTables invalid()
ProductTables()=default
BranchType
Definition: BranchType.h:20
std::map< ProductID, BranchDescription > ProductDescriptionsByID
ProductLookup_t productLookup
Definition: ProductTables.h:28