All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
testing::NameSelector Class Reference

Manages a set of names. More...

#include <NameSelector.h>

Classes

struct  NameResponse_t
 A data structure containing how to react to a name. More...
 

Public Types

enum  Response_t { rsRejected, rsAccepted, rsThrow, rsDefault = rsAccepted }
 Possible responses. More...
 
using Name_t = std::string
 type representing a name More...
 
using Names_t = std::set< Name_t >
 list of names More...
 
using NameList = std::initializer_list< Name_t >
 

Public Member Functions

 NameSelector (Response_t default_answer=rsDefault)
 Constructor: an empty selector with a default answer for unknown names. More...
 
template<typename LIST >
 NameSelector (LIST const &items, Response_t default_answer=rsDefault)
 Constructor: Parse()s the specified items. More...
 
void SetDefaultResponse (Response_t default_answer)
 Sets the default answer for names that are not registered. More...
 
template<typename LIST >
void Parse (LIST const &items)
 Parses the names in the list and adds them to the selector. More...
 
void ParseName (Name_t name)
 Parses a name and adds it to the selector. More...
 
template<typename... NAMES>
void ParseNames (NAMES...names)
 Parses a list of names and adds them to the selector. More...
 
void Clear ()
 Erases all the names in the selector (default answer is unchanged) More...
 
template<typename LIST >
void Define (std::string set_name, LIST const &items)
 Defines a set. More...
 
template<typename... NAMES>
void AddToDefinition (std::string set_name, NAMES...names)
 Parses a list of names and add them to the specified definition. More...
 
Response_t Query (Name_t name) const
 Returns the response for the specified name (does not throw) More...
 
bool Accepted (Name_t name) const
 Returns whether the name is accepted as good. More...
 
bool Rejected (Name_t name) const
 Returns whether the name is rejected as bad. More...
 
Response_t DefaultResponse () const
 Returns the default answer for names that are not registered. More...
 
bool operator() (Name_t name) const
 Returns whether the name is accepted as good (alias for accept()) More...
 
void PrintConfiguration (std::ostream &) const
 Prints the configuration into a stream. More...
 
Names_t AcceptedNames () const
 Returns a list of names that were accepted. More...
 
Names_t RejectedNames () const
 Returns a list of names that were rejected. More...
 
void ClearQueryRegistry ()
 Reests the query registry. More...
 
template<>
void AddFirstName (KnownNames_t &name_set, Name_t name)
 
bool CheckQueryRegistry () const
 Checks that no known element with valid response was left unqueried. More...
 
bool CheckQueryRegistry (std::ostream &out) const
 

Static Public Attributes

static Name_t const DefaultName = "*"
 name representing the default More...
 
static Name_t const ClearAllName = "!"
 name instructing to delete all names More...
 

Protected Types

using KnownNames_t = std::map< Name_t, NameResponse_t >
 Information about known names. More...
 
using Definitions_t = std::map< Name_t, KnownNames_t >
 Type of list of definitions. More...
 
using QueryRegistry_t = std::map< Name_t, size_t >
 Type of query counters. More...
 

Protected Member Functions

Response_t LookupResponse (Name_t name) const
 Returns the response for the specified name (does not register query) More...
 
template<typename LIST >
void BuildNameSet (KnownNames_t &name_set, LIST const &items) const
 Fills name_set with a list of items. More...
 
template<typename... NAMES>
void AddFirstName (KnownNames_t &name_set, Name_t name, NAMES...other_names)
 Parses the first of the provided names, and recurs. More...
 
void InsertItem (KnownNames_t &name_set, Name_t item, Response_t response) const
 Adds an item to the name set, working in specified mode. More...
 
void InsertItem (KnownNames_t &name_set, KnownNames_t::value_type item, Response_t response) const
 Adds an item with response to the name set, working in specified mode. More...
 
void ProcessItem (KnownNames_t &name_set, Name_t item) const
 Fills name_set with an item. More...
 
