LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::GroupSelector Class Reference

#include "GroupSelector.h"

Public Member Functions

 GroupSelector (GroupSelectorRules const &rules, ProductDescriptionsByID const &descriptions)
 
bool selected (BranchDescription const &desc) const
 
void print (std::ostream &os) const
 

Private Attributes

std::vector< BranchDescription const * > groupsToSelect_ {}
 

Detailed Description

Definition at line 26 of file GroupSelector.h.

Constructor & Destructor Documentation

GroupSelector::GroupSelector ( GroupSelectorRules const &  rules,
ProductDescriptionsByID const &  descriptions 
)
explicit

Definition at line 16 of file GroupSelector.cc.

References art::GroupSelectorRules::applyToAll(), and util::values().

18 {
19  using BranchSelectState = GroupSelectorRules::BranchSelectState;
20 
21  // Get a BranchSelectState for each branch, containing the branch
22  // name, with its 'select bit' set to false.
23  auto branchstates = descriptions | ::ranges::views::values |
24  ::ranges::views::transform(
25  [](auto const& pd) { return BranchSelectState{&pd}; }) |
26  ::ranges::to<std::vector>();
27 
28  // Now apply the rules to the branchstates, in order. Each rule can
29  // override any previous rule, or all previous rules.
30  rules.applyToAll(branchstates);
31 
32  // For each of the BranchSelectStates that indicates the branch is
33  // to be selected, remember the branch. The list of branch pointers
34  // must be sorted for subsequent binary search to work.
36  branchstates |
37  ::ranges::views::filter([](auto const& state) { return state.selectMe; }) |
38  ::ranges::views::transform([](auto const& state) { return state.desc; }) |
39  ::ranges::to<std::vector>();
40  sort_all(groupsToSelect_);
41 }
std::vector< BranchDescription const * > groupsToSelect_
Definition: GroupSelector.h:39
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.

Member Function Documentation

void GroupSelector::print ( std::ostream &  os) const

Definition at line 50 of file GroupSelector.cc.

Referenced by art::operator<<().

51 {
52  os << "GroupSelector at: " << static_cast<void const*>(this) << " has "
53  << groupsToSelect_.size() << " groups to select:\n";
54  for (auto const& bd_ptr : groupsToSelect_) {
55  os << bd_ptr->branchName() << '\n';
56  }
57 }
std::vector< BranchDescription const * > groupsToSelect_
Definition: GroupSelector.h:39
bool GroupSelector::selected ( BranchDescription const &  desc) const

Definition at line 44 of file GroupSelector.cc.

45 {
46  return binary_search_all(groupsToSelect_, &desc);
47 }
std::vector< BranchDescription const * > groupsToSelect_
Definition: GroupSelector.h:39

Member Data Documentation

std::vector<BranchDescription const*> art::GroupSelector::groupsToSelect_ {}
private

Definition at line 39 of file GroupSelector.h.


The documentation for this class was generated from the following files: