LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TypeLabel.cc
Go to the documentation of this file.
3 // vim: set sw=2 expandtab :
4 
5 #include <ostream>
6 #include <tuple>
7 
8 namespace art {
9 
10  TypeLabel::TypeLabel(TypeID const& itemtype,
11  std::string const& instanceName,
12  bool const supportsView,
13  bool const transient)
14  : typeID_{itemtype}
15  , productInstanceName_{instanceName}
17  , transient_{transient}
18  {}
19 
20  TypeLabel::TypeLabel(TypeID const& itemtype,
21  std::string const& instanceName,
22  bool const supportsView,
23  std::string emulatedModule)
24  : typeID_{itemtype}
25  , productInstanceName_{instanceName}
27  , emulatedModule_{std::make_unique<std::string>(std::move(emulatedModule))}
28  {}
29 
30  std::string const&
32  {
33  if (!emulatedModule_) {
35  "TypeLabel::emulatedModule\n")
36  << "Attempt to retrieve an emulated module name when one does not "
37  "exist.\n";
38  }
39  return *emulatedModule_;
40  }
41 
42  // Types with the same friendlyClassName are in the same equivalence
43  // class for the purposes of this comparison.
44  bool
45  operator<(TypeLabel const& a, TypeLabel const& b)
46  {
47  auto const& a_class_name = a.className();
48  auto const& b_class_name = b.className();
49  auto const& a_emulated_module =
50  a.hasEmulatedModule() ? *a.emulatedModule_ : "<none>";
51  auto const& b_emulated_module =
52  b.hasEmulatedModule() ? *b.emulatedModule_ : "<none>";
53  return std::tie(a_emulated_module, a.productInstanceName_, a_class_name) <
54  std::tie(b_emulated_module, b.productInstanceName_, b_class_name);
55  }
56 
57  std::ostream&
58  operator<<(std::ostream& os, TypeLabel const& tl)
59  {
60  os << "Emulated module: '"
61  << (tl.hasEmulatedModule() ? tl.emulatedModule() : "<none>") << "'\n"
62  << "Product instance name: '" << tl.productInstanceName() << "'\n"
63  << "Class name: '" << tl.className() << "'\n"
64  << "Supports views: '" << std::boolalpha << tl.supportsView()
65  << '\n'
66  << "Transient: '" << tl.transient();
67  return os;
68  }
69 }
std::string const & productInstanceName() const
Definition: TypeLabel.h:51
friend std::ostream & operator<<(std::ostream &os, TypeLabel const &tl)
Definition: TypeLabel.cc:58
std::string const & emulatedModule() const
Definition: TypeLabel.cc:31
std::shared_ptr< std::string > emulatedModule_
Definition: TypeLabel.h:76
bool hasEmulatedModule() const
Definition: TypeLabel.h:56
bool supportsView() const
Definition: TypeLabel.h:61
TypeID typeID_
Definition: TypeLabel.h:72
friend bool operator<(TypeLabel const &a, TypeLabel const &b)
Definition: TypeLabel.cc:45
TypeLabel(TypeID const &itemtype, std::string const &instanceName, bool const supportsView, bool const transient)
Definition: TypeLabel.cc:10
bool transient_
Definition: TypeLabel.h:75
std::string productInstanceName_
Definition: TypeLabel.h:73
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool transient() const
Definition: TypeLabel.h:66
HLT enums.
std::string className() const
Definition: TypeLabel.h:40
bool supportsView_
Definition: TypeLabel.h:74