LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::GroupSelector Class Reference

#include "GroupSelector.h"

Public Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 27 of file GroupSelector.h.

Constructor & Destructor Documentation

GroupSelector::GroupSelector ( GroupSelectorRules const &  rules,
ProductList const &  branchDescriptions 
)
explicit

Definition at line 17 of file GroupSelector.cc.

References art::GroupSelectorRules::applyToAll().

19 {
20  using BranchSelectState = GroupSelectorRules::BranchSelectState;
21 
22  // Get a BranchSelectState for each branch, containing the branch
23  // name, with its 'select bit' set to false.
24  vector<BranchSelectState> branchstates;
25  branchstates.reserve(branchDescriptions.size());
26  for (auto const& pr : branchDescriptions) {
27  branchstates.push_back(BranchSelectState{&pr.second});
28  }
29 
30  // Now apply the rules to the branchstates, in order. Each rule
31  // can override any previous rule, or all previous rules.
32  rules.applyToAll(branchstates);
33 
34  // For each of the BranchSelectStates that indicates the branch is
35  // to be selected, remember the branch. The list of branch pointers
36  // must be sorted for subsequent binary search to work.
37  for (auto const& state : branchstates) {
38  if (state.selectMe) {
39  groupsToSelect_.push_back(state.desc);
40  }
41  }
42  sort_all(groupsToSelect_);
43 }
std::vector< BranchDescription const * > groupsToSelect_
Definition: GroupSelector.h:40

Member Function Documentation

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

Definition at line 52 of file GroupSelector.cc.

Referenced by art::operator<<().

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

Definition at line 46 of file GroupSelector.cc.

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

Member Data Documentation

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

Definition at line 40 of file GroupSelector.h.


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