ProcessTag.cc
Go to the documentation of this file.
2 
3 using namespace std::string_literals;
4 
5 namespace {
6  std::string const current_process_lit{"current_process"};
7  std::string const input_source_lit{"input_source"};
8 
9  auto
10  allowed_search_policy(std::string const& specified_name,
11  std::string const& current_process_name)
12  {
13  using allowed_search = art::ProcessTag::allowed_search;
14  // If user specifies the literal "current_process" or a name that
15  // matches the current process name, then only current-process
16  // searching is allowed.
17  if (specified_name == current_process_lit ||
18  specified_name == current_process_name) {
19  return allowed_search::current_process;
20  }
21 
22  // If user specifies the literal "input_source" or a non-empty
23  // process name (that does not correspond to the current process,
24  // which is handled above), then only input-source searching is
25  // allowed.
26  if (specified_name == input_source_lit || !specified_name.empty()) {
27  return allowed_search::input_source;
28  }
29 
30  // Default to searching all processes
31  return allowed_search::all_processes;
32  }
33 
35  process_name(std::string const& specified_name,
36  std::string const& current_process_name)
37  {
38  if (specified_name == current_process_lit) {
39  return current_process_name;
40  } else if (specified_name == input_source_lit) {
41  return {};
42  }
43  return specified_name;
44  }
45 }
46 
47 art::ProcessTag::ProcessTag() = default;
48 
50  : name_{specified_name}
51 {}
52 
54  std::string const& current_process_name)
55  : search_{allowed_search_policy(specified_name, current_process_name)}
56  , name_{process_name(specified_name, current_process_name)}
57 {}
58 
59 bool
61 {
65 }
66 
67 bool
69 {
73 }
std::string string
Definition: nybbler.cc:12
bool input_source_search_allowed() const
Definition: ProcessTag.cc:60
std::string name_
Definition: ProcessTag.h:32
bool current_process_search_allowed() const
Definition: ProcessTag.cc:68
allowed_search search_
Definition: ProcessTag.h:31