13 #ifndef PNDCONTAINERREGISTER_HH 14 #define PNDCONTAINERREGISTER_HH 16 #include <RtypesCore.h> 22 #include "FairLogger.h" 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!";
47 (*pos).second.fIsOutput |= t_container.
fIsOutput;
49 LOG(debug) <<
"Setting request for an output branch " << t_container.
fBranchname <<
" for " << t_container.
fClassType;
52 fRequests[t_container.
GetKey()] = t_container;
53 LOG(debug) <<
"Setting request for branch " << t_container.
fBranchname <<
" for " << t_container.
fClassType;
59 auto pos = fInputs.find(t_branchname);
60 if (pos != fInputs.end()) {
61 return (pos->second) !=
nullptr;
63 auto opos = fOutputs.find(t_branchname);
64 if (opos != fOutputs.end()) {
65 return (opos->second) !=
nullptr;
73 LOG(debug) <<
"PndContainerRegister::GetOutput(" << t_branchname <<
") for " << T{}.ClassName();
75 if (t_branchname ==
"" || fDefaultBranches[T{}.ClassName()] == t_branchname) {
76 LOG(debug) <<
"PndContainerRegister::GetOutput(" << t_branchname <<
") from default register";
77 auto *defaultBranch = GetDefaultBranch<T>();
81 LOG(error) <<
"Attempted to cast a InputContainer " << t_branchname <<
") for " << T{}.ClassName() <<
" to PndMutableContainerI! Returning nullptr!";
92 fOutputs[t_branchname] = t_ptr;
93 fInputs[t_branchname] = t_ptr;
95 if (fDefaultBranches.find(classname) == fDefaultBranches.end()) {
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";
107 return (GetDefaultBranch<T>());
116 fInputs[t_branchname] = t_ptr;
117 if (fDefaultBranches.find(classname) == fDefaultBranches.end()) {
124 LOG(info) <<
"PndContainerRegister::SetAsDefaultBranchFor() Setting " << t_branchname <<
" as active branch for " << t_class;
125 fDefaultBranches[t_class] = t_branchname;
131 const TString classname = T{}.ClassName();
132 const TString &defaultBranch = fDefaultBranches[classname];
133 LOG(debug) <<
"PndContainerRegister::GetDefaultBranch() Returning default branch " << defaultBranch <<
" for " << classname;
135 auto pos = fInputs.find(defaultBranch);
136 if (pos != fInputs.end()) {
147 const TString classname = T{}.ClassName();
151 const std::map<TString, PndContainerType_t> &
GetRequests() {
return fRequests; }
152 const std::map<TString, TString> &
GetBranches() {
return fContainerOfType; }
153 std::map<TString, PndContainerBaseI *> &
Inputs() {
return fInputs; }
154 std::map<TString, PndContainerBaseI *> &
Outputs() {
return fOutputs; }
159 std::map<TString, PndContainerType_t> fRequests{};
160 std::map<TString, TString> fDefaultBranches{};
161 std::map<TString, TString> fContainerOfType{};
162 std::map<TString, PndContainerBaseI *> fInputs{};
163 std::map<TString, PndContainerBaseI *> fOutputs{};
PndContainerI< T > * GetDefaultBranch()
const std::map< TString, PndContainerType_t > & GetRequests()
void SetInput(const TString &t_branchname, PndContainerI< T > *t_ptr)
Container to wrap PndTCA/STDMutableContainer (not needed anymore)
void SetOutput(const TString &t_branchname, PndContainerI< T > *t_ptr)
virtual ~PndContainerRegister()=default
void Request(const PndContainerType_t &t_container)
Interface to a datacontainer to be used in PandaROOT.
Bool_t RequestsSpecificBranch() const
const TString & GetCurrentDefaultBranchName(const TString &t_classname) const
std::map< TString, PndContainerBaseI * > & Inputs()
TString GetClassName() const
const std::map< TString, TString > & GetBranches()
PndContainerI< T > * GetInput(const TString &t_branchname)
const TString & GetCurrentDefaultBranchName() const
PndMutableContainerI< T > * GetOutput(const TString &t_branchname)
std::map< TString, PndContainerBaseI * > & Outputs()
Bool_t IsBranchSet(const TString &t_branchname) const
void SetAsDefaultBranchFor(const TString &t_branchname, const TString &t_class)