ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AuxDiscoverySvc Class Reference

This class provides the interface between AthenaPoolCnvSvc and AuxStore classes. More...

#include <AuxDiscoverySvc.h>

Collaboration diagram for AuxDiscoverySvc:

Public Member Functions

 AuxDiscoverySvc ()
 
bool getAuxStore (void *obj, const Guid &classId, const std::string &contId)
 
bool setData (SG::auxid_t auxid, void *data, const RootType &type)
 
bool setAuxStore ()
 
SG::auxid_t getAuxID (const std::string &attrName, const std::string &elemName, const std::string &typeName)
 
SG::auxid_set_t getAuxIDs (const void *obj, const Guid &classId, const std::string &contId)
 
const void * getData (SG::auxid_t auxid)
 
const std::type_info * getType (SG::auxid_t auxid)
 
std::string getAttrName (SG::auxid_t auxid)
 
std::string getTypeName (SG::auxid_t auxid)
 
std::string getElemName (SG::auxid_t auxid)
 
StatusCode receiveStore (const IAthenaSerializeSvc *serSvc, IAthenaIPCTool *ipcTool, void *obj, int num=0)
 Receive dynamic aux store variables from streaming tool. More...
 
StatusCode sendStore (const IAthenaSerializeSvc *serSvc, IAthenaIPCTool *ipcTool, const void *obj, const Guid &classId, const std::string &contName, int num=0)
 Send dynamic aux store variables to streaming tool. More...
 

Private Attributes

const SG::IAuxStoreIOm_store
 
AthenaPoolAuxStorem_storeInt
 
SG::IAuxStoreHolderm_storeHolder
 

Detailed Description

This class provides the interface between AthenaPoolCnvSvc and AuxStore classes.

Definition at line 33 of file AuxDiscoverySvc.h.

Constructor & Destructor Documentation

◆ AuxDiscoverySvc()

AuxDiscoverySvc::AuxDiscoverySvc ( )
inline

Definition at line 35 of file AuxDiscoverySvc.h.

35 : m_store(0), m_storeInt(0), m_storeHolder(0) {}

Member Function Documentation

◆ getAttrName()

std::string AuxDiscoverySvc::getAttrName ( SG::auxid_t  auxid)

Definition at line 151 of file AuxDiscoverySvc.cxx.

151  {
152  return SG::AuxTypeRegistry::instance().getName(auxid);
153 }

◆ getAuxID()

SG::auxid_t AuxDiscoverySvc::getAuxID ( const std::string &  attrName,
const std::string &  elemName,
const std::string &  typeName 
)

Definition at line 93 of file AuxDiscoverySvc.cxx.

93  {
95  SG::auxid_t auxid = registry.findAuxID(attrName);
96  if (auxid == SG::null_auxid && m_storeInt != nullptr) {
97  try {
98  RootUtils::Type elemType(elemName);
99  const std::type_info* eti = elemType.getTypeInfo();
100  if (eti == nullptr) {
101  return SG::null_auxid;
102  }
103  auxid = SG::getDynamicAuxID(*eti, attrName, elemName, typeName, m_storeInt->standalone(), SG::null_auxid);
104  } catch (const std::runtime_error&) {
105  return SG::null_auxid;
106  }
107  }
108  return auxid;
109 }

◆ getAuxIDs()

SG::auxid_set_t AuxDiscoverySvc::getAuxIDs ( const void *  obj,
const Guid classId,
const std::string &  contId 
)

Definition at line 112 of file AuxDiscoverySvc.cxx.

