1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
6 * @file AthContainers/tools/AtomicConstAccessor.icc
7 * @author scott snyder <snyder@bnl.gov>
9 * @brief Access an auxiliary variable atomically.
18 * @param name Name of this aux variable.
20 * The name -> auxid lookup is done here.
22 template <class T, class ALLOC>
24 AtomicConstAccessor<T, ALLOC>::AtomicConstAccessor (const std::string& name)
25 : Base (name, "", SG::AuxVarFlags::Atomic)
32 * @param name Name of this aux variable.
33 * @param clsname The name of its associated class. May be blank.
35 * The name -> auxid lookup is done here.
37 template <class T, class ALLOC>
39 AtomicConstAccessor<T, ALLOC>::AtomicConstAccessor (const std::string& name,
40 const std::string& clsname)
41 : Base (name, clsname, SG::AuxVarFlags::Atomic)
47 * @brief Constructor taking an auxid directly.
48 * @param auxid ID for this auxiliary variable.
50 * Will throw @c SG::ExcAuxTypeMismatch if the types don't match.
52 template <class T, class ALLOC>
54 AtomicConstAccessor<T, ALLOC>::AtomicConstAccessor (const SG::auxid_t auxid)
55 : Base (auxid, SG::AuxVarFlags::Atomic)
61 * @brief Fetch the variable for one element, as a const reference.
62 * @param e The element for which to fetch the variable.
64 * As this class can be used only read-only for basic types, return
65 * the result by value. That makes it easier to call from python.
67 template <class T, class ALLOC>
69 ATH_REQUIRES( IsConstAuxElement<ELT> )
71 T AtomicConstAccessor<T, ALLOC>::operator() (const ELT& e) const
73 return reinterpret_cast<const_reference_type> (Base::operator() (e));
78 * @brief Fetch the variable for one element, as a const reference.
79 * @param container The container from which to fetch the variable.
80 * @param index The index of the desired element.
82 * This allows retrieving aux data by container / index.
83 * Looping over the index via this method will be faster then
84 * looping over the elements of the container.
86 * As this class can be used only read-only for basic types, return
87 * the result by value. That makes it easier to call from python.
89 template <class T, class ALLOC>
91 T AtomicConstAccessor<T, ALLOC>::operator() (const AuxVectorData& container,
94 return reinterpret_cast<const_reference_type> (Base::operator() (container, index));
99 * @brief Get a pointer to the start of the auxiliary data array.
100 * @param container The container from which to fetch the variable.
102 template <class T, class ALLOC>
105 AtomicConstAccessor<T, ALLOC>::getDataArray (const AuxVectorData& container) const
106 -> const_container_pointer_type
108 return reinterpret_cast<const_container_pointer_type>
109 (container.getDataArray (Base::auxid()));