ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::ShallowAuxContainer Class Referenceabstract

Class creating a shallow copy of an existing auxiliary container. More...

#include <ShallowAuxContainer.h>

Inheritance diagram for xAOD::ShallowAuxContainer:

Public Types

typedef SG::auxid_t auxid_t
 The aux ID type definition.
typedef SG::auxid_set_t auxid_set_t
 The aux ID set type definition.
enum  AuxStoreType { AST_ObjectStore = 0 , AST_ContainerStore = 1 }
 Type of the auxiliary store. More...

Public Member Functions

 ShallowAuxContainer (bool standalone=false)
 Default constructor.
 ShallowAuxContainer (const ShallowAuxContainer &parent)
 Copy constructor.
 ShallowAuxContainer (const DataLink< SG::IConstAuxStore > &parent, bool standalone=false)
 Constructor with a parent object.
 ~ShallowAuxContainer ()
 Destructor.
ShallowAuxContainer & operator= (const ShallowAuxContainer &rhs)
 Assignment operator.
const DataLink< SG::IConstAuxStore > & parent () const
 Get the parent store.
void setParent (const DataLink< SG::IConstAuxStore > &link)
 Set the parent store.
bool shallowIO () const
 Check whether only the overriden parameters will be written out or not.
void setShallowIO (bool value)
 Set whether only the overriden parameters should be written out.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore=SG::auxid_set_t())=0
 Move all elements from other to this store.
virtual bool setOption (auxid_t, const AuxDataOption &)
 Set an option for a given auxiliary variable.
virtual IAuxTypeVector * linkedVector (SG::auxid_t)
Functions implementing the SG::IAuxStoreHolder interface
virtual SG::IAuxStore * getStore () override
 Get the currently used internal store object.
virtual const SG::IAuxStore * getStore () const override
virtual void setStore (SG::IAuxStore *store) override
 Set a different internal store object.
virtual AuxStoreType getStoreType () const override
 Return the type of the store object.
Functions implementing the SG::IConstAuxStore interface
virtual const void * getData (auxid_t auxid) const override
 Get a pointer to a given array.
virtual const SG::IAuxTypeVector * getVector (SG::auxid_t auxid) const override final
 Return vector interface for one aux data item.
virtual const auxid_set_t & getAuxIDs () const override
 Get the types(names) of variables handled by this container.
virtual const auxid_set_t & getDecorIDs () const override
 Get the types(names) of decorations handled by this container.
virtual SG::auxid_set_t getCopyIDs (bool warnUnlocked=false) const override
 Get the set of variables that we should deep copy.
virtual bool isDecoration (auxid_t auxid) const override
 Test if a variable is a decoration.
virtual void * getDecoration (auxid_t auxid, size_t size, size_t capacity) override
 Return the data vector for one aux data decoration item.
virtual void lock () override
 Lock the container.
virtual bool clearDecorations () override
 Clear all decorations.
virtual size_t size () const override
 Get the size of the container.
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration.
Functions implementing the SG::IAuxStore interface
virtual void * getData (auxid_t auxid, size_t size, size_t capacity) override
 Get a pointer to a given array, creating the array if necessary.
virtual const auxid_set_t & getWritableAuxIDs () const override
 Return a set of writable data identifiers.
virtual bool resize (size_t size) override
 Resize the arrays to a given size.
virtual void reserve (size_t size) override
 Reserve a given size for the arrays.
virtual void shift (size_t pos, ptrdiff_t offs) override
 Shift the contents of the stored arrays.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
 Insert contents of another store via move.
virtual void toTransient (const EventContext &ctx) override
 Perform processing on aux variable objects just after reading to make them usable as transient objects.
Functions implementing the SG::IAuxStoreIO interface
virtual const void * getIOData (auxid_t auxid) const override
 Get a pointer to the data being stored for one aux data item.
virtual const std::type_info * getIOType (auxid_t auxid) const override
 Return the type of the data to be stored for one aux data item.
virtual const auxid_set_t & getDynamicAuxIDs () const override
 Get the types(names) of variables created dynamically.
virtual auxid_set_t getSelectedAuxIDs () const override
 Get the IDs of the selected dynamic Aux variables (for writing).
Functions managing the instance name of the container
const char * name () const
 Get the name of the container instance.
void setName (const char *name)
 Set the name of the container instance.

Static Public Attributes

static constexpr bool supportsThinning = true
 Mark that this type supports thinning operations.

Private Types

typedef AthContainers_detail::recursive_mutex mutex_t
 Mutex for multithread synchronization.
typedef AthContainers_detail::lock_guard< mutex_t > guard_t

Private Member Functions

void remakeAuxIDs () const

Private Attributes

AuxSelection m_selection
 Dynamic attributes selection implementation.
SG::IAuxStore * m_store
 Internal dynamic auxiliary store object.
SG::IAuxStoreIO * m_storeIO
 The IO interface to the internal auxiliary store.