112  {
113  pool::DbTypeInfo* info = pool::DbTypeInfo::create(classId); // Needed for Properties and TClass
114  if (info == nullptr) {
115  return SG::auxid_set_t();
116  }
117  if (!contId.empty() && (contId.size() < 5 || contId.substr(contId.size() - 5, 4) != "Aux.")
118  && !info->clazz().Properties().HasProperty("IAuxStore")) {
119  return SG::auxid_set_t();
120  }
121  // Detected auxStore
122  TClass* cl = info->clazz().Class();
123  if (cl == nullptr) {
124  return SG::auxid_set_t();
125  }
126  TClass* storeTC = cl->GetBaseClass("SG::IAuxStoreIO");
127  if (storeTC == nullptr) {
128  return SG::auxid_set_t();
129  }
130  m_store = reinterpret_cast<const SG::IAuxStoreIO*>((const char*)obj + cl->GetBaseClassOffset(storeTC));
131  if (m_store == nullptr) {
132  return SG::auxid_set_t();
133  }
134  return m_store->getSelectedAuxIDs();
135 }

◆ getAuxStore()

bool AuxDiscoverySvc::getAuxStore ( void *  obj,
const Guid classId,
const std::string &  contId 
)

Definition at line 39 of file AuxDiscoverySvc.cxx.

39  {
40  pool::DbTypeInfo* info = pool::DbTypeInfo::create(classId); // Needed for Properties and TClass
41  if (info == nullptr) {
42  return false;
43  }
44  if (!contId.empty() && (contId.size() < 5 || contId.substr(contId.size() - 5, 4) != "Aux.")
45  && !info->clazz().Properties().HasProperty("IAuxStore")) {
46  return false;
47  }
48  TClass* cl = info->clazz().Class();
49  if (cl == nullptr) {
50  return false;
51  }
52  TClass* holderTC = cl->GetBaseClass("SG::IAuxStoreHolder");
53  if (holderTC == nullptr) {
54  return false;
55  }
56  m_storeHolder = reinterpret_cast<SG::IAuxStoreHolder*>((char*)obj + cl->GetBaseClassOffset(holderTC));
57  if (m_storeHolder == nullptr) {
58  return false;
59  }
62  return true;
63 }

◆ getData()

const void * AuxDiscoverySvc::getData ( SG::auxid_t  auxid)

Definition at line 137 of file AuxDiscoverySvc.cxx.

137  {
138  if (m_store == nullptr) {
139  return nullptr;
140  }
141  return m_store->getIOData(auxid);
142 }

◆ getElemName()

std::string AuxDiscoverySvc::getElemName ( SG::auxid_t  auxid)

Definition at line 159 of file AuxDiscoverySvc.cxx.

159  {
161 }

◆ getType()

const std::type_info * AuxDiscoverySvc::getType ( SG::auxid_t  auxid)

Definition at line 144 of file AuxDiscoverySvc.cxx.

144  {
145  if (m_store == nullptr) {
146  return nullptr;
147  }
148  return m_store->getIOType(auxid);
149 }

◆ getTypeName()

std::string AuxDiscoverySvc::getTypeName ( SG::auxid_t  auxid)

Definition at line 155 of file AuxDiscoverySvc.cxx.

155  {
156  return SG::normalizedTypeinfoName(*(getType(auxid)));
157 }

◆ receiveStore()

StatusCode AuxDiscoverySvc::receiveStore ( const IAthenaSerializeSvc serSvc,
IAthenaIPCTool ipcTool,
void *  obj,
int  num = 0 
)

Receive dynamic aux store variables from streaming tool.

Definition at line 162 of file AuxDiscoverySvc.cxx.

