9 #ifndef TEST_GEOMETRY_NAMESELECTOR_H 10 #define TEST_GEOMETRY_NAMESELECTOR_H 1 13 #include <initializer_list> 51 using NameList = std::initializer_list<Name_t>;
57 template <
typename LIST>
78 template <
typename LIST>
100 template <
typename... NAMES>
120 template <
typename LIST>
121 void Define(std::string set_name, LIST
const& items);
133 template <
typename... NAMES>
210 template <
typename LIST>
214 template <
typename... NAMES>
222 KnownNames_t::value_type item,
223 Response_t response)
const;
280 template <
typename LIST>
289 template <
typename LIST>
303 template <
typename... NAMES>
312 #endif // TEST_GEOMETRY_NAMESELECTOR_H void Define(std::string set_name, LIST const &items)
Defines a set.
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.
void AddToDefinition(std::string set_name, NAMES...names)
Parses a list of names and add them to the specified definition.
Response_t DefaultResponse() const
Returns the default answer for names that are not registered.
Names_t RejectedNames() const
Returns a list of names that were rejected.
void BuildNameSet(KnownNames_t &name_set, LIST const &items) const
Fills name_set with a list of items.
bool Accepted(Name_t name) const
Returns whether the name is accepted as good.
void ParseNames(NAMES...names)
Parses a list of names and adds them to the selector.
void PrintConfiguration(std::ostream &) const
Prints the configuration into a stream.
bool operator()(Name_t name) const
Returns whether the name is accepted as good (alias for accept())
Response_t LookupResponse(Name_t name) const
Returns the response for the specified name (does not register query)
void AddFirstName(KnownNames_t &name_set, Name_t name, NAMES...other_names)
Parses the first of the provided names, and recurs.
NameSelector(LIST const &items, Response_t default_answer=rsDefault)
Constructor: Parse()s the specified items.
void ParseName(Name_t name)
Parses a name and adds it to the selector.
A data structure containing how to react to a name.
Definitions_t definitions
a set of definitions
bool Rejected(Name_t name) const
Returns whether the name is rejected as bad.
Names_t AcceptedNames() const
Returns a list of names that were accepted.
void ProcessItem(KnownNames_t &name_set, Name_t item) const
Fills name_set with an item.
NameSelector(Response_t default_answer=rsDefault)
Constructor: an empty selector with a default answer for unknown names.
Response_t
Possible responses.
std::initializer_list< Name_t > NameList
std::map< Name_t, KnownNames_t > Definitions_t
Type of list of definitions.
void Parse(LIST const &items)
Parses the names in the list and adds them to the selector.
std::map< Name_t, size_t > QueryRegistry_t
Type of query counters.
bool CheckQueryRegistry() const
Checks that no known element with valid response was left unqueried.
void ClearQueryRegistry()
Reests the query registry.
KnownNames_t known_names
list of known names, with category
Response_t response
the response
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 Clear()
Erases all the names in the selector (default answer is unchanged)
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)
bool CheckQueryRegistry(std::ostream &out) const
Checks that no known element with valid response was left unqueried.
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
void SetDefaultResponse(Response_t default_answer)
Sets the default answer for names that are not registered.
Response_t Query(Name_t name) const
Returns the response for the specified name (does not throw)