2   Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 
    6 #include "CxxUtils/checker_macros.h"
 
   11    * @brief forward the initialization to the member VarHandleKeys
 
   12    * @param used If false, then this handle is not to be used.
 
   13    *             Instead of normal initialization, the key will be cleared.
 
   17   StatusCode VarHandleKeyArrayCommon<Base>::initialize (bool used /*= true*/) {
 
   18     StatusCode sc(StatusCode::SUCCESS);
 
   20       IDataHandleHolder* const owner = this->owner();
 
   21       for (Base& b : *this) {
 
   22     if (owner != nullptr) {
 
   25         if ( b.initialize().isFailure() ) {
 
   26           sc = StatusCode::FAILURE;
 
   37   // Set the VarHandleKey from a string
 
   41   StatusCode VarHandleKeyArrayCommon<Base>::assign(const std::vector<std::string>& vs) {
 
   42     StatusCode sc(StatusCode::SUCCESS);
 
   47         sc = StatusCode::FAILURE;
 
   51           std::vector<Base>::emplace_back(std::move(b));
 
   59   // string representation of VarHandleKeyArray
 
   63   std::string VarHandleKeyArrayCommon<Base>::toString() const {
 
   64     std::ostringstream ost;
 
   65     typename std::vector<Base>::const_iterator itr;
 
   67     size_t sz = this->size();
 
   68     for ( size_t i=0; i < sz; ++i, ++itr) {
 
   69       ost << "'" << itr->objKey() << "'";
 
   78   // create array of all base VarHandleKeys in the Array
 
   82   std::vector<SG::VarHandleKey*> VarHandleKeyArrayCommon<Base>::keys() const {
 
   83     std::vector<SG::VarHandleKey*> keys;
 
   84     for (const SG::VarHandleKey& k : *this) {
 
   85       // FIXME: This is a rule violation, but we can't really fix it without
 
   86       // changing the IDataHandleHolder base class from Gaudi.
 
   87       SG::VarHandleKey* k_nc ATLAS_THREAD_SAFE = const_cast<SG::VarHandleKey*>(&k);
 
   88       keys.push_back (k_nc);
 
   95   void VarHandleKeyArrayCommon<Base>::declare(IDataHandleHolder* owner) {
 
   99     for (auto k: keys() ) {
 
  100       owner->declare ( *k );
 
  101       k->setOwner( owner );