162  {
163  void* buffer = nullptr;
164  size_t nbytes = 0;
165  StatusCode sc = ipcTool->getObject(&buffer, nbytes, num);
166  while (sc.isRecoverable() && nbytes > 0) {
167  sc = ipcTool->getObject(&buffer, nbytes, num);
168  }
169  if (!sc.isSuccess() || nbytes == 0) { // No dynamic attributes
170  return(StatusCode::SUCCESS);
171  }
172  Guid classId;
173  classId.fromString(static_cast<const char*>(buffer));
174  if (!ipcTool->getObject(&buffer, nbytes, num).isSuccess() || nbytes == 0) {
175  return(StatusCode::FAILURE);
176  }
177  const std::string contName = std::string(static_cast<const char*>(buffer));
178  if (classId != Guid::null() && this->getAuxStore(obj, classId, contName)) {
179  void* nameData = nullptr;
180  // StreamingTool owns buffer, will stay around until last dynamic attribute is copied
181  while (ipcTool->getObject(&nameData, nbytes, num).isSuccess() && nbytes > 0) {
182  const char* del1 = static_cast<const char*>(memchr(nameData, '\n', nbytes));
183  const char* del2 = static_cast<const char*>(memchr(del1 + 1, '\n', nbytes - (del1 - static_cast<const char*>(nameData) - 1)));
184  const std::string dataStr(static_cast<const char*>(nameData));
185  const std::string& attrName = dataStr.substr(0, del1 - static_cast<const char*>(nameData));
186  const std::string& typeName = dataStr.substr(del1 - static_cast<const char*>(nameData) + 1, del2 - del1 - 1);
187  const std::string& elemName = dataStr.substr(del2 - static_cast<const char*>(nameData) + 1);
188  if (ipcTool->getObject(&buffer, nbytes, num).isSuccess()) {
189  SG::auxid_t auxid = this->getAuxID(attrName, elemName, typeName);
190  if (auxid != SG::null_auxid) {
191  const RootType type(typeName);
192  void* dynAttr = nullptr;
193  if (type.IsFundamental()) {
194  dynAttr = new char[nbytes];
195  std::memcpy(dynAttr, buffer, nbytes); buffer = nullptr;
196  } else {
197  dynAttr = serSvc->deserialize(buffer, nbytes, type); buffer = nullptr;
198  }
199  this->setData(auxid, dynAttr, type);
200  }
201  }
202  }
203  this->setAuxStore();
204  }
205  return(StatusCode::SUCCESS);
206 }

◆ sendStore()

StatusCode AuxDiscoverySvc::sendStore ( const IAthenaSerializeSvc serSvc,
IAthenaIPCTool ipcTool,
const void *  obj,
const Guid classId,
const std::string &  contName,
int  num = 0 
)

Send dynamic aux store variables to streaming tool.

Definition at line 208 of file AuxDiscoverySvc.cxx.

213  {
214  const SG::auxid_set_t& auxIDs = this->getAuxIDs(obj, classId, contName);
215  if (!auxIDs.empty()) {
216  const std::string& classIdStr = classId.toString();
217  if (!ipcTool->putObject(classIdStr.c_str(), classIdStr.size() + 1, num).isSuccess()) {
218  return(StatusCode::FAILURE);
219  }
220  if (!ipcTool->putObject(contName.c_str(), contName.size() + 1, num).isSuccess()) {
221  return(StatusCode::FAILURE);
222  }
223  }
224  for (SG::auxid_t auxid : auxIDs) {
225  const std::string& dataStr = this->getAttrName(auxid) + "\n" + this->getTypeName(auxid) + "\n" + this->getElemName(auxid);
226  if (!ipcTool->putObject(dataStr.c_str(), dataStr.size() + 1, num).isSuccess()) {
227  return(StatusCode::FAILURE);
228  }
229  const std::type_info* tip = this->getType(auxid);
230  if (tip == nullptr) {
231  return(StatusCode::FAILURE);
232  }
233  RootType type(*tip);
234  StatusCode sc = StatusCode::FAILURE;
235  if (type.IsFundamental()) {
236  sc = ipcTool->putObject(this->getData(auxid), type.SizeOf(), num);
237  } else {
238  size_t nbytes = 0;
239  void* buffer = serSvc->serialize(this->getData(auxid), type, nbytes);
240  sc = ipcTool->putObject(buffer, nbytes, num);
241  delete [] static_cast<char*>(buffer); buffer = nullptr;
242  }
243  if (!sc.isSuccess()) {
244  return(StatusCode::FAILURE);
245  }
246  }
247  return(StatusCode::SUCCESS);
248 }