bool m_ownsStore
 Flag deciding if the object owns the dynamic store or not.
bool m_locked
 Flag keeping track of whether this object is locked or not.
DataLink< SG::IConstAuxStore > m_parentLink
 Link to the parent object.
const SG::IAuxStoreIO * m_parentIO
 Optional pointer to the IO interface of the parent object.
bool m_shallowIO
 Flag for whether to do "shallow IO" or not.
mutex_t m_mutex
auxid_set_t m_auxids ATLAS_THREAD_SAFE
auxid_set_t m_decorids ATLAS_THREAD_SAFE
bool m_auxidsValid ATLAS_THREAD_SAFE
std::string m_name
 Name of the container in memory. Set externally.

Detailed Description

Class creating a shallow copy of an existing auxiliary container.

During analysis, in order to create objects that override just some of the properties of an original, it's wasteful to make full copies of the objects. Not to mention that the full copies have generally issues with dynamic variables.

The behaviour of this class is that it takes all the properties that it doesn't know about from the parent auxiliary store, but the ones that it has an override for, it provides itself.

The object is persistifiable. The user can choose whether to only write out the variables that were modified wrt. the original container, or possibly all the variables. (In case the original container is not getting written out.)

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
793737
Date
2017-01-24 21:11:10 +0100 (Tue, 24 Jan 2017)

Definition at line 46 of file ShallowAuxContainer.h.

Member Typedef Documentation

◆ auxid_set_t

The aux ID set type definition.

Definition at line 56 of file ShallowAuxContainer.h.

◆ auxid_t

The aux ID type definition.

Definition at line 54 of file ShallowAuxContainer.h.

◆ guard_t

◆ mutex_t

Mutex for multithread synchronization.

Definition at line 205 of file ShallowAuxContainer.h.

Member Enumeration Documentation

◆ AuxStoreType

Type of the auxiliary store.

In the xAOD EDM we use auxiliary store objects in some cases to describe a single object, and in most cases to describe a container of objects. This enumeration declares which type the object implementing this interface is.

Enumerator
AST_ObjectStore 

The store describes a single object.

AST_ContainerStore 

The store describes a container.

Definition at line 68 of file IAuxStoreHolder.h.

68 {
69 AST_ObjectStore = 0,
71 };
@ AST_ContainerStore
The store describes a container.
@ AST_ObjectStore
The store describes a single object.

Constructor & Destructor Documentation

◆ ShallowAuxContainer() [1/3]

xAOD::ShallowAuxContainer::ShallowAuxContainer ( bool standalone = false)

Default constructor.

Parameters
standalonetrue if the store will be used for a standalone object, false for a container

Definition at line 33 of file ShallowAuxContainer.cxx.

34 : m_selection(),
35 m_store( new SG::AuxStoreInternal( standalone ) ),
36 m_storeIO( nullptr ), m_ownsStore( true ), m_locked( false ),
37 m_parentLink(), m_parentIO( nullptr ), m_shallowIO( true ),
38 m_auxids (),
39 m_auxidsValid (false),
40 m_name( "UNKNOWN" ) {
41
42 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
43 }
bool m_locked
Flag keeping track of whether this object is locked or not.
SG::IAuxStore * m_store
Internal dynamic auxiliary store object.
bool m_shallowIO
Flag for whether to do "shallow IO" or not.
bool m_ownsStore
Flag deciding if the object owns the dynamic store or not.
SG::IAuxStoreIO * m_storeIO
The IO interface to the internal auxiliary store.
DataLink< SG::IConstAuxStore > m_parentLink
Link to the parent object.
const SG::IAuxStoreIO * m_parentIO
Optional pointer to the IO interface of the parent object.
AuxSelection m_selection
Dynamic attributes selection implementation.
std::string m_name
Name of the container in memory. Set externally.
SG::auxid_set_t m_auxids
Set of auxid's for which we've created a vector.
AuxStoreInternal(bool standalone=false)
An auxiliary data store that holds data internally.

◆ ShallowAuxContainer() [2/3]

xAOD::ShallowAuxContainer::ShallowAuxContainer ( const ShallowAuxContainer & parent)

Copy constructor.

Definition at line 45 of file ShallowAuxContainer.cxx.

46 : SG::IAuxStore(), SG::IAuxStoreIO(), SG::IAuxStoreHolder(),
47 m_ownsStore( false ),
48 m_auxids (),
49 m_auxidsValid (false)
50 {
51 // Keep the source unmutable during copy
52 guard_t guard( parent.m_mutex );
53 // cppcheck-suppress copyCtorPointerCopying
54 m_store = parent.m_store;
55 m_storeIO = parent.m_storeIO;
56 m_locked = parent.m_locked;
57 m_parentLink = parent.m_parentLink;
58 m_parentIO = parent.m_parentIO;
59 m_shallowIO = parent.m_shallowIO;
60 m_selection = parent.m_selection;
61 m_name = parent.m_name;
62 }
AthContainers_detail::lock_guard< mutex_t > guard_t
const DataLink< SG::IConstAuxStore > & parent() const
Get the parent store.

