File indexing completed on 2025-01-31 02:19:21
0001 #ifndef FWCore_Framework_ProductSelectorRules_h
0002 #define FWCore_Framework_ProductSelectorRules_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <iosfwd>
0013 #include <string>
0014 #include <vector>
0015
0016 #include <regex>
0017 #include "DataFormats/Provenance/interface/ProductDescriptionFwd.h"
0018
0019 namespace edm {
0020 class ProductSelector;
0021 class ParameterSet;
0022 class ParameterSetDescription;
0023
0024 class ProductSelectorRules {
0025 public:
0026 ProductSelectorRules(ParameterSet const& pset,
0027 std::string const& parameterName,
0028 std::string const& parameterOwnerName);
0029
0030
0031
0032
0033 struct BranchSelectState {
0034 edm::ProductDescription const* desc;
0035 bool selectMe;
0036
0037
0038 explicit BranchSelectState(edm::ProductDescription const* bd) : desc(bd), selectMe(false) {}
0039 };
0040
0041 bool select(edm::ProductDescription const& bd) const;
0042 void applyToAll(std::vector<BranchSelectState>& branchstates) const;
0043
0044 bool keepAll() const { return keepAll_; }
0045
0046 static void fillDescription(ParameterSetDescription& desc,
0047 char const* parameterName,
0048 std::vector<std::string> const& defaultStrings = defaultSelectionStrings());
0049
0050 static const std::vector<std::string>& defaultSelectionStrings();
0051
0052 private:
0053 class Rule {
0054 public:
0055 Rule(std::string const& s, std::string const& parameterName, std::string const& owner);
0056
0057
0058
0059 void applyToAll(std::vector<BranchSelectState>& branchstates) const;
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 void applyToOne(ProductDescription const* branch, bool& result) const;
0070
0071
0072
0073 bool appliesTo(ProductDescription const* branch) const;
0074
0075 private:
0076
0077
0078 bool selectflag_;
0079 std::regex productType_;
0080 std::regex moduleLabel_;
0081 std::regex instanceName_;
0082 std::regex processName_;
0083 };
0084
0085 private:
0086 std::vector<Rule> rules_;
0087 std::string parameterName_;
0088 std::string parameterOwnerName_;
0089 bool keepAll_;
0090 };
0091
0092 }
0093
0094 #endif