Definitions_t::const_iterator FindDefinition (Name_t &item) const
 Strips set specifier and returns iterator to the definition, or end() More...
 
void ClearNameSet (KnownNames_t &name_set) const
 Erases all the names in the selector (default answer is unchanged) More...
 
Names_t QueriedWithStatus (Response_t answer) const
 Returns the list of queried names whose response is answer. More...
 
bool DoCheckQueryRegistry (std::ostream *out=nullptr) const
 

Static Protected Member Functions

static Response_t ParseMode (Name_t &item, Response_t default_answer=rsAccepted)
 Strips the mode specifier from item and returns the insertion mode. More...
 

Protected Attributes

KnownNames_t known_names
 list of known names, with category More...
 
Definitions_t definitions
 a set of definitions More...
 
QueryRegistry_t query_registry
 record of all the queries More...
 

Detailed Description

Manages a set of names.

This class contains a set of names to be "accepted" and a set of names to be "rejected". Queries on unknown names will generate a default answer that can be acceptance, rejection or an exception.

The class is initialized by a list of strings following the convention detailed in ProcessItem(). The default answer is set on construction, but it can be overridden to a "reject by default" using a specific identifier.

Definition at line 37 of file NameSelector.h.

Member Typedef Documentation

Type of list of definitions.

Definition at line 181 of file NameSelector.h.

Information about known names.

Definition at line 178 of file NameSelector.h.

using testing::NameSelector::Name_t = std::string

type representing a name

Definition at line 40 of file NameSelector.h.

using testing::NameSelector::NameList = std::initializer_list<Name_t>

Definition at line 52 of file NameSelector.h.

list of names

Definition at line 41 of file NameSelector.h.

using testing::NameSelector::QueryRegistry_t = std::map<Name_t, size_t>
protected

Type of query counters.

Definition at line 184 of file NameSelector.h.

Member Enumeration Documentation

Possible responses.

Enumerator
rsRejected 

rejected

rsAccepted 

accepted

rsThrow 

throw art::Exception (art::errors::Configuration)

rsDefault 

Definition at line 44 of file NameSelector.h.

44  {
45  rsRejected, ///< rejected
46  rsAccepted, ///< accepted
47  rsThrow, ///< throw art::Exception (art::errors::Configuration)
48  rsDefault = rsAccepted
49  } Response_t;
Response_t
Possible responses.
Definition: NameSelector.h:44
throw art::Exception (art::errors::Configuration)
Definition: NameSelector.h:47

Constructor & Destructor Documentation

testing::NameSelector::NameSelector ( Response_t  default_answer = rsDefault)
inline

Constructor: an empty selector with a default answer for unknown names.

Definition at line 56 of file NameSelector.h.

57  { SetDefaultResponse(default_answer); }
void SetDefaultResponse(Response_t default_answer)
Sets the default answer for names that are not registered.
Definition: NameSelector.h:66
template<typename LIST >
testing::NameSelector::NameSelector ( LIST const &  items,
Response_t  default_answer = rsDefault 
)
inline

Constructor: Parse()s the specified items.

Definition at line 61 of file NameSelector.h.

62  : NameSelector(default_answer)
63  { Parse(items); }
NameSelector(Response_t default_answer=rsDefault)
Constructor: an empty selector with a default answer for unknown names.
Definition: NameSelector.h:56
void Parse(LIST const &items)
Parses the names in the list and adds them to the selector.
Definition: NameSelector.h:78

Member Function Documentation

bool testing::NameSelector::Accepted ( Name_t  name) const

Returns whether the name is accepted as good.

Definition at line 39 of file NameSelector.cxx.

39  {
40  Response_t response = Query(name);
41  if (response == rsThrow) {
42  throw art::Exception(art::errors::Configuration)
43  << "NameSelector: name '" << name << "' not configured.";
44  }
45  return response == rsAccepted;
46  } // NameSelector::Accepted()
Response_t
Possible responses.
Definition: NameSelector.h:44
throw art::Exception (art::errors::Configuration)
Definition: NameSelector.h:47
then echo fcl name
Response_t Query(Name_t name) const
Returns the response for the specified name (does not throw)
Names_t testing::NameSelector::AcceptedNames ( ) const
inline

