19 const std::string emptyStr{};
26 m_int(), m_float(), m_vecInt(), m_vecFloat(),
35 :
SG::IAuxStore( parent ),
36 m_int( parent.m_int ), m_float( parent.m_float ),
37 m_vecInt( parent.m_vecInt ), m_vecFloat( parent.m_vecFloat ),
39 m_auxids( parent.m_auxids ),
50 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
51 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
52 for( ; itr != end; ++itr ) {
53 if( *itr )
delete *itr;
57 for( ; itr != end; ++itr ) {
58 if( *itr )
delete *itr;
69 m_float = rhs.m_float;
70 m_vecInt = rhs.m_vecInt;
71 m_vecFloat = rhs.m_vecFloat;
74 m_auxids = rhs.m_auxids;
79 for(
auto* ptr : m_dynamicVecs ) {
82 m_dynamicVecs.clear();
110 else if( ( auxid < m_dynamicVecs.size() ) &&
111 ( m_dynamicVecs[ auxid ] ) ) {
113 return m_dynamicVecs[ auxid ];
149 else if( ( auxid < m_dynamicVecs.size() ) &&
150 ( m_dynamicVecs[ auxid ] ) ) {
151 ret = m_dynamicVecs[ auxid ]->toPtr();
175 std::atomic_thread_fence (std::memory_order_seq_cst);
211 bool anycleared =
false;
213 if (m_dynamicVecs[auxid]) {
214 delete m_dynamicVecs[auxid];
215 m_dynamicVecs[auxid] =
nullptr;
216 m_auxids.erase( auxid );
219 const std::string
name =
r.getName( auxid );
220 const std::type_info* ti =
r.getType( auxid );
221 if (ti == &
typeid(
int))
223 else if (ti == &
typeid(
float))
224 m_float.erase (
name);
225 else if (ti == &
typeid(std::vector<int>))
226 m_vecInt.erase (
name);
227 else if (ti == &
typeid(std::vector<float>))
228 m_vecFloat.erase (
name);
253 if (i < m_dynamicVecs.size() && m_dynamicVecs[i]) {
254 size_t sz = m_dynamicVecs[i]->size();
284 else if( ( auxid < m_dynamicVecs.size() ) &&
285 ( m_dynamicVecs[ auxid ] ) ) {
287 m_dynamicVecs[ auxid ]->reserve( capacity );
288 m_dynamicVecs[ auxid ]->resize(
size );
290 return m_dynamicVecs[ auxid ]->toPtr();
316 if (!v->resize(
size ))
323 if (!v->resize(
size ))
338 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
339 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
340 for( ; itr != end; ++itr ) {
341 if( *itr ) ( *itr )->reserve(
size );
345 for( ; itr != end; ++itr ) {
346 if( *itr ) ( *itr )->reserve(
size );
359 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
360 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
361 for( ; itr != end; ++itr ) {
362 if( *itr ) ( *itr )->shift( pos, offs );
366 for( ; itr != end; ++itr ) {
367 if( *itr ) ( *itr )->shift( pos, offs );
385 size_t other_size =
other.size();
392 if (
id < m_dynamicVecs.size())
393 v_dst = m_dynamicVecs[id];
398 if (
other.getData (
id)) {
399 void* src_ptr =
other.getData (
id, other_size, other_size);
401 if (!v_dst->
insertMove (pos, src_ptr, 0, other_size,
407 const void* orig = v_dst->
toPtr();
408 v_dst->
shift (pos, other_size);
409 if (orig != v_dst->
toPtr())
417 if (!m_auxids.test(
id) &&
420 if (
other.getData (
id)) {
421 void* src_ptr =
other.getData (
id, other_size, other_size);
425 m_dynamicVecs[id]->resize (
sz - other_size);
426 (void)m_dynamicVecs[
id]->
insertMove (pos, src_ptr, 0, other_size,
444 m_dynamicVecs.clear();
447#define ADD_IDS(VAR, TYP) \
448 do { typedef std::map< std::string, std::vector< TYP > > CONT; \
449 for (CONT::value_type& p : VAR) \
450 m_auxids.insert (r.getAuxID< TYP > (p.first, emptyStr, SG::AuxVarFlags::SkipNameCheck)); } while(0)
453 ADD_IDS(m_vecInt, std::vector<int>);
454 ADD_IDS(m_vecFloat, std::vector<float>);
473 template<
typename T >
476 std::map< std::string,
477 std::vector< T > >& pers,
478 size_t size,
size_t capacity,
480 bool forDecor)
const {
486 const std::string
name =
r.getName( auxid );
489 typename std::map< std::string, std::vector< T > >
::iterator itr =
491 if( itr == pers.end() ) {
495 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData (const) "
496 <<
"Variable with unknown name (" <<
name <<
") requested"
505 if (
r.isLinked(auxid)) {
506 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1 doesn't implement linked variables"
512 itr = pers.insert (std::make_pair (
name, std::vector<T>())).first;
516 std::vector< T >& var = itr->second;
519 if( m_dynamicVecs.size() <= auxid ) {
520 m_dynamicVecs.resize( auxid + 1 );
524 if( m_dynamicVecs[ auxid ] ) {
525 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData "
526 <<
"Internal inconsistency detected!" << std::endl;
527 return m_dynamicVecs[ auxid ];
535 m_dynamicVecs[ auxid ]->reserve( capacity );
536 m_dynamicVecs[ auxid ]->resize(
size );
540 m_auxids.insert( auxid );
543 return m_dynamicVecs[ auxid ];
548 size_t size,
size_t capacity,
550 bool forDecor)
const {
565 typeid( std::vector< int > ) ) {
570 typeid( std::vector< float > ) ) {
577 std::cerr <<
"ERROR xAOD::ByteStreamAuxContainer_v1::getData "
578 <<
"Unknown variable type ("
580 <<
") requested for variable "
582 <<
" (" << auxid <<
")"
594 v->toTransient( ctx );
599 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