AssnsBranchData.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
6 
7 #include <utility>
8 
9 using namespace std;
10 
11 namespace gallery {
12 
13  AssnsBranchData::~AssnsBranchData() = default;
14 
15  AssnsBranchData::AssnsBranchData(art::TypeID const& type,
16  TClass* iTClass,
17  TBranch* iBranch,
18  EventNavigator const* eventNavigator,
19  art::PrincipalBase const* finder,
20  string&& iBranchName,
21  art::TypeID const& infoType,
22  art::TypeID const& infoPartnerType)
23  : BranchData{type,
24  iTClass,
25  iBranch,
26  eventNavigator,
27  finder,
28  move(iBranchName)}
29  {
30  if (type == infoType) {
31  secondary_wrapper_type_ = infoPartnerType;
32  } else {
33  secondary_wrapper_type_ = infoType;
34  }
35  }
36 
37  void
38  AssnsBranchData::updateFile(TBranch* iBranch)
39  {
41  secondaryProduct_.reset();
42  BranchData::updateFile(iBranch);
43  }
44 
45  art::EDProduct const*
47  {
48  throw art::Exception(art::errors::LogicError, "AmbiguousProduct")
49  << "AssnsBranchData uniqueProduct() called without specifying which type "
50  "was wanted.\n"
51  << "branch name is " << branchName() << "\n"
52  << "Possibly you tried to use a Ptr that points into an Assns, which is "
53  "not allowed and does not work\n";
54  }
55 
56  art::EDProduct const*
58  {
59  throw art::Exception(art::errors::LogicError, "AmbiguousProduct")
60  << "AssnsBranchData uniqueProduct() called without specifying which type "
61  "was wanted.\n"
62  << "branch name is " << branchName() << "\n"
63  << "Possibly you tried to use a Ptr that points into an Assns, which is "
64  "not allowed and does not work\n";
65  }
66 
67  art::EDProduct const*
68  AssnsBranchData::uniqueProduct_(art::TypeID const& wanted_wrapper_type) const
69  {
70  art::EDProduct const* primaryAssns = BranchData::getIt_();
71  if (primaryAssns && (wanted_wrapper_type == secondary_wrapper_type_)) {
74  primaryAssns->makePartner(wanted_wrapper_type.typeInfo());
76  }
77  return secondaryProduct_.get();
78  }
79  return primaryAssns;
80  }
81 
82 } // namespace gallery
art::TypeID secondary_wrapper_type_
STL namespace.
std::string const & branchName() const noexcept
Definition: BranchData.h:66
std::unique_ptr< EDProduct > makePartner(std::type_info const &wanted_type) const
Definition: EDProduct.h:70
def move(depos, offset)
Definition: depos.py:107
std::unique_ptr< art::EDProduct > secondaryProduct_
void updateFile(TBranch *iBranch) override
virtual art::EDProduct const * getIt_() const
Definition: BranchData.cc:79
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::EDProduct const * getIt_() const override
virtual void updateFile(TBranch *iBranch)
Definition: BranchData.cc:69
static QCString type
Definition: declinfo.cpp:672
long long lastProduct() const noexcept
Definition: BranchData.h:72
std::type_info const & typeInfo() const
Definition: TypeID.cc:36
art::EDProduct const * uniqueProduct_() const override