◆ setAuxStore()

bool AuxDiscoverySvc::setAuxStore ( )

Definition at line 85 of file AuxDiscoverySvc.cxx.

85  {
86  if (m_storeHolder == nullptr) {
87  return false;
88  }
90  return true;
91 }

◆ setData()

bool AuxDiscoverySvc::setData ( SG::auxid_t  auxid,
void *  data,
const RootType type 
)

Definition at line 65 of file AuxDiscoverySvc.cxx.

65  {
67  if (m_storeInt->standalone()) {
68  (void)m_storeInt->getData(auxid, 1, 1);
69  registry.copy(auxid,
71  SG::AuxVectorInterface (auxid, 1, const_cast<const void*>(data)), 0, 1);
72  if (type.IsFundamental()) {
73  delete [] (char*)data; data = nullptr;
74  } else {
75  type.Destruct(data); data = nullptr;
76  }
77  } else {
78  // Move the data to the dynamic store.
79  std::unique_ptr<SG::IAuxTypeVector> vec(registry.makeVectorFromData(auxid, data, nullptr, false, true));
80  m_storeInt->addVector(std::move(vec), false);
81  }
82  return true;
83 }

Member Data Documentation

◆ m_store

const SG::IAuxStoreIO* AuxDiscoverySvc::m_store
private

Definition at line 69 of file AuxDiscoverySvc.h.

◆ m_storeHolder

SG::IAuxStoreHolder* AuxDiscoverySvc::m_storeHolder
private

Definition at line 71 of file AuxDiscoverySvc.h.

◆ m_storeInt

AthenaPoolAuxStore* AuxDiscoverySvc::m_storeInt
private

Definition at line 70 of file AuxDiscoverySvc.h.


