PandaRoot
PndContainerRegister Class Reference

#include <PndContainerRegister.h>

Inheritance diagram for PndContainerRegister:

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 ()
 
virtual ~PndContainerRegister ()=default
 

Detailed Description

Definition at line 28 of file PndContainerRegister.h.

Constructor & Destructor Documentation

◆ ~PndContainerRegister()

virtual PndContainerRegister::~PndContainerRegister ( )
virtualdefault

Referenced by Outputs().

Member Function Documentation

◆ GetBranches()

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

Definition at line 152 of file PndContainerRegister.h.

152 { return fContainerOfType; }

◆ GetCurrentDefaultBranchName() [1/2]

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

Definition at line 142 of file PndContainerRegister.h.

142 { return fDefaultBranches.at(t_classname); }

◆ GetCurrentDefaultBranchName() [2/2]

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

Definition at line 145 of file PndContainerRegister.h.

146  {
147  const TString classname = T{}.ClassName();
148  return GetCurrentDefaultBranchName(classname);
149  }
const TString & GetCurrentDefaultBranchName() const

◆ GetDefaultBranch()

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

Definition at line 129 of file PndContainerRegister.h.

130  {
131  const TString classname = T{}.ClassName();
132  const TString &defaultBranch = fDefaultBranches[classname];
133  LOG(debug) << "PndContainerRegister::GetDefaultBranch() Returning default branch " << defaultBranch << " for " << classname;
134 
135  auto pos = fInputs.find(defaultBranch);
136  if (pos != fInputs.end()) {
137  return dynamic_cast<PndContainerI<T> *>(pos->second);
138  }
139  return dynamic_cast<PndContainerI<T> *>(fOutputs[defaultBranch]);
140  }

◆ GetInput()

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

Definition at line 101 of file PndContainerRegister.h.

102  {
103  LOG(debug) << "PndContainerRegister::GetInput(" << t_branchname << ") for " << T{}.ClassName();
104  if (t_branchname == "" || fDefaultBranches[T{}.ClassName()] == t_branchname) {
105  LOG(debug) << "PndContainerRegister::GetInput(" << t_branchname << ") from default register";
106 
107  return (GetDefaultBranch<T>());
108  }
109  return dynamic_cast<PndContainerI<T> *>(fInputs[t_branchname]);
110  }

◆ GetOutput()

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

Definition at line 71 of file PndContainerRegister.h.

72  {
73  LOG(debug) << "PndContainerRegister::GetOutput(" << t_branchname << ") for " << T{}.ClassName();
74 
75  if (t_branchname == "" || fDefaultBranches[T{}.ClassName()] == t_branchname) {
76  LOG(debug) << "PndContainerRegister::GetOutput(" << t_branchname << ") from default register";
77  auto *defaultBranch = GetDefaultBranch<T>();
78  if (dynamic_cast<PndMutableContainerI<T> *>(defaultBranch)) {
79  return dynamic_cast<PndMutableContainerI<T> *>(defaultBranch);
80  } else {
81  LOG(error) << "Attempted to cast a InputContainer " << t_branchname << ") for " << T{}.ClassName() << " to PndMutableContainerI! Returning nullptr!";
82  return nullptr;
83  }
84  }
85  return dynamic_cast<PndMutableContainerI<T> *>(fOutputs[t_branchname]);
86  }

◆ GetRequests()

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

Definition at line 151 of file PndContainerRegister.h.

151 { return fRequests; }

◆ Inputs()

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

Definition at line 153 of file PndContainerRegister.h.

153 { return fInputs; }

◆ IsBranchSet()

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

Definition at line 57 of file PndContainerRegister.h.

Referenced by PndProcessTask::HandledRequest().

58  {
59  auto pos = fInputs.find(t_branchname);
60  if (pos != fInputs.end()) {
61  return (pos->second) != nullptr;
62  }
63  auto opos = fOutputs.find(t_branchname);
64  if (opos != fOutputs.end()) {
65  return (opos->second) != nullptr;
66  }
67  return false;
68  }

◆ Outputs()

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

Definition at line 154 of file PndContainerRegister.h.

References ~PndContainerRegister().

154 { return fOutputs; }

◆ Request()

void PndContainerRegister::Request ( const PndContainerType_t t_container)
inline

Definition at line 39 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().

40  {
41  auto pos = fRequests.find(t_container.GetKey());
42  if (pos != fRequests.end()) {
43  if ((*pos).second.fClassType != t_container.fClassType) {
44  LOG(fatal) << "Attempting to request branch " << t_container.fBranchname << " for " << t_container.fClassType << " but branchname already used for "
45  << (*pos).second.fClassType << ". Ignoring this request!";
46  } else {
47  (*pos).second.fIsOutput |= t_container.fIsOutput;
48  (*pos).second.fIsPersistent |= t_container.fIsPersistent;
49  LOG(debug) << "Setting request for an output branch " << t_container.fBranchname << " for " << t_container.fClassType;
50  }
51  } else {
52  fRequests[t_container.GetKey()] = t_container;
53  LOG(debug) << "Setting request for branch " << t_container.fBranchname << " for " << t_container.fClassType;
54  }
55  }

◆ SetAsDefaultBranchFor()

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

Definition at line 122 of file PndContainerRegister.h.

Referenced by SetInput(), and SetOutput().

123  {
124  LOG(info) << "PndContainerRegister::SetAsDefaultBranchFor() Setting " << t_branchname << " as active branch for " << t_class;
125  fDefaultBranches[t_class] = t_branchname;
126  }

◆ SetInput()

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

Definition at line 113 of file PndContainerRegister.h.

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

Referenced by PndProcessTask::HandledRequest().

114  {
115  const TString classname = t_ptr->GetClassName();
116  fInputs[t_branchname] = t_ptr;
117  if (fDefaultBranches.find(classname) == fDefaultBranches.end()) {
118  SetAsDefaultBranchFor(t_branchname, classname);
119  }
120  }
TString GetClassName() const
Definition: PndContainerI.h:75
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 89 of file PndContainerRegister.h.

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

Referenced by PndProcessTask::HandledRequest().

90  {
91  const TString classname = t_ptr->GetClassName();
92  fOutputs[t_branchname] = t_ptr;
93  fInputs[t_branchname] = t_ptr;
94 
95  if (fDefaultBranches.find(classname) == fDefaultBranches.end()) {
96  SetAsDefaultBranchFor(t_branchname, classname);
97  }
98  }
TString GetClassName() const
Definition: PndContainerI.h:75
void SetAsDefaultBranchFor(const TString &t_branchname, const TString &t_class)

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