44 <<
"NameSelector: name '" << name <<
"' not configured.";
54 std::map<Response_t, Names_t> elements;
55 for (KnownNames_t::value_type
const& element :
known_names)
56 if (element.first !=
DefaultName) elements[element.second.response].insert(element.first);
58 size_t nKnownElements = 0;
60 auto const& selected_elements = elements[
rsAccepted];
62 out <<
" accept " << selected_elements.size() <<
": '" << *(iName++) <<
"'";
64 out <<
", '" << *(iName++) <<
"'";
66 nKnownElements += selected_elements.size();
69 auto const& selected_elements = elements[
rsRejected];
71 out <<
" reject " << selected_elements.size() <<
": '" << *(iName++) <<
"'";
73 out <<
", '" << *(iName++) <<
"'";
75 nKnownElements += selected_elements.size();
78 auto const& selected_elements = elements[
rsThrow];
80 out <<
" throw on " << selected_elements.size() <<
": '" << *(iName++) <<
"'";
82 out <<
", '" << *(iName++) <<
"'";
84 nKnownElements += selected_elements.size();
86 if (nKnownElements > 0) out <<
" otherwise,";
88 case rsAccepted: out <<
" accept everything";
break;
89 case rsRejected: out <<
" reject everything";
break;
90 case rsThrow: out <<
" throw on anything";
break;
91 default: out <<
" I don't know";
112 name_set[item] = {response};
117 KnownNames_t::value_type item,
125 final_response = item.second.response;
128 switch (item.second.response) {
133 << __func__ <<
": unexpected code flow: invalid added response";
138 << __func__ <<
": unexpected code flow: invalid response";
140 InsertItem(name_set, item.first, final_response);
156 for (KnownNames_t::value_type
const& element : iDefinition->second)
164 bool bForceDef =
false;
166 if (item[0] ==
'@') {
172 if ((iDefinition ==
definitions.end()) && bForceDef) {
182 while (iName != nend) {
186 iName = name_set.erase(iName);
197 names.insert(query_info.first);
209 missing.insert(elem.first);
211 if (out && !missing.empty()) {
212 (*out) << missing.size() <<
" items not queried:";
213 for (
Name_t const& name : missing)
214 (*out) <<
" " << name;
217 return missing.empty();
224 if (item[0] ==
'+') {
228 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.
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
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)