The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
python.Dso.registry
registry
Definition: Control/AthenaServices/python/Dso.py:159
SG::AuxStoreInternal::addVector
void addVector(std::unique_ptr< IAuxTypeVector > vec, bool isDecoration)
Explicitly add a vector to the store.
Definition: AuxStoreInternal.cxx:144
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Guid::null
static const Guid & null()
NULL-Guid: static class method.
Definition: Guid.cxx:18
SG::IAuxStoreHolder::getStoreType
virtual AuxStoreType getStoreType() const =0
Return the type of the store object.
L1CaloPhase1Monitoring.standalone
standalone
Definition: L1CaloPhase1Monitoring.py:112
SG::AuxStoreInternal::getData
virtual const void * getData(SG::auxid_t auxid) const override
Return the data vector for one aux data item.
Definition: AuxStoreInternal.cxx:83
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
SG::normalizedTypeinfoName
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Definition: normalizedTypeinfoName.cxx:120
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:881
SG::AuxStoreInternal::standalone
bool standalone() const
Return the standalone flag.
Definition: AuxStoreInternal.cxx:67
AuxDiscoverySvc::getElemName
std::string getElemName(SG::auxid_t auxid)
Definition: AuxDiscoverySvc.cxx:159
AuxDiscoverySvc::getAttrName
std::string getAttrName(SG::auxid_t auxid)
Definition: AuxDiscoverySvc.cxx:151
Guid::toString
const std::string toString() const
Automatic conversion to string representation.
Definition: Guid.cxx:58
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
SG::IAuxStoreIO::getIOType
virtual const std::type_info * getIOType(SG::auxid_t auxid) const =0
Return the type of the data to be stored for one aux data item.
AuxDiscoverySvc::setData
bool setData(SG::auxid_t auxid, void *data, const RootType &type)
Definition: AuxDiscoverySvc.cxx:65
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
AuxDiscoverySvc::setAuxStore
bool setAuxStore()
Definition: AuxDiscoverySvc.cxx:85
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
AuxDiscoverySvc::getData
const void * getData(SG::auxid_t auxid)
Definition: AuxDiscoverySvc.cxx:137
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
IAthenaSerializeSvc::serialize
virtual void * serialize(const void *object, const std::string &name, size_t &nbytes) const =0
AuxDiscoverySvc::m_store
const SG::IAuxStoreIO * m_store
Definition: AuxDiscoverySvc.h:69
SG::getDynamicAuxID
SG::auxid_t getDynamicAuxID(const std::type_info &ti, const std::string &name, const std::string &elementTypeName, const std::string &branch_type_name, bool standalone, SG::auxid_t linked_auxid)
Find the auxid for a dynamic branch.
Definition: getDynamicAuxID.cxx:64
SG::AuxTypeRegistry::getTypeName
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
Definition: AuxTypeRegistry.cxx:923
pool::DbTypeInfo::create
static DbTypeInfo * create(const std::string &cl_name)
Create type information using name.
AuxDiscoverySvc::m_storeHolder
SG::IAuxStoreHolder * m_storeHolder
Definition: AuxDiscoverySvc.h:71
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::IAuxStoreIO::getSelectedAuxIDs
virtual SG::auxid_set_t getSelectedAuxIDs() const
Get a list of dynamic variables that need to be written out.
Definition: IAuxStoreIO.h:86
IAthenaIPCTool::putObject
virtual StatusCode putObject(const void *source, size_t nbytes, int num=0)=0
AuxDiscoverySvc::m_storeInt
AthenaPoolAuxStore * m_storeInt
Definition: AuxDiscoverySvc.h:70
CxxUtils::ConcurrentBitset::empty
bool empty() const
Return true if there are no 1 bits in the set.
AuxDiscoverySvc::getAuxID
SG::auxid_t getAuxID(const std::string &attrName, const std::string &elemName, const std::string &typeName)
Definition: AuxDiscoverySvc.cxx:93
SG::IAuxStoreHolder::setStore
virtual void setStore(IAuxStore *store)=0
Give an auxiliary store object to the holder object.
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
IAthenaIPCTool::getObject
virtual StatusCode getObject(void **target, size_t &nbytes, int num=0)=0
SG::IAuxStoreIO::getIOData
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.
IAthenaSerializeSvc::deserialize
virtual void * deserialize(void *buffer, size_t &nbytes, const std::string &name) const =0
AuxDiscoverySvc::getAuxStore
bool getAuxStore(void *obj, const Guid &classId, const std::string &contId)
Definition: AuxDiscoverySvc.cxx:39
AuxDiscoverySvc::getType
const std::type_info * getType(SG::auxid_t auxid)
Definition: AuxDiscoverySvc.cxx:144
SG::AuxVectorInterface
Make an AuxVectorData object from either a raw array or an aux store.
Definition: AuxVectorInterface.h:33
python.PoolAttributeHelper.attrName
attrName
Definition: PoolAttributeHelper.py:100
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Guid::fromString
const Guid & fromString(const std::string &s)
Automatic conversion from string representation.
Definition: Guid.cxx:65
RootUtils::Type
Wrapper for ROOT types.
Definition: Type.h:40
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
AthenaPoolAuxStore
Definition: AuxDiscoverySvc.cxx:33
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::IAuxStoreHolder::AST_ObjectStore
@ AST_ObjectStore
The store describes a single object.
Definition: IAuxStoreHolder.h:67
AuxDiscoverySvc::getAuxIDs
SG::auxid_set_t getAuxIDs(const void *obj, const Guid &classId, const std::string &contId)
Definition: AuxDiscoverySvc.cxx:112
SG::IAuxStoreHolder
Interface for objects taking part in direct ROOT I/O.
Definition: IAuxStoreHolder.h:36
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
pool::DbTypeInfo
Definition: DbTypeInfo.h:47
TScopeAdapter
Definition: RootType.h:119
AuxDiscoverySvc::getTypeName
std::string getTypeName(SG::auxid_t auxid)
Definition: AuxDiscoverySvc.cxx:155