InfoForTypeLabelInstance.cc
Go to the documentation of this file.
5 #include "canvas_root_io/Utilities/TypeWithDict.h"
6 
7 #include "TClass.h"
8 
9 using namespace std;
10 
11 namespace {
13  getPartnerTypeID(TClass* tClass)
14  {
16  if (tClass) {
17  // Note we allow tClass to be null at this point. If the branch is
18  // actually in the input file and there is an attempt to construct
19  // a BranchData object with it null, a missing dictionary
20  // exception will be thrown. This also means we just assume it is
21  // not an Assns. Even if this assumption is wrong, we will get the
22  // correct behavior from getByLabel. A missing dictionary
23  // exception will get thrown if the branch is in the input file
24  // and a ProductNotFound exception will get thrown if it is not.
25  auto const wrappedClass = art::name_of_template_arg(tClass->GetName(), 0);
26  auto const assnsPartner = art::name_of_assns_partner(wrappedClass);
27  if (assnsPartner.empty()) {
28  return result;
29  }
30  auto const wrappedPartnerClassName = art::wrappedClassName(assnsPartner);
31  art::root::TypeWithDict const wrappedPartner(wrappedPartnerClassName);
32  if (!wrappedPartner) {
34  << "In InfoForTypeLabelInstance constructor.\nMissing dictionary for "
35  "wrapped partner of Assns class.\n"
36  << wrappedPartnerClassName << "\n";
37  }
38  result = wrappedPartner.id();
39  }
40  return result;
41  }
42 }
43 
44 namespace gallery {
45  InfoForTypeLabelInstance::InfoForTypeLabelInstance(art::TypeID const& iType,
46  string const& iLabel,
47  string const& iInstance)
48  : type_{iType}
49  , label_{iLabel}
50  , instance_{iInstance}
51  , tClass_{TClass::GetClass(type_.typeInfo())}
53  , partnerType_{getPartnerTypeID(tClass_)}
54  {}
55 
56  art::TypeID const&
58  {
59  return type_;
60  }
61 
62  std::string const&
64  {
65  return label_;
66  }
67 
68  std::string const&
70  {
71  return instance_;
72  }
73 
74  TClass*
76  {
77  return tClass_;
78  }
79 
80  bool
82  {
83  return isAssns_;
84  }
85 
86  art::TypeID const&
88  {
89  return partnerType_;
90  }
91 
92  std::vector<IndexProductIDPair>&
94  {
96  }
97 
98  std::vector<art::ProductID>&
100  {
102  }
103 }
static QCString result
std::string string
Definition: nybbler.cc:12
std::string wrappedClassName(std::string const &className)
STL namespace.
string name_of_assns_partner(string assns_type_name)
Definition: TypeID.cc:170
std::string const & instance() const noexcept
std::vector< IndexProductIDPair > processIndexToProductID_
std::vector< art::ProductID > & productIDsOrderedByHistory() const noexcept
std::vector< IndexProductIDPair > & processIndexToProductID() const noexcept
art::TypeID const & partnerType() const noexcept
std::string className() const
Definition: TypeID.cc:48
string name_of_template_arg(string const &template_instance, size_t desired_arg)
Definition: TypeID.cc:118
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string const & label() const noexcept
art::TypeID const & type() const noexcept
std::vector< art::ProductID > productIDsOrderedByHistory_
bool is_assns(std::string const &type_name)
Definition: TypeID.h:66
std::type_info const & typeInfo() const
Definition: TypeID.cc:36