21 m_int(), m_float(), m_vecInt(), m_vecFloat(),
30 :
SG::IAuxStore( parent ),
31 m_int( parent.m_int ), m_float( parent.m_float ),
32 m_vecInt( parent.m_vecInt ), m_vecFloat( parent.m_vecFloat ),
34 m_auxids( parent.m_auxids ),
45 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
46 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
47 for( ; itr != end; ++itr ) {
48 if( *itr )
delete *itr;
52 for( ; itr != end; ++itr ) {
53 if( *itr )
delete *itr;
64 m_float = rhs.m_float;
65 m_vecInt = rhs.m_vecInt;
66 m_vecFloat = rhs.m_vecFloat;
69 m_auxids = rhs.m_auxids;
74 for(
auto* ptr : m_dynamicVecs ) {
77 m_dynamicVecs.clear();
105 else if( ( auxid < m_dynamicVecs.size() ) &&
106 ( m_dynamicVecs[ auxid ] ) ) {
108 return m_dynamicVecs[ auxid ];
144 else if( ( auxid < m_dynamicVecs.size() ) &&
145 ( m_dynamicVecs[ auxid ] ) ) {
146 ret = m_dynamicVecs[ auxid ]->toPtr();
170 std::atomic_thread_fence (std::memory_order_seq_cst);
201 bool anycleared =
false;
203 if (m_dynamicVecs[auxid]) {
204 delete m_dynamicVecs[auxid];
205 m_dynamicVecs[auxid] =
nullptr;
206 m_auxids.erase( auxid );
209 const std::string
name =
r.getName( auxid );
210 const std::type_info* ti =
r.getType( auxid );
211 if (ti == &
typeid(
int))
213 else if (ti == &
typeid(
float))
214 m_float.erase (
name);
215 else if (ti == &
typeid(std::vector<int>))
216 m_vecInt.erase (
name);
217 else if (ti == &
typeid(std::vector<float>))
218 m_vecFloat.erase (
name);
243 if (i < m_dynamicVecs.size() && m_dynamicVecs[i]) {
244 size_t sz = m_dynamicVecs[i]->size();
274 else if( ( auxid < m_dynamicVecs.size() ) &&
275 ( m_dynamicVecs[ auxid ] ) ) {
277 m_dynamicVecs[ auxid ]->reserve( capacity );
278 m_dynamicVecs[ auxid ]->resize(
size );
280 return m_dynamicVecs[ auxid ]->toPtr();
306 if (!v->resize(
size ))
313 if (!v->resize(
size ))
328 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
329 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
330 for( ; itr != end; ++itr ) {
331 if( *itr ) ( *itr )->reserve(
size );
335 for( ; itr != end; ++itr ) {
336 if( *itr ) ( *itr )->reserve(
size );
349 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
350 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
351 for( ; itr != end; ++itr ) {
352 if( *itr ) ( *itr )->shift( pos, offs );
356 for( ; itr != end; ++itr ) {
357 if( *itr ) ( *itr )->shift( pos, offs );
375 size_t other_size =
other.size();
382 if (
id < m_dynamicVecs.size())
383 v_dst = m_dynamicVecs[id];
388 if (
other.getData (
id)) {
389 void* src_ptr =
other.getData (
id, other_size, other_size);
391 if (!v_dst->
insertMove (pos, src_ptr, 0, other_size,
397 const void* orig = v_dst->
toPtr();
398 v_dst->
shift (pos, other_size);
399 if (orig != v_dst->
toPtr())
407 if (!m_auxids.test(
id) &&
410 if (
other.getData (
id)) {
411 void* src_ptr =
other.getData (
id, other_size, other_size);
415 m_dynamicVecs[id]->resize (
sz - other_size);
416 (void)m_dynamicVecs[
id]->
insertMove (pos, src_ptr, 0, other_size,
434 m_dynamicVecs.clear();
437#define ADD_IDS(VAR, TYP) \
438 do { typedef std::map< std::string, std::vector< TYP > > CONT; \
439 for (CONT::value_type& p : VAR) \
440 m_auxids.insert (r.getAuxID< TYP > (p.first, "", SG::AuxVarFlags::SkipNameCheck)); } while(0)
443 ADD_IDS(m_vecInt, std::vector<int>);
444 ADD_IDS(m_vecFloat, std::vector<float>);
463 template<
typename T >
466 std::map< std::string,
467 std::vector< T > >& pers,
468 size_t size,
size_t capacity,
470 bool forDecor)
const {
476 const std::string
name =
r.getName( auxid );
479 typename std::map< std::string, std::vector< T > >
::iterator itr =
481 if( itr == pers.end() ) {
485 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData (const) "
486 <<
"Variable with unknown name (" <<
name <<
") requested"
495 if (
r.isLinked(auxid)) {
496 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1 doesn't implement linked variables"
502 itr = pers.insert (std::make_pair (
name, std::vector<T>())).first;
506 std::vector< T >& var = itr->second;
509 if( m_dynamicVecs.size() <= auxid ) {
510 m_dynamicVecs.resize( auxid + 1 );
514 if( m_dynamicVecs[ auxid ] ) {
515 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData "
516 <<
"Internal inconsistency detected!" << std::endl;
517 return m_dynamicVecs[ auxid ];
525 m_dynamicVecs[ auxid ]->reserve( capacity );
526 m_dynamicVecs[ auxid ]->resize(
size );
530 m_auxids.insert( auxid );
533 return m_dynamicVecs[ auxid ];
538 size_t size,
size_t capacity,
540 bool forDecor)
const {
555 typeid( std::vector< int > ) ) {
560 typeid( std::vector< float > ) ) {
566 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData "
567 <<
"Unknown variable type ("
569 <<
") requested" << std::endl;
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.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type 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.
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 ~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.
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