Returns a list of names that were accepted.

Definition at line 151 of file NameSelector.h.

151 { return QueriedWithStatus(rsAccepted); }
Names_t QueriedWithStatus(Response_t answer) const
Returns the list of queried names whose response is answer.
void testing::NameSelector::AddFirstName ( KnownNames_t name_set,
Name_t  name 
)

Definition at line 109 of file NameSelector.cxx.

109  {
110  ProcessItem(name_set, name);
111  } // NameSelector::AddFirstName<>()
void ProcessItem(KnownNames_t &name_set, Name_t item) const
Fills name_set with an item.
then echo fcl name
template<typename... NAMES>
void testing::NameSelector::AddFirstName ( KnownNames_t name_set,
Name_t  name,
NAMES...  other_names 
)
protected

Parses the first of the provided names, and recurs.

Definition at line 307 of file NameSelector.h.

308 {
309  AddFirstName(name_set, name);
310  AddFirstName(name_set, other_names...);
311 } // testing::NameSelector::AddFirstName()
void AddFirstName(KnownNames_t &name_set, Name_t name, NAMES...other_names)
Parses the first of the provided names, and recurs.
Definition: NameSelector.h:307
then echo fcl name
template<typename... NAMES>
void testing::NameSelector::AddToDefinition ( std::string  set_name,
NAMES...  names 
)
inline

Parses a list of names and add them to the specified definition.

Template Parameters
NAMESName_t-compatible types
Parameters
set_namename of the set to be defined
namesthe definitions to be used

Specified items are processed with ProcessItem(); the result is added to the set with the specified name. If a set with that name does not exist, it's created empty.

Definition at line 128 of file NameSelector.h.

129  { AddFirstName(definitions[set_name], names...); }
void AddFirstName(KnownNames_t &name_set, Name_t name, NAMES...other_names)
Parses the first of the provided names, and recurs.
Definition: NameSelector.h:307
Definitions_t definitions
a set of definitions
Definition: NameSelector.h:188
static const std::vector< std::string > names
template<typename LIST >
void testing::NameSelector::BuildNameSet ( KnownNames_t name_set,
LIST const &  items 
) const
protected

Fills name_set with a list of items.

Template Parameters
LISTtype of container of name directives
Parameters
name_setset to be modified
itemsname directives

A name set is modified according to the instructions in each of the items. The items are parsed sequentially, and their order matters for the final result. Each item is processed through ProcessItem().

Definition at line 292 of file NameSelector.h.

293 {
294  for (Name_t item: items) ProcessItem(name_set, item);
295 } // testing::NameSelector::BuildNameSet()
void ProcessItem(KnownNames_t &name_set, Name_t item) const
Fills name_set with an item.
std::string Name_t
type representing a name
Definition: NameSelector.h:40
bool testing::NameSelector::CheckQueryRegistry ( ) const
inline

Checks that no known element with valid response was left unqueried.

Definition at line 161 of file NameSelector.h.

161 { return DoCheckQueryRegistry(); }
bool DoCheckQueryRegistry(std::ostream *out=nullptr) const
bool testing::NameSelector::CheckQueryRegistry ( std::ostream &  out) const
inline

Definition at line 162 of file NameSelector.h.

163  { return DoCheckQueryRegistry(&out); }
bool DoCheckQueryRegistry(std::ostream *out=nullptr) const
void testing::NameSelector::Clear ( )
inline

Erases all the names in the selector (default answer is unchanged)

Definition at line 101 of file NameSelector.h.

KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
void ClearNameSet(KnownNames_t &name_set) const
Erases all the names in the selector (default answer is unchanged)
void testing::NameSelector::ClearNameSet ( KnownNames_t name_set) const
protected