◆ ShallowAuxContainer() [3/3]

xAOD::ShallowAuxContainer::ShallowAuxContainer ( const DataLink< SG::IConstAuxStore > & parent,
bool standalone = false )

Constructor with a parent object.

Parameters
parentThe parent object to make a shallow copy of
standalonetrue if the store will be used for a standalone object, false for a container

Definition at line 68 of file ShallowAuxContainer.cxx.

71 : m_selection(),
72 m_store( new SG::AuxStoreInternal( standalone ) ),
73 m_storeIO( nullptr ), m_ownsStore( true ), m_locked( false ),
74 m_parentLink( parent ), m_parentIO( nullptr ), m_shallowIO( true ),
75 m_auxids (),
76 m_auxidsValid (false),
77 m_name( "UNKNOWN" ) {
78
79 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
80 m_parentIO = dynamic_cast< const SG::IAuxStoreIO* >( m_parentLink.cptr() );
81 }

◆ ~ShallowAuxContainer()

xAOD::ShallowAuxContainer::~ShallowAuxContainer ( )

Destructor.

Definition at line 83 of file ShallowAuxContainer.cxx.

83 {
84
85 if( m_ownsStore && m_store ) {
86 delete m_store;
87 }
88 }

Member Function Documentation

◆ clearDecorations()

bool xAOD::ShallowAuxContainer::clearDecorations ( )
overridevirtual

Clear all decorations.

Definition at line 385 of file ShallowAuxContainer.cxx.

386 {
387 guard_t guard (m_mutex);
388 bool ret = m_store->clearDecorations();
389 if (ret) {
390 remakeAuxIDs();
391 }
392 return ret;
393 }

◆ getAuxIDs()

const ShallowAuxContainer::auxid_set_t & xAOD::ShallowAuxContainer::getAuxIDs ( ) const
overridevirtual

Get the types(names) of variables handled by this container.

Definition at line 233 of file ShallowAuxContainer.cxx.

233 {
234
235 guard_t guard( m_mutex );
236 if (!m_auxidsValid) {
237 remakeAuxIDs();
238 }
239 return m_auxids;
240 }

◆ getCopyIDs()

SG::auxid_set_t xAOD::ShallowAuxContainer::getCopyIDs ( bool warnUnlocked = false) const
overridevirtual

Get the set of variables that we should deep copy.

Definition at line 252 of file ShallowAuxContainer.cxx.

253 {
254 guard_t guard( m_mutex );
256 if( m_parentLink.isValid() ) {
257 ids.insert (m_parentLink->getCopyIDs (warnUnlocked));
258 }
259 ids.insert (m_store->getCopyIDs (warnUnlocked));
260 return ids;
261 }
SG::auxid_set_t auxid_set_t
The aux ID set type definition.

◆ getData() [1/2]

const void * xAOD::ShallowAuxContainer::getData ( auxid_t auxid) const
overridevirtual

Get a pointer to a given array.

Definition at line 193 of file ShallowAuxContainer.cxx.

193 {
194
195 const SG::IAuxTypeVector* v = getVector( auxid );
196 if( v ) {
197 return v->toPtr();
198 }
199 return nullptr;
200 }
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override final
Return vector interface for one aux data item.

◆ getData() [2/2]

void * xAOD::ShallowAuxContainer::getData ( auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Get a pointer to a given array, creating the array if necessary.

Implements SG::IAuxStore.

Definition at line 404 of file ShallowAuxContainer.cxx.

405 {
406
407 guard_t guard (m_mutex);
408
409 // Check if we already have this variable by any chance.
410 const void* cptr = m_store->getData( auxid );
411
412 // Create the variable in the dynamic store:
413 void* ptr = m_store->getData( auxid, size, capacity );
414
415 // If in some weird way we already had this variable before, then don't
416 // try to overwrite it with the parent's payload, and finish here already.
417 if( cptr != nullptr ) {
418 return ptr;
419 }
420
421 remakeAuxIDs();
422
423 // If the parent doesn't have this variable, then we're done already:
424 if( ! m_parentLink.isValid() ) {
425 return ptr;
426 }
427 const void* pptr = m_parentLink->getData( auxid );
428 if( ! pptr ) {
429 return ptr;
430 }
431
432 // If the variable does exist in the parent, then copy it over to this
433 // store before returning.
434
435 // Get the registry:
436 SG::AuxTypeRegistry& reg = SG::AuxTypeRegistry::instance();
437
438 // Get the type of this variable:
439 const std::type_info* type = reg.getType( auxid );
440 if( type == nullptr ) {
441 throw std::runtime_error( std::format( "Couldn't find the type of auxiliary ID {}", auxid ) );
442 }
443
444 // And the allocator type for this variable.
445 const std::type_info* allocType = reg.getAllocType( auxid );
446 if( allocType == nullptr ) {
447 throw std::runtime_error( std::format( "Couldn't find the allocator type of auxiliary ID {}", auxid ) );
448 }
449
450 // First let's get the vector factory of this variable:
451 const SG::IAuxTypeVectorFactory* factory =
452 SG::AuxTypeRegistry::instance().getFactory( *type, *allocType );
453 if( factory == nullptr ) {
454 throw std::runtime_error( std::format( "Couldn't find a factory for type {}", type->name() ) );
455 }
456
457 // Copy each element of the parent's decoration:
458 factory->copy( auxid,
459 SG::AuxVectorInterface( *this ), 0,
460 SG::AuxVectorInterface( *m_parentLink ), 0, size );
461
462 // Now we're done:
463 return ptr;
464 }
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.
virtual size_t size() const override
Get the size of the container.
void * ptr(T *p)
Definition SGImplSvc.cxx:75

◆ getDecoration()

void * xAOD::ShallowAuxContainer::getDecoration ( auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Return the data vector for one aux data decoration item.

Definition at line 275 of file ShallowAuxContainer.cxx.

277 {
278
279 guard_t guard( m_mutex );
280
281 // Check if we already have this variable by any chance.
282 const void* cptr = m_store->getData( auxid );
283
284 // If the parent has such a variable, then we need to check one more
285 // thing. If it's a decoration on the parent, then we should be allowed
286 // to override it in this (possibly locked) shallow copy. But let's leave
287 // the logic of this up to the parent.
288 if( m_locked && m_parentLink.isValid() &&
289 ( m_parentLink->getAuxIDs().count( auxid ) > 0 ) )
290 {
291 if (!m_parentLink->isDecoration (auxid)) {
292 throw SG::ExcStoreLocked (auxid);
293 }
294 }
295
296 // If we got this far without any exception, then let the internal store
297 // try to provide the decoration for us:
298 const size_t nids = m_store->getAuxIDs().size();
299 void* result = m_store->getDecoration( auxid, size, capacity );
300 if( result && ( nids != m_store->getAuxIDs().size() ) ) {
301 remakeAuxIDs();
302 }
303
304 // If we already had this variable before, then don't try to overwrite it
305 // with the parent's payload, and finish here already.
306 if( cptr != nullptr ) {
307 return result;
308 }
309
310 // If the parent doesn't have this variable, then we're done.
311 if( ! m_parentLink.isValid() ) {
312 return result;
313 }
314 const void* pptr = m_parentLink->getData( auxid );
315 if( pptr == nullptr ) {
316 return result;
317 }
318
319 // If the variable does exist in the parent, then copy it over to this
320 // store before returning.
321
322 // Get the registry.
323 SG::AuxTypeRegistry& reg = SG::AuxTypeRegistry::instance();
324
325 // Get the type of this variable.
326 const std::type_info* type = reg.getType( auxid );
327 if( type == nullptr ) {
328 throw std::runtime_error( std::format( "Couldn't find the type of auxiliary ID {}", auxid ) );
329 }
330
331 // And the allocator type for this variable.
332 const std::type_info* allocType = reg.getAllocType( auxid );
333 if( allocType == nullptr ) {
334 throw std::runtime_error( std::format( "Couldn't find the allocator type of auxiliary ID {}", auxid ) );
335 }
336
337 // Get the vector factory of this variable.
338 const SG::IAuxTypeVectorFactory* factory =
339 SG::AuxTypeRegistry::instance().getFactory( *type, *allocType );
340 if( factory == nullptr ) {
341 throw std::runtime_error( std::format( "Couldn't find a factory for type {}", type->name() ) );
342 }
343
344 // Copy each element of the parent's decoration.
345 factory->copy( auxid,
346 SG::AuxVectorInterface( *this ), 0,
347 SG::AuxVectorInterface( *m_parentLink ), 0, size );
348
349 // Now we're done.
350 return result;
351 }

◆ getDecorIDs()

const ShallowAuxContainer::auxid_set_t & xAOD::ShallowAuxContainer::getDecorIDs ( ) const
overridevirtual

Get the types(names) of decorations handled by this container.

Definition at line 243 of file ShallowAuxContainer.cxx.

243 {
244
245 guard_t guard( m_mutex );
246 if (!m_auxidsValid) {
247 remakeAuxIDs();
248 }
249 return m_decorids;
250 }

◆ getDynamicAuxIDs()

const ShallowAuxContainer::auxid_set_t & xAOD::ShallowAuxContainer::getDynamicAuxIDs ( ) const
overridevirtual

Get the types(names) of variables created dynamically.

Implements SG::IAuxStoreIO.

Definition at line 572 of file ShallowAuxContainer.cxx.

572 {
573
574 if( m_shallowIO ) {
575 if( m_storeIO ) {
576 return m_store->getAuxIDs();
577 } else {
578 static const auxid_set_t dummy (0);
579 return dummy;
580 }
581 } else {
582 return getAuxIDs();
583 }
584 }
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.

◆ getIOData()

const void * xAOD::ShallowAuxContainer::getIOData ( auxid_t auxid) const
overridevirtual

Get a pointer to the data being stored for one aux data item.

Implements SG::IAuxStoreIO.

Definition at line 521 of file ShallowAuxContainer.cxx.

521 {
522
523 guard_t guard (m_mutex);
524 // Do we have it?
525 if( m_storeIO && m_store->getAuxIDs().test (auxid)) {
526 return m_storeIO->getIOData( auxid );
527 }
528
529 // Do we have a parent that has it?
530 const SG::IAuxStoreIO* parentIO = m_parentIO;
531 if( ( parentIO == nullptr ) && m_parentLink.isValid() ) {
532 parentIO =
533 dynamic_cast< const SG::IAuxStoreIO* >( m_parentLink.cptr() );
534 }
535 if( parentIO ) {
536 return parentIO->getIOData( auxid );
537 }
538
539 // If not, then where did this variable come from?!?
540 std::println( std::cerr, "ERROR xAOD::ShallowAuxContainer::getIOData Unknown "
541 "variable ({}) requested",
543 return nullptr;
544 }
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.

◆ getIOType()

const std::type_info * xAOD::ShallowAuxContainer::getIOType ( auxid_t auxid) const
overridevirtual

Return the type of the data to be stored for one aux data item.

Implements SG::IAuxStoreIO.

Definition at line 546 of file ShallowAuxContainer.cxx.

546 {
547
548 guard_t guard (m_mutex);
549 // Do we have it?
550 if( m_storeIO && m_store->getAuxIDs().test (auxid)) {
551 return m_storeIO->getIOType( auxid );
552 }
553
554 // Do we have a parent that has it?
555 const SG::IAuxStoreIO* parentIO = m_parentIO;
556 if( ( parentIO == nullptr ) && m_parentLink.isValid() ) {
557 parentIO =
558 dynamic_cast< const SG::IAuxStoreIO* >( m_parentLink.cptr() );
559 }
560 if( parentIO ) {
561 return parentIO->getIOType( auxid );
562 }
563
564 // If not, then where did this variable come from?!?
565 std::println( std::cerr, "ERROR xAOD::ShallowAuxContainer::getIOType Unknown "
566 "variable ({}) requested",
568 return nullptr;
569 }
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.

◆ getSelectedAuxIDs()

ShallowAuxContainer::auxid_set_t xAOD::ShallowAuxContainer::getSelectedAuxIDs ( ) const
overridevirtual

Get the IDs of the selected dynamic Aux variables (for writing).

Reimplemented from SG::IAuxStoreIO.

Definition at line 587 of file ShallowAuxContainer.cxx.

587 {
588
589 if( m_shallowIO ) {
590 if( m_storeIO ) {
591 return m_selection.getSelectedAuxIDs( m_store->getAuxIDs() );
592 } else {
593 return auxid_set_t();
594 }
595 } else {
596 return m_selection.getSelectedAuxIDs( getAuxIDs() );
597 }
598 }

◆ getStore() [1/2]

const SG::IAuxStore * xAOD::ShallowAuxContainer::getStore ( ) const
overridevirtual

Implements SG::IAuxStoreHolder.

Definition at line 160 of file ShallowAuxContainer.cxx.

161 {
162 return m_store;
163 }

◆ getStore() [2/2]

SG::IAuxStore * xAOD::ShallowAuxContainer::getStore ( )
overridevirtual

Get the currently used internal store object.

Implements SG::IAuxStoreHolder.

Definition at line 155 of file ShallowAuxContainer.cxx.

156 {
157 return m_store;
158 }

◆ getStoreType()

virtual AuxStoreType xAOD::ShallowAuxContainer::getStoreType ( ) const
inlineoverridevirtual

Return the type of the store object.

Implements SG::IAuxStoreHolder.

Reimplemented in xAOD::ShallowAuxInfo.

Definition at line 90 of file ShallowAuxContainer.h.

90{ return AST_ContainerStore; }

◆ getVector()

const SG::IAuxTypeVector * xAOD::ShallowAuxContainer::getVector ( SG::auxid_t auxid) const
finaloverridevirtual

Return vector interface for one aux data item.

Definition at line 202 of file ShallowAuxContainer.cxx.

202 {
203
204 guard_t guard( m_mutex );
205
206 // Check if we have this variable ourselves. I use getData(...)
207 // instead of getAuxIDs(), as a dynamic store may not have connected
208 // to all the variables yet that it has available...
209 size_t nids = m_store->getAuxIDs().size();
210 const SG::IAuxTypeVector* result = m_store->getVector( auxid );
211 if( result != nullptr && result->toPtr() != nullptr ) {
212 if( nids != m_store->getAuxIDs().size() ) {
213 remakeAuxIDs();
214 }
215 return result;
216 }
217
218 // If not, then leave it up to the parent object do deal with this:
219 if( m_parentLink.isValid() ) {
220 nids = m_parentLink->getAuxIDs().size();
221 result = m_parentLink->getVector( auxid );
222 if( result && ( nids != m_parentLink->getAuxIDs().size() ) ) {
223 remakeAuxIDs();
224 }
225 return result;
226 }
227
228 // Apparently the variable wasn't found:
229 return nullptr;
230 }

◆ getWritableAuxIDs()

const ShallowAuxContainer::auxid_set_t & xAOD::ShallowAuxContainer::getWritableAuxIDs ( ) const
overridevirtual

Return a set of writable data identifiers.

Implements SG::IAuxStore.

Definition at line 467 of file ShallowAuxContainer.cxx.

467 {
468
469 // Only the variables in the dynamic store are writable. Maybe not
470 // even all of those...
471 return m_store->getWritableAuxIDs();
472 }

◆ insertMove() [1/2]

virtual bool SG::IAuxStore::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore = SG::auxid_set_t() )
pure virtualinherited

Move all elements from other to this store.

Parameters
posThe starting index of the insertion.
otherStore from which to do the move.
ignoreSet of variables that should not be added to the store.

Let len be the size of other. The store will be increased in size by len elements, with the elements at pos being copied to pos+len. Then, for each auxiliary variable, the entire contents of that variable for other will be moved to this store at index pos. This will be done via move semantics if possible; otherwise, it will be done with a copy. Variables present in this store but not in other will have the corresponding elements default-initialized. Variables in other but not in this store will be added unless they are in ignore.

Returns true if it is known that none of the vectors' memory moved, false otherwise.

◆ insertMove() [2/2]

bool xAOD::ShallowAuxContainer::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore )
overridevirtual

Insert contents of another store via move.

Definition at line 498 of file ShallowAuxContainer.cxx.

500 {
501
502 // Nope, not allowed...
503 throw std::runtime_error( "Trying to call insertMove on a shallow copy "
504 "container" );
505 }

◆ isDecoration()

bool xAOD::ShallowAuxContainer::isDecoration ( auxid_t auxid) const
overridevirtual

Test if a variable is a decoration.

Definition at line 263 of file ShallowAuxContainer.cxx.

264 {
265 guard_t guard( m_mutex );
266 if (m_parentLink.isValid()) {
267 if (m_parentLink->isDecoration (auxid)) {
268 return true;
269 }
270 }
271 return m_store->isDecoration (auxid);
272 }

◆ linkedVector()

virtual IAuxTypeVector * SG::IAuxStore::linkedVector ( SG::auxid_t )
inlinevirtualinherited

Reimplemented in xAOD::AuxContainerBase, xAOD::AuxInfoBase, and xAOD::details::AuxStoreBase.

Definition at line 203 of file IAuxStore.h.

204 { return nullptr; }

◆ lock()

void xAOD::ShallowAuxContainer::lock ( )
overridevirtual

Lock the container.

Definition at line 355 of file ShallowAuxContainer.cxx.

356 {
357 guard_t guard (m_mutex);
358 m_locked = true;
359 m_store->lock();
360 }

◆ lockDecoration()

void xAOD::ShallowAuxContainer::lockDecoration ( SG::auxid_t auxid)
overridevirtual

Lock a decoration.

Definition at line 364 of file ShallowAuxContainer.cxx.

365 {
366 guard_t guard (m_mutex);
367 m_store->lockDecoration (auxid);
368 m_auxidsValid = false;
369 }

◆ name()

const char * xAOD::ShallowAuxContainer::name ( ) const

Get the name of the container instance.

Definition at line 604 of file ShallowAuxContainer.cxx.

604 {
605
606 return m_name.c_str();
607 }

◆ operator=()

ShallowAuxContainer & xAOD::ShallowAuxContainer::operator= ( const ShallowAuxContainer & rhs)

Assignment operator.

Definition at line 91 of file ShallowAuxContainer.cxx.

91 {
92
93 // Check if anything needs to be done:
94 if( this == &rhs ) {
95 return *this;
96 }
97
98 // Keep the source unmutable during copy
99 std::scoped_lock lck{m_mutex, rhs.m_mutex};
100
101 // Clean up if necessary:
102 if( m_ownsStore && m_store ) {
103 delete m_store;
104 m_store = nullptr;
105 }
106
107 m_selection = rhs.m_selection;
108 m_ownsStore = false;
109 m_store = rhs.m_store;
110 m_storeIO = rhs.m_storeIO;
111 m_locked = rhs.m_locked;
112 m_parentLink = rhs.m_parentLink;
113 m_parentIO = rhs.m_parentIO;
114 m_shallowIO = rhs.m_shallowIO;
115 m_name = rhs.m_name;
116 m_auxids = rhs.m_auxids;
117 m_auxidsValid= rhs.m_auxidsValid;
118
119 // Return this object:
120 return *this;
121 }

◆ parent()

const DataLink< SG::IConstAuxStore > & xAOD::ShallowAuxContainer::parent ( ) const

Get the parent store.

Definition at line 123 of file ShallowAuxContainer.cxx.

123 {
124
125 return m_parentLink;
126 }

◆ remakeAuxIDs()

void xAOD::ShallowAuxContainer::remakeAuxIDs ( ) const
private

Definition at line 615 of file ShallowAuxContainer.cxx.

615 {
616 auxid_set_t ids = m_store->getAuxIDs();
617 if( m_parentLink.isValid() ) {
618 ids.insert (m_parentLink->getAuxIDs());
619 }
620
621 auxid_set_t decors = m_store->getDecorIDs();
622 if( m_parentLink.isValid() ) {
623 ids.insert (m_parentLink->getDecorIDs());
624 }
625
626 // Move assignment no longer clears garbage for the LHS.
627 // To limit the buildup of garbage, we do this assignment operation
628 // via copy it it will fit, only doing a move in the case where
629 // the table would need to be expanded (and we would thus generate
630 // garbage anyway). This is a non-atomic update, but that
631 // shouldn't matter for our purposes here.
632 if (decors.capacity() > m_decorids.capacity())
633 m_decorids = std::move(decors);
634 else
635 m_decorids = decors;
636
637 // Ensure that decoration updates are visible to other threads before
638 // auxid updates.
639 std::atomic_thread_fence( std::memory_order_seq_cst );
640
641 if (ids.capacity() > m_auxids.capacity())
642 m_auxids = std::move(ids);
643 else
644 m_auxids = ids;
645
646 m_auxidsValid = true;
647 }

◆ reserve()

void xAOD::ShallowAuxContainer::reserve ( size_t size)
overridevirtual

Reserve a given size for the arrays.

Implements SG::IAuxStore.

Definition at line 484 of file ShallowAuxContainer.cxx.

484 {
485
486 // Nope, not allowed...
487 throw std::runtime_error( "Trying to call reserve on a shallow copy "
488 "container" );
489 }

◆ resize()

bool xAOD::ShallowAuxContainer::resize ( size_t size)
overridevirtual

Resize the arrays to a given size.

Implements SG::IAuxStore.

Definition at line 474 of file ShallowAuxContainer.cxx.

475 {
476 if (size == this->size()) {
477 return false;
478 }
479 // Nope, not allowed...
480 throw std::runtime_error( "Trying to call resize on a shallow copy "
481 "container" );
482 }

◆ setName()

void xAOD::ShallowAuxContainer::setName ( const char * name)

Set the name of the container instance.

Definition at line 609 of file ShallowAuxContainer.cxx.

609 {
610
611 m_name = name;
612 return;
613 }
const char * name() const
Get the name of the container instance.

◆ setOption()

virtual bool SG::IAuxStore::setOption ( auxid_t ,
const AuxDataOption &  )
inlinevirtualinherited

Set an option for a given auxiliary variable.

Parameters
auxidThe identifier of the desired aux data item.
optionThe option to set.

The interpretation of the option depends on the particular representation of the variable.

Returns true if the option setting was successful; false otherwise.

Reimplemented in xAOD::AuxContainerBase, and xAOD::AuxInfoBase.

Definition at line 189 of file IAuxStore.h.

190 { return false; }

◆ setParent()

void xAOD::ShallowAuxContainer::setParent ( const DataLink< SG::IConstAuxStore > & link)

Set the parent store.

Definition at line 128 of file ShallowAuxContainer.cxx.

129 {
130
131 guard_t guard (m_mutex);
133 m_parentIO = dynamic_cast< const SG::IAuxStoreIO* >( m_parentLink.cptr() );
134 m_auxidsValid = false;
135 return;
136 }
pointer & link(pointer p) const
Return a reference to the link for an element.

◆ setShallowIO()

void xAOD::ShallowAuxContainer::setShallowIO ( bool value)

Set whether only the overriden parameters should be written out.

Definition at line 143 of file ShallowAuxContainer.cxx.

143 {
144
145 guard_t guard (m_mutex);
147 return;
148 }

◆ setStore()

void xAOD::ShallowAuxContainer::setStore ( SG::IAuxStore * store)
overridevirtual

Set a different internal store object.

Implements SG::IAuxStoreHolder.

Definition at line 165 of file ShallowAuxContainer.cxx.

165 {
166
167 // Check if anything needs to be done:
168 guard_t guard (m_mutex);
169 if( store == m_store ) return;
170
171 if( m_ownsStore && m_store ) {
172 delete m_store;
173 m_store = nullptr;
174 }
175
176 // Do the assignment:
177 m_store = store;
178 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
179 m_ownsStore = true;
180 m_auxidsValid = false;
181
182 return;
183 }
TestStore store
Definition TestStore.cxx:23

◆ shallowIO()

bool xAOD::ShallowAuxContainer::shallowIO ( ) const

Check whether only the overriden parameters will be written out or not.

Definition at line 138 of file ShallowAuxContainer.cxx.

138 {
139
140 return m_shallowIO;
141 }

◆ shift()

void xAOD::ShallowAuxContainer::shift ( size_t pos,
ptrdiff_t offs )
overridevirtual

Shift the contents of the stored arrays.

Implements SG::IAuxStore.

Definition at line 491 of file ShallowAuxContainer.cxx.

491 {
492
493 // Nope, not allowed...
494 throw std::runtime_error( "Trying to call shift on a shallow copy "
495 "container" );
496 }

◆ size()

size_t xAOD::ShallowAuxContainer::size ( ) const
overridevirtual

Get the size of the container.

Definition at line 371 of file ShallowAuxContainer.cxx.

371 {
372
373 guard_t guard( m_mutex );
374 size_t sz = m_store->size();
375 if( sz > 0 ) {
376 return sz;
377 }
378 if( m_parentLink.isValid() ) {
379 return m_parentLink->size();
380 }
381 return 0;
382 }
static Double_t sz

◆ toTransient()

void xAOD::ShallowAuxContainer::toTransient ( const EventContext & ctx)
overridevirtual

Perform processing on aux variable objects just after reading to make them usable as transient objects.

Implements SG::IAuxStore.

Definition at line 507 of file ShallowAuxContainer.cxx.

507 {
508 m_parentLink.toTransient( ctx );
509 m_store->toTransient( ctx );
510 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/3]

bool m_auxidsValid xAOD::ShallowAuxContainer::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 213 of file ShallowAuxContainer.h.

◆ ATLAS_THREAD_SAFE [2/3]

auxid_set_t m_decorids xAOD::ShallowAuxContainer::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 212 of file ShallowAuxContainer.h.

◆ ATLAS_THREAD_SAFE [3/3]

auxid_set_t m_auxids xAOD::ShallowAuxContainer::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 211 of file ShallowAuxContainer.h.

◆ m_locked

bool xAOD::ShallowAuxContainer::m_locked
private

Flag keeping track of whether this object is locked or not.

Definition at line 195 of file ShallowAuxContainer.h.

◆ m_mutex

mutex_t xAOD::ShallowAuxContainer::m_mutex
mutableprivate

Definition at line 207 of file ShallowAuxContainer.h.

◆ m_name

std::string xAOD::ShallowAuxContainer::m_name
private

Name of the container in memory. Set externally.

Definition at line 216 of file ShallowAuxContainer.h.

◆ m_ownsStore

bool xAOD::ShallowAuxContainer::m_ownsStore
private

Flag deciding if the object owns the dynamic store or not.

Definition at line 193 of file ShallowAuxContainer.h.

◆ m_parentIO

const SG::IAuxStoreIO* xAOD::ShallowAuxContainer::m_parentIO
private

Optional pointer to the IO interface of the parent object.

Definition at line 200 of file ShallowAuxContainer.h.

◆ m_parentLink

DataLink< SG::IConstAuxStore > xAOD::ShallowAuxContainer::m_parentLink
private

Link to the parent object.

Definition at line 198 of file ShallowAuxContainer.h.

◆ m_selection

AuxSelection xAOD::ShallowAuxContainer::m_selection
private

Dynamic attributes selection implementation.

Definition at line 186 of file ShallowAuxContainer.h.

◆ m_shallowIO

bool xAOD::ShallowAuxContainer::m_shallowIO
private

Flag for whether to do "shallow IO" or not.

Definition at line 202 of file ShallowAuxContainer.h.

◆ m_store

SG::IAuxStore* xAOD::ShallowAuxContainer::m_store
private

Internal dynamic auxiliary store object.

Definition at line 189 of file ShallowAuxContainer.h.

◆ m_storeIO

SG::IAuxStoreIO* xAOD::ShallowAuxContainer::m_storeIO
private

The IO interface to the internal auxiliary store.

Definition at line 191 of file ShallowAuxContainer.h.

◆ supportsThinning

bool SG::IAuxStore::supportsThinning = true
staticconstexprinherited

Mark that this type supports thinning operations.

See AthContainers/supportsThinning.h and AthenaPoolCnvSvc/T_AthenaPoolCnv.h. Helps guide which pool converter template will be used. If false, the default pool converter will be used rather than the aux store-specific one. Ordinary xAOD type should not touch this, but may be overridden in a derived class to handle certain special cases.

Definition at line 216 of file IAuxStore.h.


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