PandaRoot
PndContainerRegister Class Reference

#include <PndContainerRegister.h>

Classes

struct  PndContainerType_t
 

Public Member Functions

void Request (const PndContainerType_t &t_container)
 
Bool_t IsBranchSet (const TString &t_branchname) const
 
template<class T >
PndMutableContainerI< T > * GetOutput (const TString &t_branchname)
 
template<class T >
void SetOutput (const TString &t_branchname, PndContainerI< T > *t_ptr)
 
template<class T >
PndContainerI< T > * GetInput (const TString &t_branchname)
 
template<class T >
void SetInput (const TString &t_branchname, PndContainerI< T > *t_ptr)
 
void SetAsDefaultBranchFor (const TString &t_branchname, const TString &t_class)
 
template<class T >
PndContainerI< T > * GetDefaultBranch ()
 
const TString & GetCurrentDefaultBranchName (const TString &t_classname) const
 
template<class T >
const TString & GetCurrentDefaultBranchName () const
 
const std::map< TString, PndContainerType_t > & GetRequests ()
 
const std::map< TString, TString > & GetBranches ()
 
std::map< TString, PndContainerBaseI * > & Inputs ()
 
std::map< TString, PndContainerBaseI * > & Outputs ()
 

Detailed Description

Definition at line 16 of file PndContainerRegister.h.

Member Function Documentation

◆ GetBranches()

const std::map<TString, TString>& PndContainerRegister::GetBranches ( )
inline

Definition at line 138 of file PndContainerRegister.h.

138 { return fContainerOfType; }

◆ GetCurrentDefaultBranchName() [1/2]

const TString& PndContainerRegister::GetCurrentDefaultBranchName ( const TString &  t_classname) const
inline

Definition at line 128 of file PndContainerRegister.h.

128 { return fDefaultBranches.at(t_classname); }

◆ GetCurrentDefaultBranchName() [2/2]

template<class T >
const TString& PndContainerRegister::GetCurrentDefaultBranchName ( ) const
inline

Definition at line 131 of file PndContainerRegister.h.

132  {
133  const TString classname = T{}.ClassName();
134  return GetCurrentDefaultBranchName(classname);
135  }
const TString & GetCurrentDefaultBranchName() const

◆ GetDefaultBranch()

template<class T >
PndContainerI<T>* PndContainerRegister::GetDefaultBranch ( )
inline

Definition at line 115 of file PndContainerRegister.h.

116  {
117  const TString classname = T{}.ClassName();
118  const TString &defaultBranch = fDefaultBranches[classname];
119  LOG(debug) << "PndContainerRegister::GetDefaultBranch() Returning default branch " << defaultBranch << " for " << classname;
120 
121  auto pos = fInputs.find(defaultBranch);
122  if (pos != fInputs.end()) {
123  return dynamic_cast<PndContainerI<T> *>(pos->second);
124  }
125  return dynamic_cast<PndContainerI<T> *>(fOutputs[defaultBranch]);
126  }

◆ GetInput()

template<class T >
PndContainerI<T>* PndContainerRegister::GetInput ( const TString &  t_branchname)
inline

Definition at line 87 of file PndContainerRegister.h.

88  {
89  LOG(debug) << "PndContainerRegister::GetInput(" << t_branchname << ") for " << T{}.ClassName();
90  if (t_branchname == "" || fDefaultBranches[T{}.ClassName()] == t_branchname) {
91  LOG(debug) << "PndContainerRegister::GetInput(" << t_branchname << ") from default register";
92 
93  return dynamic_cast<PndContainerI<T> *>(GetDefaultBranch<T>());
94  }
95  return dynamic_cast<PndContainerI<T> *>(fInputs[t_branchname]);
96  }

◆ GetOutput()

template<class T >
PndMutableContainerI<T>* PndContainerRegister::GetOutput ( const TString &  t_branchname)
inline

Definition at line 59 of file PndContainerRegister.h.

60  {
61  LOG(debug) << "PndContainerRegister::GetOutput(" << t_branchname << ") for " << T{}.ClassName();
62 
63  if (t_branchname == "" || fDefaultBranches[T{}.ClassName()] == t_branchname) {
64  LOG(debug) << "PndContainerRegister::GetOutput(" << t_branchname << ") from default register";
65  auto *defaultBranch = GetDefaultBranch<T>();
66  if (dynamic_cast<PndMutableContainerI<T> *>(defaultBranch)) {
67  return dynamic_cast<PndMutableContainerI<T> *>(defaultBranch);
68  } else {
69  LOG(error) << "Attempted to cast a InputContainer " << t_branchname << ") for " << T{}.ClassName() << " to PndMutableContainerI! Returning nullptr!";
70  return nullptr;
71  }
72  }
73  return dynamic_cast<PndMutableContainerI<T> *>(fOutputs[t_branchname]);
74  }