Erases all the names in the selector (default answer is unchanged)

Definition at line 189 of file NameSelector.cxx.

189  {
190  KnownNames_t::iterator iName = name_set.begin(), nend = name_set.end();
191  while (iName != nend) {
192  if (iName->first == DefaultName) ++iName;
193  else iName = name_set.erase(iName);
194  } // while
195  } // NameSelector::ClearNameSet()
static Name_t const DefaultName
name representing the default
Definition: NameSelector.h:167
void testing::NameSelector::ClearQueryRegistry ( )
inline

Reests the query registry.

Definition at line 157 of file NameSelector.h.

157 { query_registry.clear(); }
QueryRegistry_t query_registry
record of all the queries
Definition: NameSelector.h:190
Response_t testing::NameSelector::DefaultResponse ( ) const
inline

Returns the default answer for names that are not registered.

Definition at line 141 of file NameSelector.h.

142  { return known_names.find(DefaultName)->second.response; }
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
static Name_t const DefaultName
name representing the default
Definition: NameSelector.h:167
template<typename LIST >
void testing::NameSelector::Define ( std::string  set_name,
LIST const &  items 
)

Defines a set.

Template Parameters
LISTtype of list of strings
Parameters
set_namename of the set to be defined
itemsthe definitions to be used

Specified items are processed with BuildSet(); the result is stored as a set with the specified name. If a set with that name already exists, it's replaced and the old one is lost.

Definition at line 282 of file NameSelector.h.

282  {
283  KnownNames_t name_set;
284  BuildNameSet(name_set, items);
285  definitions[set_name] = std::move(name_set);
286 } // testing::NameSelector::Define()
std::map< Name_t, NameResponse_t > KnownNames_t
Information about known names.
Definition: NameSelector.h:178
void BuildNameSet(KnownNames_t &name_set, LIST const &items) const
Fills name_set with a list of items.
Definition: NameSelector.h:292
Definitions_t definitions
a set of definitions
Definition: NameSelector.h:188
bool testing::NameSelector::DoCheckQueryRegistry ( std::ostream *  out = nullptr) const
protected

Definition at line 214 of file NameSelector.cxx.

215  {
216  Names_t missing;
217  for (auto const& elem: known_names) {
218  if (query_registry[elem.first] > 0U) continue;
219  if (elem.first == DefaultName) continue;
220  missing.insert(elem.first);
221  } // for
222  if (out && !missing.empty()) {
223  (*out) << missing.size() << " items not queried:";
224  for (Name_t const& name: missing) (*out) << " " << name;
225  (*out) << std::endl;
226  }
227  return missing.empty();
228  } // NameSelector::CheckQueryRegistry()
std::set< Name_t > Names_t
list of names
Definition: NameSelector.h:41
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
static Name_t const DefaultName
name representing the default
Definition: NameSelector.h:167
QueryRegistry_t query_registry
record of all the queries
Definition: NameSelector.h:190
then echo fcl name
std::string Name_t
type representing a name
Definition: NameSelector.h:40
NameSelector::Definitions_t::const_iterator testing::NameSelector::FindDefinition ( Name_t item) const
protected

Strips set specifier and returns iterator to the definition, or end()

Definition at line 170 of file NameSelector.cxx.

171  {
172  bool bForceDef = false;
173  if (!item.empty()) {
174  if (item[0] == '@') {
175  bForceDef = true;
176  item.erase(0, 1);
177  }
178  }
179  Definitions_t::const_iterator iDefinition = definitions.find(item);
180  if ((iDefinition == definitions.end()) && bForceDef) {
181  throw art::Exception(art::errors::LogicError)
182  << "no set named '" << item << "'\n";
183  }
184  return iDefinition;
185  } // NameSelector::FindDefinition()
Definitions_t definitions
a set of definitions
Definition: NameSelector.h:188
void testing::NameSelector::InsertItem ( KnownNames_t name_set,
Name_t  item,
Response_t  response 
) const
protected

