3#include "Framework/Exception/Exception.h"
10 const std::string& purposeString) {
11 for (
const auto& [processor_rule, purpose_rule] :
rules_) {
12 if (std::regex_match(processor_name, processor_rule) and
13 std::regex_match(purposeString, purpose_rule)) {
23 const std::string& purpose_pat) {
27 if (processor_pat.empty())
return;
31 std::piecewise_construct,
32 std::forward_as_tuple(processor_pat,
33 std::regex::extended | std::regex::nosubs),
34 std::forward_as_tuple(purpose_pat.empty() ?
".*" : purpose_pat,
35 std::regex::extended | std::regex::nosubs));
36 }
catch (
const std::regex_error& e) {
39 "Invalid regex configured for the storage control listening rules: "};
41 EXCEPTION_RAISE(
"ConfigureError", msg);
50 if (not event_completed)
return false;
55 int votesKeep(0), votesDrop(0);
56 bool mustDrop{
false}, mustKeep{
false};
65 case Hint::ShouldDrop:
68 case Hint::ShouldKeep:
78 "This error comes from StorageControl and should never happen. "
79 "A storage hint should always be one of the members of the "
80 "StorageControlHint enum.");
87 if (mustDrop)
return false;
93 if (mustKeep)
return true;
99 if (votesKeep > votesDrop)
return true;
100 if (votesDrop > votesKeep)
return false;
Definitions related to event storage control from an EventProcessor.
void addHint(const std::string &processor_name, Hint hint, const std::string &purposeString)
Add a storage hint for a given processor.
std::vector< std::pair< std::regex, std::regex > > rules_
Collection of rules allowing certain processors or purposes to be considered ("listened to") during t...
bool keepEvent(bool event_completed) const
Determine if the current event should be kept, based on the defined rules.
std::vector< Hint > hints_
Collection of hints from the event processors.
void addRule(const std::string &processor_pat, const std::string &purpose_pat)
Add a listening rule.
bool defaultIsKeep_
Default state for storage control.
void resetEventState()
Reset the event-by-event state.
Hint
Hints that can be provided by processors to the storage controller.
All classes in the ldmx-sw project use this namespace.