1 // Dear emacs, this is -*- c++ -*-
 
    3   Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 
    5 #ifndef XAODCORE_AUXCONTAINERBASE_ICC
 
    6 #define XAODCORE_AUXCONTAINERBASE_ICC
 
   12 #include "AthContainers/AuxTypeRegistry.h"
 
   15 #include "xAODCore/tools/AuxPersVector.h"
 
   16 #include "xAODCore/tools/AuxVariable.h"
 
   20    template< typename T, typename ALLOC >
 
   21    AuxContainerBase::auxid_t
 
   22    AuxContainerBase::getAuxID( const std::string& name,
 
   23                                std::vector< T, ALLOC >& /*vec*/,
 
   24                                SG::AuxVarFlags flags,
 
   25                                const SG::auxid_t linkedVariable ) {
 
   27       return SG::AuxTypeRegistry::instance().template getAuxID< T >( name, "",
 
   32    template< typename T >
 
   33    AuxContainerBase::auxid_t
 
   34    AuxContainerBase::getAuxID( const std::string& name,
 
   35                                SG::PackedContainer< T >& /*vec*/,
 
   36                                SG::AuxVarFlags flags,
 
   37                                const SG::auxid_t linkedVariable ) {
 
   39       return SG::AuxTypeRegistry::instance().template getAuxID< T >( name, "",
 
   44    /// Common code between vector and PackedContainer cases.
 
   45    template< typename ELT, typename CONT >
 
   46    void AuxContainerBase::regAuxVar1( const auxid_t auxid,
 
   47                                       const std::string& name, CONT& vec ) {
 
   49       // Make sure that the internal vector is big enough:
 
   50       if( m_vecs.size() <= auxid ) {
 
   51          m_vecs.resize( auxid + 1 );
 
   54       // Check if this variable name was already registered:
 
   55       if( m_vecs[ auxid ] ) {
 
   56          std::cout << "WARNING xAOD::AuxContainerBase::regAuxVec "
 
   57                    << "Re-registering variable with name \""
 
   58                    << name << "\"" << std::endl;
 
   59          delete m_vecs[ auxid ];
 
   62       // Register the variable:
 
   63       const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
 
   64       m_vecs[ auxid ] = new AuxPersVector< ELT, CONT >( auxid, vec, r.isLinked( auxid ), this );
 
   66       // Remember that we are now handling this variable:
 
   67       m_auxids.insert( auxid );
 
   72    /// The user is expected to use this function inside the constructor of
 
   73    /// the derived class.
 
   75    /// @param auxid The auxiliary ID to use for the variable
 
   76    /// @param name The name of the variable. Same as the C++ variable's name.
 
   77    /// @param vec A reference to the auxiliary variable inside the object
 
   78    /// @param flags Optional flags qualifying the type.  See AuxTypeRegistry.h.
 
   79    template< typename T, typename ALLOC >
 
   80    void AuxContainerBase::regAuxVar( const auxid_t auxid,
 
   81                                      const std::string& name,
 
   82                                      std::vector< T, ALLOC >& vec ) {
 
   83      regAuxVar1<T> (auxid, name, vec);
 
   87    /// The user is expected to use this function inside the constructor of
 
   88    /// the derived class.
 
   90    /// @param auxid The auxiliary ID to use for the variable
 
   91    /// @param name The name of the variable. Same as the C++ variable's name.
 
   92    /// @param vec A reference to the auxiliary variable inside the object
 
   93    /// @param flags Optional flags qualifying the type.  See AuxTypeRegistry.h.
 
   94    template< typename T >
 
   95    void AuxContainerBase::regAuxVar( const auxid_t auxid,
 
   96                                      const std::string& name,
 
   97                                      SG::PackedContainer< T >& vec ) {
 
   98      regAuxVar1<T> (auxid, name, vec);
 
  104 #endif // XAODCORE_AUXCONTAINERBASE_ICC