Adds an item to the name set, working in specified mode.

Definition at line 116 of file NameSelector.cxx.

117  {
118  name_set[item] = { response };
119  } // NameSelector::InsertItem()
void testing::NameSelector::InsertItem ( KnownNames_t name_set,
KnownNames_t::value_type  item,
Response_t  response 
) const
protected

Adds an item with response to the name set, working in specified mode.

Definition at line 124 of file NameSelector.cxx.

126  {
127  // response is the instruction we have about how to add the item
128  // item.second.response is what the default answer for that item is
129  Response_t final_response; // uninitialized
130  switch (response) {
131  case rsAccepted:
132  final_response = item.second.response; // respect the response
133  break;
134  case rsRejected: // flip the response
135  switch (item.second.response) {
136  case rsAccepted: final_response = rsRejected; break;
137  case rsRejected: final_response = rsAccepted; break;
138  default:
139  throw art::Exception(art::errors::LogicError)
140  << __func__ << ": unexpected code flow: invalid added response";
141  } // switch item response
142  break;
143  default:
144  throw art::Exception(art::errors::LogicError)
145  << __func__ << ": unexpected code flow: invalid response";
146  } // switch response
147  InsertItem(name_set, item.first, final_response);
148  } // NameSelector::InsertItem(KnownNames_t::value_type)
Response_t
Possible responses.
Definition: NameSelector.h:44
void InsertItem(KnownNames_t &name_set, Name_t item, Response_t response) const
Adds an item to the name set, working in specified mode.
NameSelector::Response_t testing::NameSelector::LookupResponse ( Name_t  name) const
protected

Returns the response for the specified name (does not register query)

Definition at line 100 of file NameSelector.cxx.

100  {
101  KnownNames_t::const_iterator iResponse = known_names.find(name);
102  return (iResponse == known_names.end())?
103  DefaultResponse(): iResponse->second.response;
104  } // NameSelector::LookupResponse()
Response_t DefaultResponse() const
Returns the default answer for names that are not registered.
Definition: NameSelector.h:141
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
then echo fcl name
bool testing::NameSelector::operator() ( Name_t  name) const
inline

Returns whether the name is accepted as good (alias for accept())

Definition at line 145 of file NameSelector.h.

145 { return Accepted(name); }
bool Accepted(Name_t name) const
Returns whether the name is accepted as good.
then echo fcl name
template<typename LIST >
void testing::NameSelector::Parse ( LIST const &  items)
inline

Parses the names in the list and adds them to the selector.

Template Parameters
LISTtype of list of strings
Parameters
itemsthe definitions to be used

Specified items are processed with ProcessItem() and the current set is modified.

Definition at line 78 of file NameSelector.h.

78 { BuildNameSet(known_names, items); }
void BuildNameSet(KnownNames_t &name_set, LIST const &items) const
Fills name_set with a list of items.
Definition: NameSelector.h:292
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
NameSelector::Response_t testing::NameSelector::ParseMode ( Name_t item,
Response_t  default_answer = rsAccepted 
)
staticprotected

Strips the mode specifier from item and returns the insertion mode.

Definition at line 233 of file NameSelector.cxx.

234  {
235  if (item[0] == '+') {
236  item.erase(0, 1);
237  return rsAccepted;
238  }
239  if (item[0] == '-') {
240  item.erase(0, 1);
241  return rsRejected;
242  }
243  return default_mode;
244  } // NameSelector::ParseMode()
void testing::NameSelector::ParseName ( Name_t  name)

Parses a name and adds it to the selector.

Parameters
namename specification to be parsed

The name is processed with ProcessItem() and the current set is modified.

Definition at line 26 of file NameSelector.cxx.

26  {
28  } // NameSelector::ParseName()
void ProcessItem(KnownNames_t &name_set, Name_t item) const
Fills name_set with an item.
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
then echo fcl name
template<typename... NAMES>
void testing::NameSelector::ParseNames ( NAMES...  names)
inline

