1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
 
    4   Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 
    7 /***************************************************************************
 
    8  implementation of DataProxy_cast operator
 
    9  -----------------------------------------
 
   11 ***************************************************************************/
 
   13 // $Id: DataProxy.icc,v 1.6 2008-07-14 22:16:25 calaf Exp $
 
   15 #include "AthenaKernel/DataBucketBase.h"
 
   16 #include "AthenaKernel/StorableConversions.h"
 
   17 #include "AthenaKernel/ClassID_traits.h"
 
   19 #  include "AthenaKernel/getMessageSvc.h"
 
   20 #  include "GaudiKernel/MsgStream.h"
 
   27 /// Retrieve data object key == string
 
   29 const SG::DataProxy::name_type& SG::DataProxy::name() const
 
   32   return m_tAddress.name();
 
   36 /// Retrieve data object key == string
 
   37 /// duplicated for Gaudi folks does same as name()
 
   39 const SG::DataProxy::id_type& SG::DataProxy::identifier() const
 
   42   return m_tAddress.name();
 
   46 /// Retrieve DataObject
 
   48 DataObject* SG::DataProxy::object ATLAS_NOT_CONST_THREAD_SAFE () const
 
   54 /// Retrieve IOpaqueAddress
 
   56 IOpaqueAddress* SG::DataProxy::address() const
 
   58   lock_t lock (m_mutex);
 
   59   return m_tAddress.address();
 
   63 /// set DataSvc (Gaudi-specific); do nothing for us
 
   65 IDataProviderSvc* SG::DataProxy::dataSvc() const
 
   70 ///< Get the primary (hashed) SG key.
 
   72 SG::sgkey_t SG::DataProxy::sgkey() const
 
   74   // No lock; underlying member is atomic.
 
   75   return m_tAddress.sgkey();
 
   79 /// Set the primary (hashed) SG key.
 
   81 void SG::DataProxy::setSGKey (sgkey_t sgkey)
 
   83   lock_t lock (m_mutex);
 
   84   m_tAddress.setSGKey (sgkey);
 
   88 ///< Return the ID of the store containing this proxy.
 
   90 StoreID::type SG::DataProxy::storeID() const
 
   92   lock_t lock (m_mutex);
 
   93   return m_tAddress.storeID();
 
   97 ///< check if it is a transient ID (primary or symLinked):
 
   99 bool SG::DataProxy::transientID (CLID id) const
 
  101   lock_t lock (m_mutex);
 
  102   return m_tAddress.transientID (id);
 
  106 ///< return the list of transient IDs (primary or symLinked):
 
  108 SG::DataProxy::CLIDCont_t SG::DataProxy::transientID() const
 
  110   lock_t lock (m_mutex);
 
  111   return m_tAddress.transientID();
 
  115 /// Add a new transient ID
 
  117 void SG::DataProxy::setTransientID(CLID id)
 
  119   lock_t lock (m_mutex);
 
  120   m_tAddress.setTransientID (id);
 
  124 /// access set of proxy aliases
 
  125 /// Returns a COPY of the alias set.
 
  127 SG::DataProxy::AliasCont_t SG::DataProxy::alias() const
 
  129   lock_t lock (m_mutex);
 
  130   return m_tAddress.alias();
 
  134 /// Add a new proxy alias.
 
  136 void SG::DataProxy::setAlias(const std::string& key)
 
  138   lock_t lock (m_mutex);
 
  139   m_tAddress.setAlias (key);
 
  143 /// Test to see if a given string is in the alias set.
 
  145 bool SG::DataProxy::hasAlias(const std::string& key) const
 
  147   lock_t lock (m_mutex);
 
  148   return m_tAddress.hasAlias (key);
 
  152 /// remove alias from proxy
 
  154 bool SG::DataProxy::removeAlias(const std::string& key)
 
  156   lock_t lock (m_mutex);
 
  157   return m_tAddress.removeAlias (key);
 
  161 /// Return the address provider.
 
  163 IAddressProvider* SG::DataProxy::provider()
 
  165   lock_t lock (m_mutex);
 
  166   return m_tAddress.provider();
 
  170 /// Set the address provider.
 
  172 void SG::DataProxy::setProvider(IAddressProvider* provider,
 
  173                                 StoreID::type storeID)
 
  175   lock_t lock (m_mutex);
 
  176   m_tAddress.setProvider (provider, storeID);
 
  180 /// Set the CLID / key.
 
  181 /// This will only succeed if the clid/key are currently clear.
 
  183 void SG::DataProxy::setID (CLID id, const std::string& key)
 
  185   lock_t lock (m_mutex);
 
  186   m_tAddress.setID (id, key);
 
  192 bool SG::DataProxy::isValid() const
 
  194   return (isValidObject() || isValidAddress());
 
  198 /// is the object valid?
 
  200 bool SG::DataProxy::isValidObject() const
 
  202   // FIXME: should we try to chase?
 
  203   return (0!= m_dObject);
 
  207 /// Access DataObject on-demand using conversion service
 
  208 ///@throws runtime_error when converter fails
 
  210 DataObject* SG::DataProxy::accessData()
 
  212   // Inlined part: return m_dObject if it's valid.
 
  213   // Otherwise, call the out-of-line part of the code.
 
  214   if (0 != m_dObject) return m_dObject;  // cached object
 
  215   return accessDataOol();
 
  220 SG::DataProxy::ErrNo SG::DataProxy::errNo() const
 
  222   lock_t lock (m_objMutex);
 
  229 CLID SG::DataProxy::clID() const
 
  231   // No lock; underlying member is atomic.
 
  232   return m_tAddress.clID();
 
  236 /// Check if it is a const object
 
  238 bool SG::DataProxy::isConst() const
 
  240   // No lock; underlying member is atomic.
 
  245 /// set the reset only flag: Clear Store will reset and not delete.
 
  247 void SG::DataProxy::resetOnly(const bool& flag)
 
  249   lock_t lock (m_mutex);
 
  254 /// Check reset only:
 
  256 bool SG::DataProxy::isResetOnly() const
 
  258   lock_t lock (m_mutex);
 
  263 /// Set the store of which we're a part.
 
  265 void SG::DataProxy::setStore (IProxyDict* store)
 
  270 /// Return the store of which we're a part.
 
  272 IProxyDict* SG::DataProxy::store()
 
  278 /// Return the store of which we're a part.
 
  280 const IProxyDict* SG::DataProxy::store() const
 
  287 IConverter* SG::DataProxy::loader()
 
  289   lock_t lock (m_mutex);