ATLAS Offline Software
Loading...
Searching...
No Matches
TPyStore.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local include(s).
7
9
10// ROOT include(s).
11#include <TClass.h>
12#include <TError.h>
13
14namespace xAOD {
15
28bool TPyStore::pyContains(const std::string& key,
29 const std::string& type) const {
30
31 // Try to access the dictionary of this type.
32 ::TClass* cl = ::TClass::GetClass(type.c_str());
33 if (cl == nullptr) {
34 ::Warning("xAOD::TPyStore::pyContains", "Type name \"%s\" not known",
35 type.c_str());
36 return false;
37 }
38
39 // Check if the dictionary can return a type_info.
40 const std::type_info* ti = cl->GetTypeInfo();
41 if (!ti) {
42 ::Warning("xAOD::TPyStore::pyContains",
43 "Type \"%s\" doesn't have a proper dictionary", type.c_str());
44 return false;
45 }
46
47 // Use the base class to answer the question.
48 return TStore::contains(key, *ti);
49}
50
63bool TPyStore::pyIsConst(const std::string& key,
64 const std::string& type) const {
65
66 // Try to access the dictionary of this type.
67 ::TClass* cl = ::TClass::GetClass(type.c_str());
68 if (cl == nullptr) {
69 ::Warning("xAOD::TPyStore::pyIsConst", "Type name \"%s\" not known",
70 type.c_str());
71 return false;
72 }
73
74 // Check if the dictionary can return a type_info.
75 const std::type_info* ti = cl->GetTypeInfo();
76 if (ti == nullptr) {
77 ::Warning("xAOD::TPyStore::pyIsConst",
78 "Type \"%s\" doesn't have a proper dictionary", type.c_str());
79 return false;
80 }
81
82 // Use the base class to answer the question.
83 return TStore::isConst(key, *ti);
84}
85
103StatusCode TPyStore::pyRecord(void* obj, const std::string& key,
104 const std::string& type) {
105
106 // Simply forward the call to the appropriate function from the base
107 // class.
108 static constexpr bool IS_OWNER = true;
109 static constexpr bool IS_CONST = false;
110 RETURN_CHECK("xAOD::TPyStore::pyRecord",
111 TStore::record(obj, key, type, IS_OWNER, IS_CONST));
112
113 // Return gracefully:
114 return StatusCode::SUCCESS;
115}
116
121void TPyStore::dump() const {
122
123 print();
124 return;
125}
126
127} // namespace xAOD
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition ReturnCheck.h:26
void dump() const
Print the contents of the store using a Python friendly function.
Definition TPyStore.cxx:121
StatusCode pyRecord(void *obj, const std::string &key, const std::string &type)
Record an object into the store in a typeless way.
Definition TPyStore.cxx:103
bool pyIsConst(const std::string &key, const std::string &type) const
Function checking if an object with a given key and type is constant.
Definition TPyStore.cxx:63
bool pyContains(const std::string &key, const std::string &type) const
Function checking if an object with a given key and type is available.
Definition TPyStore.cxx:28
void print() const
Print the current contents of the transient store.
Definition TStore.cxx:124
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.