Parses a list of names and adds them to the selector.

Template Parameters
NAMESName_t-compatible types
Parameters
namesthe definitions to be used

Specified items are processed with ProcessItem() and modify the current set.

Definition at line 98 of file NameSelector.h.

void AddFirstName(KnownNames_t &name_set, Name_t name, NAMES...other_names)
Parses the first of the provided names, and recurs.
Definition: NameSelector.h:307
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
static const std::vector< std::string > names
void testing::NameSelector::PrintConfiguration ( std::ostream &  out) const

Prints the configuration into a stream.

Definition at line 50 of file NameSelector.cxx.

50  {
51 
52  // resort the known elements
53  std::map<Response_t, Names_t> elements;
54  for (KnownNames_t::value_type const& element: known_names)
55  if (element.first != DefaultName)
56  elements[element.second.response].insert(element.first);
57 
58  size_t nKnownElements = 0;
59  if (!elements[rsAccepted].empty()) {
60  auto const& selected_elements = elements[rsAccepted];
61  Names_t::const_iterator iName = selected_elements.cbegin(),
62  nend = selected_elements.cend();
63  out << " accept " << selected_elements.size()
64  << ": '" << *(iName++) << "'";
65  while (iName != nend) out << ", '" << *(iName++) << "'";
66  out << ";";
67  nKnownElements += selected_elements.size();
68  } // if accepting anything
69  if (!elements[rsRejected].empty()) {
70  auto const& selected_elements = elements[rsRejected];
71  Names_t::const_iterator iName = selected_elements.cbegin(),
72  nend = selected_elements.cend();
73  out << " reject " << selected_elements.size()
74  << ": '" << *(iName++) << "'";
75  while (iName != nend) out << ", '" << *(iName++) << "'";
76  out << ";";
77  nKnownElements += selected_elements.size();
78  } // if accepting anything
79  if (!elements[rsThrow].empty()) {
80  auto const& selected_elements = elements[rsThrow];
81  Names_t::const_iterator iName = selected_elements.cbegin(),
82  nend = selected_elements.cend();
83  out << " throw on " << selected_elements.size()
84  << ": '" << *(iName++) << "'";
85  while (iName != nend) out << ", '" << *(iName++) << "'";
86  out << ";";
87  nKnownElements += selected_elements.size();
88  } // if accepting anything
89  if (nKnownElements > 0) out << " otherwise,";
90  switch (DefaultResponse()) {
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";
95  } // switch
96  } // NameSelector::PrintConfiguration()
Response_t DefaultResponse() const
Returns the default answer for names that are not registered.
Definition: NameSelector.h:141
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
static Name_t const DefaultName
name representing the default
Definition: NameSelector.h:167
throw art::Exception (art::errors::Configuration)
Definition: NameSelector.h:47
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
void testing::NameSelector::ProcessItem ( KnownNames_t name_set,
Name_t  item 
) const
protected

Fills name_set with an item.

Parameters
name_setset to be modified
itemname directive

A name set is modified according to the instruction in the items. An identifier may represent either a single literal item or a set name; it can appear in two forms:

  • "\@identifier": always denotes a set named "identifier"
  • "identifier": if a set named "identifier" exists, the name represents that set; otherwise, it represents a literal item named "identifier"

The directives in items are:

  • "identifier": the element or elements represented by the identifier replace the content of the current set
  • "+identifier": the element or elements represented by the identifier are added to the current set; if the identifier is a predefined set, the elements accepted in the set are added as accepted here, the ones rejected are added as rejected here
  • "-identifier": the element or elements represented by the identifier; if the identifier is a predefined set, the elements accepted in the set are added as rejected here, the ones rejected are added as accepted here

Definition at line 152 of file NameSelector.cxx.

