LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
InputTag.h
Go to the documentation of this file.
1 #ifndef canvas_Utilities_InputTag_h
2 #define canvas_Utilities_InputTag_h
3 
4 #include <iosfwd>
5 #include <string>
6 
7 namespace boost {
8  class any;
9 }
10 
11 namespace art {
12  class InputTag;
13 
14  std::ostream& operator<<(std::ostream& ost, InputTag const& tag);
15  bool operator!=(InputTag const& left, InputTag const& right) noexcept;
16 }
17 
19 public:
20  InputTag() = default;
21 
22  // Create an InputTag by parsing the given string, which is
23  // expected to be in colon-delimited form, fitting one of the
24  // following patterns:
25  //
26  // label
27  // label:instance
28  // label:instance:process
29  InputTag(std::string const& s);
30  InputTag(char const* s);
31 
32  // Create an InputTag with the given label, instance, and process
33  // specificiations.
34  InputTag(std::string const& label,
35  std::string const& instance,
36  std::string const& processName = {});
37 
38  // Create an InputTag with the given label, instance, and process
39  // specifications.
40  InputTag(char const* label,
41  char const* instance,
42  char const* processName = "");
43 
44  // use compiler-generated copy c'tor, copy assignment, and d'tor
45 
46  std::string encode() const;
47 
48  bool
49  empty() const noexcept
50  {
51  return label_.empty() && instance_.empty() && process_.empty();
52  }
53 
54  std::string const&
55  label() const noexcept
56  {
57  return label_;
58  }
59  std::string const&
60  instance() const noexcept
61  {
62  return instance_;
63  }
66  std::string const&
67  process() const noexcept
68  {
69  return process_;
70  }
71 
72  bool operator==(InputTag const& tag) const noexcept;
73 
74 private:
75  std::string label_{};
76  std::string instance_{};
77  std::string process_{};
78 
79  // Helper function, to parse colon-separated initialization
80  // string.
81  void set_from_string_(std::string const& s);
82 };
83 
84 inline art::InputTag::InputTag(std::string const& label,
85  std::string const& instance,
86  std::string const& processName)
87  : label_(label), instance_(instance), process_(processName)
88 {}
89 
90 inline art::InputTag::InputTag(char const* label,
91  char const* instance,
92  char const* processName)
93  : label_(label), instance_(instance), process_(processName)
94 {}
95 
96 inline art::InputTag::InputTag(std::string const& s)
97 {
99 }
100 
101 inline art::InputTag::InputTag(char const* s)
102 {
103  set_from_string_(s);
104 }
105 
106 inline bool
107 art::InputTag::operator==(InputTag const& tag) const noexcept
108 {
109  return (label_ == tag.label_) && (instance_ == tag.instance_) &&
110  (process_ == tag.process_);
111 }
112 
113 inline bool
114 art::operator!=(InputTag const& left, InputTag const& right) noexcept
115 {
116  return !(left == right);
117 }
118 
119 //=====================================================================
120 // decode specialization for allowing conversions from
121 // atom ===> InputTag
122 // sequence ===> InputTag
123 
124 namespace art {
125  void decode(boost::any const& a, InputTag& tag);
126 }
127 
128 #endif /* canvas_Utilities_InputTag_h */
129 
130 // Local Variables:
131 // mode: c++
132 // End:
Float_t s
Definition: plot.C:23
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
const std::string label
void set_from_string_(std::string const &s)
Definition: InputTag.cc:15
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
bool operator!=(InputTag const &left, InputTag const &right) noexcept
Definition: InputTag.h:114
std::string label_
Definition: InputTag.h:75
std::string process_
Definition: InputTag.h:77
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
Stream & operator<<(Stream &&out, CallInfo_t const &info)
Helper operator to insert a call information in a stream with default options.
Definition: DebugUtils.h:228
InputTag()=default
bool empty() const noexcept
Definition: InputTag.h:49
std::string const & process() const noexcept
Definition: InputTag.h:67
std::string const & instance() const noexcept
Definition: InputTag.h:60
void decode(boost::any const &a, InputTag &tag)
Definition: InputTag.cc:64
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
HLT enums.
bool operator==(InputTag const &tag) const noexcept
Definition: InputTag.h:107
std::string const & label() const noexcept
Definition: InputTag.h:55
std::string instance_
Definition: InputTag.h:76
bool operator==(geometry_element_iterator< GEOIDITER > const &iter, GEOIDITER const &id_iter)
Comparison operator: geometry ID and element point to the same ID.