◆ GetRequests()

const std::map<TString, PndContainerType_t>& PndContainerRegister::GetRequests ( )
inline

Definition at line 137 of file PndContainerRegister.h.

137 { return fRequests; }

◆ Inputs()

std::map<TString, PndContainerBaseI *>& PndContainerRegister::Inputs ( )
inline

Definition at line 139 of file PndContainerRegister.h.

139 { return fInputs; }

◆ IsBranchSet()

Bool_t PndContainerRegister::IsBranchSet ( const TString &  t_branchname) const
inline

Definition at line 45 of file PndContainerRegister.h.

Referenced by PndProcessTask::HandledRequest().

46  {
47  auto pos = fInputs.find(t_branchname);
48  if (pos != fInputs.end()) {
49  return (pos->second) != nullptr;
50  }
51  auto opos = fOutputs.find(t_branchname);
52  if (opos != fOutputs.end()) {
53  return (opos->second) != nullptr;
54  }
55  return false;
56  }

◆ Outputs()

std::map<TString, PndContainerBaseI *>& PndContainerRegister::Outputs ( )
inline

Definition at line 140 of file PndContainerRegister.h.

140 { return fOutputs; }

◆ Request()

void PndContainerRegister::Request ( const PndContainerType_t t_container)
inline

Definition at line 27 of file PndContainerRegister.h.

References PndContainerRegister::PndContainerType_t::fBranchname, PndContainerRegister::PndContainerType_t::fClassType, PndContainerRegister::PndContainerType_t::fIsOutput, PndContainerRegister::PndContainerType_t::fIsPersistent, and PndContainerRegister::PndContainerType_t::GetKey().

28  {
29  auto pos = fRequests.find(t_container.GetKey());
30  if (pos != fRequests.end()) {
31  if ((*pos).second.fClassType != t_container.fClassType) {
32  LOG(fatal) << "Attempting to request branch " << t_container.fBranchname << " for " << t_container.fClassType << " but branchname already used for "
33  << (*pos).second.fClassType << ". Ignoring this request!";
34  } else {
35  (*pos).second.fIsOutput |= t_container.fIsOutput;
36  (*pos).second.fIsPersistent |= t_container.fIsPersistent;
37  LOG(debug) << "Setting request for an output branch " << t_container.fBranchname << " for " << t_container.fClassType;
38  }
39  } else {
40  fRequests[t_container.GetKey()] = t_container;
41  LOG(debug) << "Setting request for branch " << t_container.fBranchname << " for " << t_container.fClassType;
42  }
43  }

◆ SetAsDefaultBranchFor()

void PndContainerRegister::SetAsDefaultBranchFor ( const TString &  t_branchname,
const TString &  t_class 
)
inline

Definition at line 108 of file PndContainerRegister.h.

Referenced by SetInput(), and SetOutput().

109  {
110  LOG(info) << "PndContainerRegister::SetAsDefaultBranchFor() Setting " << t_branchname << " as active branch for " << t_class;
111  fDefaultBranches[t_class] = t_branchname;
112  }

◆ SetInput()

template<class T >
void PndContainerRegister::SetInput ( const TString &  t_branchname,
PndContainerI< T > *  t_ptr 
)
inline

Definition at line 99 of file PndContainerRegister.h.

References PndContainerI< T >::GetClassName(), and SetAsDefaultBranchFor().

Referenced by PndProcessTask::HandledRequest().

100  {
101  const TString classname = t_ptr->GetClassName();
102  fInputs[t_branchname] = t_ptr;
103  if (fDefaultBranches.find(classname) == fDefaultBranches.end()) {
104  SetAsDefaultBranchFor(t_branchname, classname);
105  }
106  }
TString GetClassName() const
Definition: PndContainerI.h:63
void SetAsDefaultBranchFor(const TString &t_branchname, const TString &t_class)

◆ SetOutput()

template<class T >
void PndContainerRegister::SetOutput ( const TString &  t_branchname,
PndContainerI< T > *  t_ptr 
)
inline

Definition at line 77 of file PndContainerRegister.h.

References PndContainerI< T >::GetClassName(), and SetAsDefaultBranchFor().

Referenced by PndProcessTask::HandledRequest().

78  {
79  const TString classname = t_ptr->GetClassName();
80  fOutputs[t_branchname] = t_ptr;
81  if (fDefaultBranches.find(classname) == fDefaultBranches.end()) {
82  SetAsDefaultBranchFor(t_branchname, classname);
83  }
84  }
TString GetClassName() const
Definition: PndContainerI.h:63
void SetAsDefaultBranchFor(const TString &t_branchname, const TString &t_class)

The documentation for this class was generated from the following file: