18 const std::string emptyStr{};
25 m_int(), m_float(), m_vecInt(), m_vecFloat(),
34 :
SG::IAuxStore( parent ),
35 m_int( parent.m_int ), m_float( parent.m_float ),
36 m_vecInt( parent.m_vecInt ), m_vecFloat( parent.m_vecFloat ),
38 m_auxids( parent.m_auxids ),
49 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
50 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
51 for( ; itr != end; ++itr ) {
52 if( *itr )
delete *itr;
56 for( ; itr != end; ++itr ) {
57 if( *itr )
delete *itr;
68 m_float = rhs.m_float;
69 m_vecInt = rhs.m_vecInt;
70 m_vecFloat = rhs.m_vecFloat;
73 m_auxids = rhs.m_auxids;
78 for(
auto* ptr : m_dynamicVecs ) {
81 m_dynamicVecs.clear();
109 else if( ( auxid < m_dynamicVecs.size() ) &&
110 ( m_dynamicVecs[ auxid ] ) ) {
112 return m_dynamicVecs[ auxid ];
148 else if( ( auxid < m_dynamicVecs.size() ) &&
149 ( m_dynamicVecs[ auxid ] ) ) {
150 ret = m_dynamicVecs[ auxid ]->toPtr();
174 std::atomic_thread_fence (std::memory_order_seq_cst);
210 bool anycleared =
false;
212 if (m_dynamicVecs[auxid]) {
213 delete m_dynamicVecs[auxid];
214 m_dynamicVecs[auxid] =
nullptr;
215 m_auxids.erase( auxid );
218 const std::string
name =
r.getName( auxid );
219 const std::type_info* ti =
r.getType( auxid );
220 if (ti == &
typeid(
int))
222 else if (ti == &
typeid(
float))
223 m_float.erase (
name);
224 else if (ti == &
typeid(std::vector<int>))
225 m_vecInt.erase (
name);
226 else if (ti == &
typeid(std::vector<float>))
227 m_vecFloat.erase (
name);
252 if (i < m_dynamicVecs.size() && m_dynamicVecs[i]) {
253 size_t sz = m_dynamicVecs[i]->size();
283 else if( ( auxid < m_dynamicVecs.size() ) &&
284 ( m_dynamicVecs[ auxid ] ) ) {
286 m_dynamicVecs[ auxid ]->reserve( capacity );
287 m_dynamicVecs[ auxid ]->resize(
size );
289 return m_dynamicVecs[ auxid ]->toPtr();
315 if (!v->resize(
size ))
322 if (!v->resize(
size ))
337 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
338 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
339 for( ; itr != end; ++itr ) {
340 if( *itr ) ( *itr )->reserve(
size );
344 for( ; itr != end; ++itr ) {
345 if( *itr ) ( *itr )->reserve(
size );
358 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
359 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
360 for( ; itr != end; ++itr ) {
361 if( *itr ) ( *itr )->shift( pos, offs );
365 for( ; itr != end; ++itr ) {
366 if( *itr ) ( *itr )->shift( pos, offs );
384 size_t other_size =
other.size();
391 if (
id < m_dynamicVecs.size())
392 v_dst = m_dynamicVecs[id];
397 if (
other.getData (
id)) {
398 void* src_ptr =
other.getData (
id, other_size, other_size);
400 if (!v_dst->
insertMove (pos, src_ptr, 0, other_size,
406 const void* orig = v_dst->
toPtr();
407 v_dst->
shift (pos, other_size);
408 if (orig != v_dst->
toPtr())
416 if (!m_auxids.test(
id) &&
419 if (
other.getData (
id)) {
420 void* src_ptr =
other.getData (
id, other_size, other_size);
424 m_dynamicVecs[id]->resize (
sz - other_size);
425 (void)m_dynamicVecs[
id]->
insertMove (pos, src_ptr, 0, other_size,
443 m_dynamicVecs.clear();
446#define ADD_IDS(VAR, TYP) \
447 do { typedef std::map< std::string, std::vector< TYP > > CONT; \
448 for (CONT::value_type& p : VAR) \
449 m_auxids.insert (r.getAuxID< TYP > (p.first, emptyStr, SG::AuxVarFlags::SkipNameCheck)); } while(0)
452 ADD_IDS(m_vecInt, std::vector<int>);
453 ADD_IDS(m_vecFloat, std::vector<float>);
472 template<
typename T >
475 std::map< std::string,
476 std::vector< T > >& pers,
477 size_t size,
size_t capacity,
479 bool forDecor)
const {
485 const std::string
name =
r.getName( auxid );
488 typename std::map< std::string, std::vector< T > >
::iterator itr =
490 if( itr == pers.end() ) {
494 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData (const) "
495 <<
"Variable with unknown name (" <<
name <<
") requested"
504 if (
r.isLinked(auxid)) {
505 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1 doesn't implement linked variables"
511 itr = pers.insert (std::make_pair (
name, std::vector<T>())).first;
515 std::vector< T >& var = itr->second;
518 if( m_dynamicVecs.size() <= auxid ) {
519 m_dynamicVecs.resize( auxid + 1 );
523 if( m_dynamicVecs[ auxid ] ) {
524 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData "
525 <<
"Internal inconsistency detected!" << std::endl;
526 return m_dynamicVecs[ auxid ];
534 m_dynamicVecs[ auxid ]->reserve( capacity );
535 m_dynamicVecs[ auxid ]->resize(
size );
539 m_auxids.insert( auxid );
542 return m_dynamicVecs[ auxid ];
547 size_t size,
size_t capacity,
549 bool forDecor)
const {
564 typeid( std::vector< int > ) ) {
569 typeid( std::vector< float > ) ) {
575 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData "
576 <<
"Unknown variable type ("
578 <<
") requested for variable "
580 <<
" (" << auxid <<
")"
591 v->toTransient( ctx );
596 v->toTransient( ctx );
An auxiliary data store that holds data internally.
Handle mappings between names and auxid_t.
#define ADD_IDS(VAR, TYP)
Exceptions that can be thrown from AthContainers.
Handle mappings between names and auxid_t.
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Exception — Attempted to modify auxiliary data in a locked store.
Abstract interface for manipulating vectors of arbitrary types.
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.
virtual bool insertMove(size_t pos, void *src, size_t src_pos, size_t src_n, IAuxStore &srcStore)=0
Insert elements into the vector via move semantics.
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
A set of aux data identifiers.
Class managing concrete vector variables.
Base class for dynamic auxiliary stores saved into ByteStream.
SG::auxid_set_t m_decorations
Record which variables are decorations.
SG::auxid_set_t auxid_set_t
The aux ID set type definition from IConstAuxStore.
virtual const SG::IAuxTypeVector * getVector(auxid_t auxid) const override final
Return vector interface for one aux data item.
virtual size_t size() const override
Get the size of the container.
size_t size_noLock() const
Internal method: return size without taking out the lock.
virtual const auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
void setName(const char *name)
Set the name of the container instance.
virtual void * getDecoration(auxid_t auxid, size_t size, size_t capacity) override
Get a pointer to a given array, as a decoration.
const char * name() const
Get the name of the container instance.
virtual bool insertMove(size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
Insert contents of another store via move.
ByteStreamAuxContainer_v1 & operator=(const ByteStreamAuxContainer_v1 &rhs)
Assignment operator.
virtual bool resize(size_t size) override
Resize the arrays to a given size.
std::vector< SG::IAuxTypeVector * > m_staticVecs
Internal list of static managed variables.
SG::IAuxTypeVector * getVector1(auxid_t auxid, std::map< std::string, std::vector< T > > &pers, size_t size, size_t capacity, bool quiet, bool forDecor) const
Function retrieving a simple dynamic variable.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Get the set of variables that we should deep copy.
bool m_locked
Has the container been locked?
ByteStreamAuxContainer_v1()
Default constructor.
virtual const auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
virtual bool clearDecorations() override
Clear all decorations.
virtual bool isDecoration(auxid_t auxid) const override
Test if a variable is a decoration.
virtual void lock() override
Lock the container.
std::string m_name
Name of the container in memory. Set externally.
void reset()
Function resetting the internal (cached) state of the object.
virtual void toTransient(const EventContext &ctx) override
Perform post-read processing on this store.
virtual ~ByteStreamAuxContainer_v1()
Destructor.
virtual void reserve(size_t size) override
Reserve a given size for the arrays.
SG::auxid_t auxid_t
The aux ID type definition from IConstAuxStore.
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the contents of the stored arrays.
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.
AthContainers_detail::lock_guard< mutex_t > guard_t
virtual void lockDecoration(SG::auxid_t auxid) override
Lock a decoration.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Return the set of variables to copy in a deep copy.
size_t auxid_t
Identifier for a particular aux data item.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
JetConstituentVector::iterator iterator