ATLAS Offline Software
Loading...
Searching...
No Matches
ByteStreamAuxContainer_v1.icc
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2/*
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4*/
5#ifndef XAODTRIGGER_VERSIONS_BYTESTREAMAUXCONTAINER_V1_ICC
6#define XAODTRIGGER_VERSIONS_BYTESTREAMAUXCONTAINER_V1_ICC
7
8// System include(s):
9#include <iostream>
10
11// EDM include(s):
12#include "AthContainers/AuxTypeRegistry.h"
13#include "xAODCore/tools/AuxPersVector.h"
14#include "xAODCore/tools/AuxVariable.h"
15
16namespace xAOD {
17
18 template< typename T >
19 ByteStreamAuxContainer_v1::auxid_t
20 ByteStreamAuxContainer_v1::getAuxID( const std::string& name,
21 std::vector< T >& /*vec*/,
22 SG::AuxVarFlags flags) {
23
24 return SG::AuxTypeRegistry::instance().template getAuxID< T >( name, "", flags );
25 }
26
27 /// The user is expected to use this function inside the constructor of
28 /// the derived class.
29 ///
30 /// @param name The name of the variable. Same as the C++ variable's name.
31 /// @param vec A reference to the auxiliary variable inside the object
32 ///
33 template< typename T >
34 void ByteStreamAuxContainer_v1::regAuxVar( const auxid_t auxid,
35 const std::string& name,
36 std::vector< T >& vec ) {
37
38 // Make sure that the internal vector is big enough:
39 if( m_staticVecs.size() <= auxid ) {
40 m_staticVecs.resize( auxid + 1 );
41 }
42
43 // Check if this variable name was already registered:
44 if( m_staticVecs[ auxid ] ) {
45 std::cerr << "WARNING xAOD::AuxContainerBase::regAuxVec "
46 << "Re-registering variable with name \""
47 << name << "\"" << std::endl;
48 delete m_staticVecs[ auxid ];
49 }
50
51 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
52 if (r.isLinked(auxid)) {
53 throw std::runtime_error ("ERROR xAOD::ByteStreamAuxContainer_v1 doesn't implement linked variables");
54 }
55
56 // Register the variable:
57 m_staticVecs[ auxid ] = new AuxPersVector< T >( auxid, vec, false, this );
58
59 // Remember that we are now handling this variable:
60 m_auxids.insert( auxid );
61
62 return;
63 }
64
65} // namespace xAOD
66
67#endif // XAODTRIGGER_VERSIONS_BYTESTREAMAUXCONTAINER_V1_ICC