43 <<
"NameSelector: name '" << name <<
"' not configured.";
53 std::map<Response_t, Names_t> elements;
54 for (KnownNames_t::value_type
const& element:
known_names)
56 elements[element.second.response].insert(element.first);
58 size_t nKnownElements = 0;
60 auto const& selected_elements = elements[
rsAccepted];
62 nend = selected_elements.cend();
63 out <<
" accept " << selected_elements.size()
64 <<
": '" << *(iName++) <<
"'";
65 while (iName != nend) out <<
", '" << *(iName++) <<
"'";
67 nKnownElements += selected_elements.size();
70 auto const& selected_elements = elements[
rsRejected];
72 nend = selected_elements.cend();
73 out <<
" reject " << selected_elements.size()
74 <<
": '" << *(iName++) <<
"'";
75 while (iName != nend) out <<
", '" << *(iName++) <<
"'";
77 nKnownElements += selected_elements.size();
80 auto const& selected_elements = elements[
rsThrow];
82 nend = selected_elements.cend();
83 out <<
" throw on " << selected_elements.size()
84 <<
": '" << *(iName++) <<
"'";
85 while (iName != nend) out <<
", '" << *(iName++) <<
"'";
87 nKnownElements += selected_elements.size();
89 if (nKnownElements > 0) out <<
" otherwise,";
91 case rsAccepted: out <<
" accept everything";
break;
92 case rsRejected: out <<
" reject everything";
break;
93 case rsThrow: out <<
" throw on anything";
break;
94 default: out <<
" I don't know";
102 return (iResponse == known_names.end())?
118 name_set[item] = { response };
132 final_response = item.second.response;
135 switch (item.second.response) {
140 << __func__ <<
": unexpected code flow: invalid added response";
145 << __func__ <<
": unexpected code flow: invalid response";
147 InsertItem(name_set, item.first, final_response);
162 for (KnownNames_t::value_type
const& element: iDefinition->second)
172 bool bForceDef =
false;
174 if (item[0] ==
'@') {
180 if ((iDefinition ==
definitions.end()) && bForceDef) {
182 <<
"no set named '" << item <<
"'\n";
191 while (iName != nend) {
193 else iName = name_set.erase(iName);
206 names.insert(query_info.first);
214 (std::ostream* out )
const 217 for (
auto const& elem: known_names) {
218 if (query_registry[elem.first] > 0U)
continue;
220 missing.insert(elem.first);
222 if (out && !missing.empty()) {
223 (*out) << missing.size() <<
" items not queried:";
224 for (
Name_t const& name: missing) (*out) <<
" " <<
name;
227 return missing.empty();
235 if (item[0] ==
'+') {
239 if (item[0] ==
'-') {
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.
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.
static Name_t const DefaultName
name representing the default
throw art::Exception (art::errors::Configuration)
KnownNames_t known_names
list of known names, with category
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
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
static Name_t const ClearAllName
name instructing to delete all names
static std::vector< std::string > const names
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.
QTextStream & endl(QTextStream &s)
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)