42 <<
"NameSelector: name '" << name <<
"' not configured.";
52 std::map<Response_t, Names_t> elements;
53 for (KnownNames_t::value_type
const& element:
known_names)
55 elements[element.second.response].insert(element.first);
57 size_t nKnownElements = 0;
59 auto const& selected_elements = elements[
rsAccepted];
61 nend = selected_elements.cend();
62 out <<
" accept " << selected_elements.size()
63 <<
": '" << *(iName++) <<
"'";
64 while (iName != nend) out <<
", '" << *(iName++) <<
"'";
66 nKnownElements += selected_elements.size();
69 auto const& selected_elements = elements[
rsRejected];
71 nend = selected_elements.cend();
72 out <<
" reject " << selected_elements.size()
73 <<
": '" << *(iName++) <<
"'";
74 while (iName != nend) out <<
", '" << *(iName++) <<
"'";
76 nKnownElements += selected_elements.size();
78 if (!elements[
rsThrow].empty()) {
79 auto const& selected_elements = elements[
rsThrow];
81 nend = selected_elements.cend();
82 out <<
" throw on " << selected_elements.size()
83 <<
": '" << *(iName++) <<
"'";
84 while (iName != nend) out <<
", '" << *(iName++) <<
"'";
86 nKnownElements += selected_elements.size();
88 if (nKnownElements > 0) out <<
" otherwise,";
90 case rsAccepted: out <<
" accept everything";
break;
91 case rsRejected: out <<
" reject everything";
break;
92 case rsThrow: out <<
" throw on anything";
break;
93 default: out <<
" I don't know";
117 name_set[item] = { response };
131 final_response = item.second.response;
134 switch (item.second.response) {
139 << __func__ <<
": unexpected code flow: invalid added response";
144 << __func__ <<
": unexpected code flow: invalid response";
146 InsertItem(name_set, item.first, final_response);
161 for (KnownNames_t::value_type
const& element: iDefinition->second)
171 bool bForceDef =
false;
173 if (item[0] ==
'@') {
179 if ((iDefinition ==
definitions.end()) && bForceDef) {
181 <<
"no set named '" << item <<
"'\n";
190 while (iName != nend) {
192 else iName = name_set.erase(iName);
205 names.insert(query_info.first);
213 (std::ostream* out )
const 219 missing.insert(elem.first);
221 if (out && !missing.empty()) {
222 (*out) << missing.size() <<
" items not queried:";
223 for (
Name_t const& name: missing) (*out) <<
" " << name;
226 return missing.empty();
234 if (item[0] ==
'+') {
238 if (item[0] ==
'-') {
static Name_t const ClearAllName
name instructing to delete all names
std::set< Name_t > Names_t
list of names
bool DoCheckQueryRegistry(std::ostream *out=nullptr) const
static Response_t ParseMode(Name_t &item, Response_t default_answer=rsAccepted)
Strips the mode specifier from item and returns the insertion mode.
Definitions_t::const_iterator FindDefinition(Name_t &item) const
Strips set specifier and returns iterator to the definition, or end()
std::map< Name_t, NameResponse_t > KnownNames_t
Information about known names.
Response_t DefaultResponse() const
Returns the default answer for names that are not registered.
bool Accepted(Name_t name) const
Returns whether the name is accepted as good.
void PrintConfiguration(std::ostream &) const
Prints the configuration into a stream.
Response_t LookupResponse(Name_t name) const
Returns the response for the specified name (does not register query)
void ParseName(Name_t name)
Parses a name and adds it to the selector.
A class providing a selection list.
Definitions_t definitions
a set of definitions
void ProcessItem(KnownNames_t &name_set, Name_t item) const
Fills name_set with an item.
Response_t
Possible responses.
KnownNames_t known_names
list of known names, with category
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
static Name_t const DefaultName
name representing the default
Names_t QueriedWithStatus(Response_t answer) const
Returns the list of queried names whose response is answer.
void ClearNameSet(KnownNames_t &name_set) const
Erases all the names in the selector (default answer is unchanged)
QueryRegistry_t query_registry
record of all the queries
throw art::Exception (art::errors::Configuration)
void InsertItem(KnownNames_t &name_set, Name_t item, Response_t response) const
Adds an item to the name set, working in specified mode.
std::string Name_t
type representing a name
Response_t Query(Name_t name) const
Returns the response for the specified name (does not throw)