2   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
    7  * @file AthContainers/ViewVector.icc
 
    8  * @author scott snyder <snyder@bnl.gov>
 
   10  * @brief Identify view containers to be made persistent.
 
   15  * @brief Default constructor.
 
   16  * @param ownPolicy The ownership mode for the container.
 
   17  *                  Must be @c SG::VIEW_ELEMENTS.
 
   18  *                  (Argument present only for interface compatibility.)
 
   22 ViewVector<DV>::ViewVector(SG::OwnershipPolicy ownPolicy /*= SG::VIEW_ELEMENTS*/)
 
   23   : DV (SG::VIEW_ELEMENTS)
 
   25   if (ownPolicy != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
   31  * @brief Sized constructor.
 
   32  * @param n The size of the container.
 
   33  * @param ownPolicy The ownership mode for the container.
 
   34  *                  Must be @c SG::VIEW_ELEMENTS.
 
   35  *                  (Argument present only for interface compatibility.)
 
   37  * Note that unlike the standard vector constructor, you can't specify
 
   38  * an initial value here.  The container will be initialized with 0's.
 
   42 ViewVector<DV>::ViewVector(size_type n,
 
   43                            SG::OwnershipPolicy ownPolicy /*= SG::VIEW_ELEMENTS*/)
 
   44   : DV (n, SG::VIEW_ELEMENTS)
 
   46   if (ownPolicy != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
   52  * @brief Constructor from iterators.
 
   53  * @param first The start of the range to put in the new container.
 
   54  * @param last The end of the range to put in the new container.
 
   57 template <class InputIterator>
 
   59 ViewVector<DV>::ViewVector(InputIterator first, InputIterator last)
 
   60   : DV (first, last, SG::VIEW_ELEMENTS)
 
   67  * @brief Move constructor.
 
   68  * @param rhs The container from which to move.
 
   70  * Any auxiliary data will be moved along with the container contents.
 
   74 ViewVector<DV>::ViewVector (ViewVector&& rhs)
 
   76   // Redundant, but just to check for problems.
 
   77   if (rhs.ownPolicy() != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
   78   DV::operator= (std::move (rhs));
 
   84  * @brief Constructor from base vector..
 
   85  * @param rhs The container from which to copy.
 
   89 ViewVector<DV>::ViewVector (const DV& rhs)
 
   97  * @brief Move constructor from base vector.
 
   98  * @param rhs The container from which to copy.  Must be a view container.
 
  100  * Any auxiliary data will be moved along with the container contents.
 
  104 ViewVector<DV>::ViewVector (DV&& rhs)
 
  107   if (this->ownPolicy() != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
  113  * @brief Constructor from an initializer list.
 
  114  * @param l An initializer list.
 
  118 ViewVector<DV>::ViewVector(std::initializer_list<value_type> l)
 
  119   : DV (l, SG::VIEW_ELEMENTS)
 
  126  * @brief Assignment operator.
 
  127  * @param rhs The DataVector from which to assign.
 
  128  * @return This object.
 
  130  * This is a `shallow' copy; after the completion of this, the DataVector
 
  131  * will not own its elements.  Any elements it owned prior to this call
 
  134  * Note: this method may only be called using the most derived
 
  135  * @c DataVector in the hierarchy.
 
  139 ViewVector<DV>& ViewVector<DV>::operator= (const DV& rhs)
 
  149  * @brief Move assignment.
 
  150  * @param rhs The container from which to move.
 
  152  * Any auxiliary data will be moved along with the container contents.
 
  156 ViewVector<DV>& ViewVector<DV>::operator= (ViewVector&& rhs)
 
  159     // Redundant but good to check anyway.
 
  160     if (this->ownPolicy() != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
  161     DV::operator= (std::move (rhs));
 
  168  * @brief Move assignment from base vector.
 
  169  * @param rhs The container from which to move.
 
  170  *            Must be a view vector.
 
  172  * Any auxiliary data will be moved along with the container contents.
 
  176 ViewVector<DV>& ViewVector<DV>::operator= (DV&& rhs)
 
  179     if (rhs.ownPolicy() != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
  180     DV::operator= (std::move (rhs));
 
  187  * @brief Assignment operator, from an initializer list.
 
  188  * @param l An initializer list.
 
  189  * @return This object.
 
  191  * This is equivalent to @c assign.
 
  195 ViewVector<DV>& ViewVector<DV>::operator= (std::initializer_list<value_type> l)
 
  204  * @brief Erase all the elements in the collection.
 
  205  * @param ownPolicy The new ownership policy of the container.
 
  206  *                  Must be SG::VIEW_ELEMENTS.
 
  207  *                  (Argument present only for interface compatibility.)
 
  211 void ViewVector<DV>::clear (SG::OwnershipPolicy ownPolicy)
 
  213   if (ownPolicy != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
  214   DV::clear (SG::VIEW_ELEMENTS);
 
  219  * @brief Convert the vector to persistent form.
 
  223 void ViewVector<DV>::toPersistent()
 
  225   doToPersistent (*static_cast<DV*>(this));
 
  230  * @brief Convert the vector to transient form.
 
  234 void ViewVector<DV>::toTransient()
 
  236   doToTransient (*static_cast<DV*>(this));
 
  242  * @brief Erase all the elements in the collection.
 
  243  * @param ownPolicy The new ownership policy of the container.
 
  244  *                  Must be SG::VIEW_ELEMENTS.
 
  245  *                  (Argument present only for interface compatibility.)
 
  246  * @param trackIndices The index tracking policy.
 
  250 void ViewVector<DV>::clear (SG::OwnershipPolicy ownPolicy,
 
  251                             SG::IndexTrackingPolicy trackIndices)
 
  253   if (ownPolicy != SG::VIEW_ELEMENTS) SG::throwExcViewVectorNotView();
 
  254   DV::clear (SG::VIEW_ELEMENTS, trackIndices);
 
  259  * @brief Helper to ensure that the inheritance information for this class
 
  263 void ViewVector<DV>::registerBaseInit()
 
  265 #ifndef XAOD_STANDALONE
 
  266   static const SG::RegisterBaseInit<ViewVector> rbi;