152  {
153  // special: if this name is actually a directive to clear all
154  if (item == ClearAllName) {
155  ClearNameSet(name_set); // clear everything except the default
156  return;
157  } // if clear all
158  Response_t response = ParseMode(item);
159  Definitions_t::const_iterator iDefinition = FindDefinition(item);
160  if (iDefinition == definitions.end()) InsertItem(name_set, item, response);
161  else {
162  for (KnownNames_t::value_type const& element: iDefinition->second)
163  InsertItem(name_set, element, response);
164  }
165  } // NameSelector::ProcessItem()
static Name_t const ClearAllName
name instructing to delete all names
Definition: NameSelector.h:168
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()
Definitions_t definitions
a set of definitions
Definition: NameSelector.h:188
Response_t
Possible responses.
Definition: NameSelector.h:44
void ClearNameSet(KnownNames_t &name_set) const
Erases all the names in the selector (default answer is unchanged)
void InsertItem(KnownNames_t &name_set, Name_t item, Response_t response) const
Adds an item to the name set, working in specified mode.
NameSelector::Names_t testing::NameSelector::QueriedWithStatus ( Response_t  answer) const
protected

Returns the list of queried names whose response is answer.

Definition at line 200 of file NameSelector.cxx.

201  {
203  for (auto const& query_info: query_registry) {
204  if (query_info.first == DefaultName) continue;
205  if (LookupResponse(query_info.first) != answer) continue;
206  names.insert(query_info.first);
207  } // for
208  return names;
209  } // NameSelector::QueriedWithStatus()
std::set< Name_t > Names_t
list of names
Definition: NameSelector.h:41
Response_t LookupResponse(Name_t name) const
Returns the response for the specified name (does not register query)
static const std::vector< std::string > names
static Name_t const DefaultName
name representing the default
Definition: NameSelector.h:167
QueryRegistry_t query_registry
record of all the queries
Definition: NameSelector.h:190
NameSelector::Response_t testing::NameSelector::Query ( Name_t  name) const

Returns the response for the specified name (does not throw)

Definition at line 32 of file NameSelector.cxx.

32  {
33  ++(query_registry[name]);
34  return LookupResponse(name);
35  } // NameSelector::Query()
Response_t LookupResponse(Name_t name) const
Returns the response for the specified name (does not register query)
QueryRegistry_t query_registry
record of all the queries
Definition: NameSelector.h:190
then echo fcl name
bool testing::NameSelector::Rejected ( Name_t  name) const
inline

Returns whether the name is rejected as bad.

Definition at line 138 of file NameSelector.h.

138 { return !Accepted(name); }
bool Accepted(Name_t name) const
Returns whether the name is accepted as good.
then echo fcl name
Names_t testing::NameSelector::RejectedNames ( ) const
inline

Returns a list of names that were rejected.

Definition at line 154 of file NameSelector.h.

154 { return QueriedWithStatus(rsRejected); }
Names_t QueriedWithStatus(Response_t answer) const
Returns the list of queried names whose response is answer.
void testing::NameSelector::SetDefaultResponse ( Response_t  default_answer)
inline

Sets the default answer for names that are not registered.

Definition at line 66 of file NameSelector.h.

67  { known_names[DefaultName] = { default_answer }; }
KnownNames_t known_names
list of known names, with category
Definition: NameSelector.h:186
static Name_t const DefaultName
name representing the default
Definition: NameSelector.h:167

Member Data Documentation

NameSelector::Name_t const testing::NameSelector::ClearAllName = "!"
static

name instructing to delete all names

Definition at line 168 of file NameSelector.h.

NameSelector::Name_t const testing::NameSelector::DefaultName = "*"
static

name representing the default

Definition at line 167 of file NameSelector.h.

Definitions_t testing::NameSelector::definitions
protected

a set of definitions

Definition at line 188 of file NameSelector.h.

KnownNames_t testing::NameSelector::known_names
protected

list of known names, with category

Definition at line 186 of file NameSelector.h.

QueryRegistry_t testing::NameSelector::query_registry
mutableprotected

record of all the queries

Definition at line 190 of file NameSelector.h.


The documentation for this class was generated from the following files: