Commits

Anonymous committed 528b885

Change logic for default key retrieval: If there are multiple matching proxies, but only one is of the exact type requested, then that one wins. This means that making a symlink from another type wont spoil an existing default key retrieval.

  • Participants
  • Parent commits 783f5cb
  • Tags SGTools-00-17-01

Comments (0)

Files changed (14)

File src/BaseInfo.cxx

-// $Id: BaseInfo.cxx,v 1.9 2008-11-25 21:45:04 ssnyder Exp $
-/**
- * @file  SGTools/BaseInfo.cxx
- * @author scott snyder
- * @date Nov 2005
- * @brief Provide an interface for finding inheritance information
- *        at run time.
- *        Out-of-line implementation.
- */
-
-#include "SGTools/BaseInfo.h"
-//#include "boost/thread/mutex.hpp"
-#include <map>
-
-
-namespace SG {
-
-
-struct BaseInfoBaseImpl {
-  /// Structure to hold information about one base.
-  struct info {
-    /// Constructor.  @a converter* and @a is_virtual are as for @a add_info.
-    info (BaseInfoBase::castfn_t* converter = 0,
-          BaseInfoBase::castfn_t* converterTo = 0,
-          bool is_virtual = false);
-
-    /// Converter function.  Takes a @a T* and converts to a pointer
-    /// to this base.
-    BaseInfoBase::castfn_t* m_converter;
-
-    /// Converter function.  Takes a pointer to this base and converts
-    /// to @a T*.
-    /// to this base.
-    BaseInfoBase::castfn_t* m_converterTo;
-
-    /// True if the derivation from this base to @a T is via
-    /// virtual derivation.
-    bool m_is_virtual;
-  };
-
-
-  /// CLID of this class.
-  CLID m_clid;
-
-  /// Set to true when first created.
-  /// Reset after we scan for init functions.
-  bool m_needs_init;
-
-  /// @c std::type_info of this class.
-  const std::type_info* m_typeinfo;
-
-
-  /// Hold base information indexed by class ID.
-  typedef std::map<CLID, info> clid_map_type;
-  clid_map_type m_clidmap;
-
-  /// Hold base information indexed by @a type_info.
-  typedef std::map<const std::type_info*, info> ti_map_type;
-  ti_map_type m_timap;
-
-
-  /// Map of all CLIDs to @c BaseInfoBase instances.
-  typedef std::map<CLID, BaseInfoBase*> bi_by_clid_map_type;
-  static bi_by_clid_map_type* s_bi_by_clid;
-
-  /// Map of all @c type_info names to @c BaseInfoBase instances.
-  typedef std::map<const std::type_info*, BaseInfoBase*> bi_by_ti_map_type;
-  static bi_by_ti_map_type* s_bi_by_ti;
-
-  /// Holds @c BaseInfo classes awaiting initialization.
-  /// This is used to defer initialization until everything's loaded.
-  struct init_elem_t {
-    CLID m_clid;
-    const std::type_info* m_ti;
-    BaseInfoBase::init_func_t* m_init_func;
-  };
-  static std::vector<init_elem_t>* s_init_list;
-
-
-  // To make sure that the maps get deleted at program termination.
-  struct Deleter {
-    ~Deleter();
-  };
-  static Deleter s_deleter;
-
-  /// For thread-safety.
-  //static boost::mutex s_mutex;
-};
-
-
-
-/**
- * @brief Return the CLID for this class.
- */
-CLID BaseInfoBase::clid() const
-{
-  return m_impl->m_clid;
-}
-
-
-/**
- * @brief Return the @c std::type_info for this class.
- */
-const std::type_info& BaseInfoBase::typeinfo() const
-{
-  return *m_impl->m_typeinfo;
-}
-
-
-/**
- * @brief Cast to a base pointer.
- * @param p The pointer to cast (a @a T* cast to a @a void*).
- * @param clid ID of the class to which to cast.
- * @return The pointer cast to the requested type, returned
- *         as a @a void*.  @a clid must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- */
-void* BaseInfoBase::cast (void* p, CLID clid) const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  BaseInfoBaseImpl::clid_map_type::const_iterator i = map.find (clid);
-  if (i != map.end())
-    return i->second.m_converter (p);
-  return 0;
-}
-
-
-/**
- * @brief Cast to a base pointer.
- * @param p The pointer to cast (a @a T* cast to a @a void*).
- * @param clid @a type_info of the class to which to cast.
- * @return The pointer cast to the requested type, returned
- *         as a @a void*.  @a tinfo must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- */
-void* BaseInfoBase::cast (void* p, const std::type_info& tinfo) const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  BaseInfoBaseImpl::ti_map_type::const_iterator i = map.find (&tinfo);
-  if (i != map.end())
-    return i->second.m_converter (p);
-  return 0;
-}
-
-
-/**
- * @brief Cast to a derived pointer.
- * @param p The pointer to cast (a @a B* cast to a @a void*).
- * @param clid ID of the class @a B from which to cast.
- * @return The pointer cast to the requested type, returned
- *         as a @a void*.  @a clid must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- *         0 will also be returned if the @a dynamic_cast fails.
- */
-void* BaseInfoBase::castTo (void* p, CLID clid) const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  BaseInfoBaseImpl::clid_map_type::const_iterator i = map.find (clid);
-  if (i != map.end() && i->second.m_converterTo)
-    return i->second.m_converterTo (p);
-  return 0;
-}
-
-
-/**
- * @brief Cast to a derived pointer.
- * @param p The pointer to cast (a @a B* cast to a @a void*).
- * @param clid @a type_info of the class @a B from which to cast.
- * @return The pointer cast to the requested type, returned
- *         as a @a void*.  @a tinfo must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- *         0 will also be returned if the @a dynamic_cast fails.
- */
-void* BaseInfoBase::castTo (void* p, const std::type_info& tinfo) const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  BaseInfoBaseImpl::ti_map_type::const_iterator i = map.find (&tinfo);
-  if (i != map.end() && i->second.m_converterTo)
-    return i->second.m_converterTo (p);
-  return 0;
-}
-
-
-/**
- * @brief Return a function for casting to a base pointer.
- * @param clid ID of the class to which to cast.
- * @return A function to convert a pointer to a @c T to a pointer
- *         to the type identified by @a clid.
- *         @a clid must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- */
-BaseInfoBase::castfn_t* BaseInfoBase::castfn (CLID clid) const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  BaseInfoBaseImpl::clid_map_type::const_iterator i = map.find (clid);
-  if (i != map.end())
-    return i->second.m_converter;
-  return 0;
-}
-
-
-/**
- * @brief Return a function for casting to a base pointer.
- * @param clid @a type_info of the class to which to cast.
- * @return A function to convert a pointer to a @c T to a pointer
- *         to the type identified by @a tinfo.
- *         @a tinfo must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- */
-BaseInfoBase::castfn_t*
-BaseInfoBase::castfn (const std::type_info& tinfo) const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  BaseInfoBaseImpl::ti_map_type::const_iterator i = map.find (&tinfo);
-  if (i != map.end())
-    return i->second.m_converter;
-  return 0;
-}
-
-
-/**
- * @brief Return a function for casting to a derived pointer.
- * @param clid ID of the class @a B from which to cast.
- * @return A function to convert a pointer to a @a B to a pointer
- *         to a @a T.  @a B must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- *         0 will also be returned if the @a dynamic_cast fails.
- */
-BaseInfoBase::castfn_t* BaseInfoBase::castfnTo (CLID clid) const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  BaseInfoBaseImpl::clid_map_type::const_iterator i = map.find (clid);
-  if (i != map.end())
-    return i->second.m_converterTo;
-  return 0;
-}
-
-
-/**
- * @brief Return a function for casting to a derived pointer.
- * @param clid @a type_info of the class @a B from which to cast.
- * @return A function to convert a pointer to a @a B to a pointer
- *         to a @a T.  @a B must be known to be a base
- *         of @a T; otherwise, 0 will be returned.
- *         0 will also be returned if the @a dynamic_cast fails.
- */
-BaseInfoBase::castfn_t*
-BaseInfoBase::castfnTo (const std::type_info& tinfo) const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  BaseInfoBaseImpl::ti_map_type::const_iterator i = map.find (&tinfo);
-  if (i != map.end())
-    return i->second.m_converterTo;
-  return 0;
-}
-
-
-/**
- * @brief Return the class IDs of all known bases of @a T (that
- *        have class IDs).  The list will include @a T itself.
- */
-std::vector<CLID> BaseInfoBase::get_bases() const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  std::vector<CLID> v;
-  v.reserve (map.size());
-  for (BaseInfoBaseImpl::clid_map_type::const_iterator i = map.begin();
-       i != map.end();
-       ++i)
-    v.push_back (i->first);
-  return v;
-}
-
-
-/**
- * @brief Return the @c type_info's of all known bases of @a T.
- *        The list will include @a T itself.
- */
-std::vector<const std::type_info*> BaseInfoBase::get_ti_bases() const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  std::vector<const std::type_info*> v;
-  v.reserve (map.size());
-  for (BaseInfoBaseImpl::ti_map_type::const_iterator i = map.begin();
-       i != map.end();
-       ++i)
-    v.push_back (i->first);
-  return v;
-}
-
-
-/**
- * @brief Return true if @a clid is the ID of a class that
- *        is known to be a base of @a T.  @a T is considered
- *        to be its own base for this purpose.
- * @param clid The ID of the class to test.
- */
-bool BaseInfoBase::is_base (CLID clid) const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  BaseInfoBaseImpl::clid_map_type::const_iterator i = map.find (clid);
-  return i != map.end();
-}
-
-
-/**
- * @brief Return true if @a tinfo is the @a type_info of a class that
- *        is known to be a base of @a T.  @a T is considered
- *        to be its own base for this purpose.
- * @param clid The ID of the class to test.
- */
-bool BaseInfoBase::is_base (const std::type_info& tinfo) const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  BaseInfoBaseImpl::ti_map_type::const_iterator i = map.find (&tinfo);
-  return i != map.end();
-}
-
-
-/**
- * @brief Return true if @a clid is the ID of a class that
- *        is known to be a virtual base of @a T.  (This will always
- *        be false for @a T itself.)
- * @param clid The ID of the class to test.
- */
-bool BaseInfoBase::is_virtual (CLID clid) const
-{
-  const BaseInfoBaseImpl::clid_map_type& map = m_impl->m_clidmap;
-  BaseInfoBaseImpl::clid_map_type::const_iterator i = map.find (clid);
-  if (i != map.end())
-    return i->second.m_is_virtual;
-  return false;
-}
-
-
-/**
- * @brief Return true if @a tinfo is the @a std::type_info of a class that
- *        is known to be a virtual base of @a T.  (This will always
- *        be false for @a T itself.)
- * @param tinfo The @a std::type_info of the class to test.
- */
-bool BaseInfoBase::is_virtual (const std::type_info& tinfo) const
-{
-  const BaseInfoBaseImpl::ti_map_type& map = m_impl->m_timap;
-  BaseInfoBaseImpl::ti_map_type::const_iterator i = map.find (&tinfo);
-  if (i != map.end())
-    return i->second.m_is_virtual;
-  return false;
-}
-
-
-/**
- * @brief Add information about one base class.
- * @param clid The class ID of the base.  May be @a CLID_NULL if no
- *             class ID is available.
- * @param tinfo The @a std::type_info of the base.
- * @param converter Converter function.  This should be able to
- *                  convert a @a T* to a pointer to this base.
- * @param converterTo Converter function.  This should be able to
- *                    convert a pointer to this base to a @a T*.
- * @param is_virtual True if the derivation from this base to @a T
- *                   is via virtual derivation.
- */
-void BaseInfoBase::add_info (CLID clid,
-                             const std::type_info& tinfo,
-                             castfn_t* converter,
-                             castfn_t* converterTo,
-                             bool is_virtual)
-{
-  if (m_impl->m_timap.find (&tinfo) == m_impl->m_timap.end()) {
-    if (clid != CLID_NULL)
-      m_impl->m_clidmap[clid] =
-        BaseInfoBaseImpl::info (converter, converterTo, is_virtual);
-    m_impl->m_timap[&tinfo] =
-      BaseInfoBaseImpl::info (converter, converterTo, is_virtual);
-  }
-}
-
-
-/**
- * @brief Convenience constructor.
- * @param converter Converter function.  This should be able to
- *                  convert a @a T* to a pointer to this base.
- * @param converterTo Converter function.  This should be able to
- *                    convert a pointer to this base to a @a T*.
- * @param is_virtual True if the derivation from this base to @a T
- *                   is via virtual derivation.
- *
- * The defaults are there just so this class can be used with STL
- * containers that require a default ctor.
- */
-BaseInfoBaseImpl::info::info (BaseInfoBase::castfn_t* converter /*= 0*/,
-                              BaseInfoBase::castfn_t* converterTo /*= 0*/,
-                              bool is_virtual /*= false*/)
-  : m_converter (converter),
-    m_converterTo (converterTo),
-    m_is_virtual (is_virtual)
-{
-}
-
-
-/**
- * @brief Constructor.
- * @param clid The class ID of this class.  May be @c CLID_NULL if no
- *             ID is available.
- * @param tinfo The @c std::type_info for this class.
- */
-BaseInfoBase::BaseInfoBase (CLID clid, const std::type_info& tinfo)
-  : m_impl (new BaseInfoBaseImpl)
-{
-  m_impl->m_clid = clid;
-  m_impl->m_typeinfo = &tinfo;
-  m_impl->m_needs_init = true;
-
-  //boost::mutex::scoped_lock lock (BaseInfoBaseImpl::s_mutex);
-  if (!BaseInfoBaseImpl::s_bi_by_clid)
-    BaseInfoBaseImpl::s_bi_by_clid = new BaseInfoBaseImpl::bi_by_clid_map_type;
-  if (!BaseInfoBaseImpl::s_bi_by_ti)
-    BaseInfoBaseImpl::s_bi_by_ti   = new BaseInfoBaseImpl::bi_by_ti_map_type;
-
-  // Register this instance in the static maps.
-  if (clid != CLID_NULL)
-    (*BaseInfoBaseImpl::s_bi_by_clid)[clid] = this;
-  (*BaseInfoBaseImpl::s_bi_by_ti)[&tinfo] = this;
-}
-
-
-/**
- * @brief Destructor.
- */
-BaseInfoBase::~BaseInfoBase()
-{
-  delete m_impl;
-}
-
-
-/**
- * @brief Find the @c BaseInfoBase instance for @c clid.
- * @param clid The class ID of the class for which we want information.
- *
- * Returns 0 if no @c BaseInfoBase instance is available.
- */
-const BaseInfoBase* BaseInfoBase::find (CLID clid)
-{
-  //boost::mutex::scoped_lock lock (BaseInfoBaseImpl::s_mutex);
-  if (!BaseInfoBaseImpl::s_bi_by_clid) return 0;
-  BaseInfoBaseImpl::bi_by_clid_map_type::iterator i =
-    BaseInfoBaseImpl::s_bi_by_clid->find (clid);
-  if (i != BaseInfoBaseImpl::s_bi_by_clid->end()) {
-    if (!i->second->m_impl->m_needs_init)
-      return i->second;
-    i->second->m_impl->m_needs_init = false;
-  }
-
-  // Try the initlist.
-  if (BaseInfoBaseImpl::s_init_list) {
-    for (size_t j = 0; j < BaseInfoBaseImpl::s_init_list->size(); j++) {
-      if ((*BaseInfoBaseImpl::s_init_list)[j].m_clid == clid) {
-        BaseInfoBase::init_func_t* init = 
-          (*BaseInfoBaseImpl::s_init_list)[j].m_init_func;
-        BaseInfoBaseImpl::s_init_list->erase
-          (BaseInfoBaseImpl::s_init_list->begin() + j);
-        --j;
-        init();
-        i = BaseInfoBaseImpl::s_bi_by_clid->find (clid);
-      }
-    }
-  }
-  if (i != BaseInfoBaseImpl::s_bi_by_clid->end())
-    return i->second;
-
-  return 0;
-}
-
-
-/**
- * @brief Find the @c BaseInfoBase instance for @c tinfo.
- * @param tinfo The @c std::type_info of the class
- *              for which we want information.
- *
- * Returns 0 if no @c BaseInfoBase instance is available.
- */
-const BaseInfoBase* BaseInfoBase::find (const std::type_info& tinfo)
-{
-  //boost::mutex::scoped_lock lock (BaseInfoBaseImpl::s_mutex);
-  if (!BaseInfoBaseImpl::s_bi_by_ti) return 0;
-  BaseInfoBaseImpl::bi_by_ti_map_type::iterator i = 
-    BaseInfoBaseImpl::s_bi_by_ti->find (&tinfo);
-  if (i != BaseInfoBaseImpl::s_bi_by_ti->end()) {
-    if (!i->second->m_impl->m_needs_init)
-      return i->second;
-    i->second->m_impl->m_needs_init = false;
-  }
-
-  // Try the initlist.
-  if (BaseInfoBaseImpl::s_init_list) {
-    for (size_t j = 0; j < BaseInfoBaseImpl::s_init_list->size(); j++) {
-      if ((*BaseInfoBaseImpl::s_init_list)[j].m_ti == &tinfo) {
-        BaseInfoBase::init_func_t* init = 
-          (*BaseInfoBaseImpl::s_init_list)[j].m_init_func;
-        BaseInfoBaseImpl::s_init_list->erase
-          (BaseInfoBaseImpl::s_init_list->begin() + j);
-        --j;
-        init();
-        i = BaseInfoBaseImpl::s_bi_by_ti->find (&tinfo);
-      }
-    }
-  }
-  if (i != BaseInfoBaseImpl::s_bi_by_ti->end())
-    return i->second;
-
-  return 0;
-}
-
-
-/**
- * @brief Register an initialization function.
- * @param clid The class ID of the class being registered.
- * @param tinfo The @c std::type_info for the class being registered.
- * @param init_func Function to initialize @c BaseInfo for the class.
- */
-void BaseInfoBase::addInit (CLID clid,
-                            const std::type_info* tinfo,
-                            init_func_t* init_func)
-{
-  //boost::mutex::scoped_lock lock (BaseInfoBaseImpl::s_mutex);
-  if (!BaseInfoBaseImpl::s_init_list)
-    BaseInfoBaseImpl::s_init_list =
-      new std::vector<BaseInfoBaseImpl::init_elem_t>;
-  BaseInfoBaseImpl::init_elem_t elem;
-  elem.m_clid = clid;
-  elem.m_ti = tinfo;
-  elem.m_init_func = init_func;
-  BaseInfoBaseImpl::s_init_list->push_back (elem);
-
-  if (BaseInfoBaseImpl::s_bi_by_ti) {
-    BaseInfoBaseImpl::bi_by_ti_map_type::iterator i = 
-      BaseInfoBaseImpl::s_bi_by_ti->find (tinfo);
-    if (i != BaseInfoBaseImpl::s_bi_by_ti->end() && 
-        !i->second->m_impl->m_needs_init)
-      i->second->m_impl->m_needs_init = true;
-  }
-}
-
-
-/**
- * @brief Run initializations for this class, if needed.
- */
-void BaseInfoBase::maybeInit()
-{
-  if (m_impl->m_needs_init)
-    find (*m_impl->m_typeinfo);
-}
-
-
-
-/// Declare the static members of @c BaseInfoBaseImpl.
-BaseInfoBaseImpl::bi_by_clid_map_type*      BaseInfoBaseImpl::s_bi_by_clid = 0;
-BaseInfoBaseImpl::bi_by_ti_map_type*        BaseInfoBaseImpl::s_bi_by_ti = 0;
-std::vector<BaseInfoBaseImpl::init_elem_t>* BaseInfoBaseImpl::s_init_list = 0;
-//boost::mutex                                BaseInfoBaseImpl::s_mutex;
-
-// To get them deleted.
-BaseInfoBaseImpl::Deleter BaseInfoBaseImpl::s_deleter;
-BaseInfoBaseImpl::Deleter::~Deleter()
-{
-  delete s_bi_by_clid;
-  delete s_bi_by_ti;
-  delete s_init_list;
-}
-
-} // namespace SG

File src/CLIDRegistry.cxx

-#include "SGTools/CLIDRegistry.h"
-/* #include <algorithm> */
-using namespace std;
-
-const unsigned long CLIDRegistry::MINCLID = detail::MINCLID;
-const unsigned long CLIDRegistry::MAXCLID = detail::MAXCLID;
-
-
-
-//   bool 
-//   CLIDRegistry::addEntry(unsigned long id, const string& typeName) {
-//     assert( MINCLID <= id && id <= MAXCLID );
-//     registry().push_back(pair<unsigned long, string>(id,typeName));
-//     return true;
-//   }
-
-CLIDRegistry::const_iterator CLIDRegistry::begin() {
-#ifdef CLIDREG_DEBUG
-  cerr << "CLIDRegistry::begin: returns " 
-	    << &*(registry().begin()) << " for registry " <<&registry() 
-	    <<endl;
-#endif	
-  return registry().begin();
-}
-
-CLIDRegistry::const_iterator CLIDRegistry::end() {
-#ifdef CLIDREG_DEBUG
-  cerr << "CLIDRegistry::end: returns " 
-	    << &*(registry().end()) << " for registry " <<&registry() 
-	    <<endl;
-#endif	
-  return registry().end();
-  //return unique(registry().begin(), registry().end());  //FIXME O(N)!
-}
-
-CLIDRegistry::CLIDRegistryImpl& CLIDRegistry::registry() {
-  static CLIDRegistryImpl _reg;
-  return _reg;
-}

File src/DataBucketCast.cxx

-
-#include "SGTools/DataBucketCast.h"
-#include "Reflex/Type.h"
-#include "Reflex/Object.h"
-#include "SGTools/DataBucketBase.h"
-
-
-void  
-DataBucketCast::castObject(const std::string& toType, 
-			   void* inObject, 
-			   void*& outObject)
-{
-    // Cast object into type toType from a DataObject
-    DataBucketBase* dbb = (DataBucketBase*)(inObject);
-    ROOT::Reflex::Type toObjectType   = ROOT::Reflex::Type::ByName(toType);
-    ROOT::Reflex::Object dbbObject(toObjectType, dbb->object());
-
-//     std::cout << "To Type " << toObjectType.Name() << std::endl;
-//     std::cout << "DataBucketBase " << dbb
-// 	      << " object " << dbb->object()
-// 	      << " obj addr " << dbbObject.Address()
-// 	      << " type " << dbbObject.DynamicType().Name()
-// 	      << std::endl;
-
-    outObject = dbbObject.Address();
-
-}

File src/DataHandleBase.cxx

-///////////////////////// -*- C++ -*- /////////////////////////////
-// DataHandleBase.cxx 
-// Implementation file for class DataHandleBase
-// Author: S.Binet<binet@cern.ch>
-/////////////////////////////////////////////////////////////////// 
-
-// SGTools includes
-#include "SGTools/DataHandleBase.h"
-
-// STL includes
-
-
-
-/////////////////////////////////////////////////////////////////// 
-// Public methods: 
-/////////////////////////////////////////////////////////////////// 
-
-// Constructors
-////////////////
-
-/// Default constructor: 
-DataHandleBase::DataHandleBase() :
-  IResetable(),
-  m_itr(), 
-  m_itrEnd(), 
-  m_proxy(0),
-  //m_ptr(0),
-  m_useItr(false)
-{}
-
-/// Copy constructor: 
-DataHandleBase::DataHandleBase( const DataHandleBase& rhs ) :
-  IResetable(),
-  m_itr(rhs.m_itr), 
-  m_itrEnd(rhs.m_itrEnd),
-  m_proxy(rhs.m_proxy), 
-  //m_ptr(rhs.m_ptr),
-  m_useItr(rhs.m_useItr)
-{
-  if (m_proxy) {
-    m_proxy->addRef();
-  }
-}
-
-
-/// Assignment operator: 
-DataHandleBase& 
-DataHandleBase::operator=( const DataHandleBase& rhs )
-{
-  if (m_proxy) {
-    m_proxy->release();
-  }
-
-  m_itr =    rhs.m_itr;
-  m_itrEnd = rhs.m_itrEnd;
-  m_useItr = rhs.m_useItr;
-  m_proxy =  rhs.m_proxy;
-  //m_ptr =    rhs.m_ptr;
-  if (m_proxy) {
-    m_proxy->addRef();
-  }
-
-  return *this;
-}
-
-/// Constructor with parameters: 
-DataHandleBase::DataHandleBase(SG::DataProxy* proxy) :
-  IResetable(),
-  m_itr(), 
-  m_itrEnd(), 
-  m_proxy(proxy), 
-  //m_ptr(0),
-  m_useItr(false)
-{
-  if (m_proxy) {
-    m_proxy->addRef();
-  }
-}
-
-DataHandleBase::DataHandleBase(const SG::ConstProxyIterator& itr,
-                               const SG::ConstProxyIterator& itrEnd) :
-  IResetable(),
-  m_itr(itr), 
-  m_itrEnd(itrEnd),
-  m_proxy(0), 
-  //m_ptr(0),
-  m_useItr(true)
-{
-  if (m_itr != m_itrEnd) {
-    m_proxy = m_itr->second;
-  }
-
-  if (m_proxy) {
-    m_proxy->addRef();
-  }
-}
-
-
-/// Destructor: 
-DataHandleBase::~DataHandleBase()
-{
-  if (m_proxy != 0) {
-    m_proxy->unbindHandle(this);
-    m_proxy->release();
-  }
-}
-
-// Destructor
-///////////////
-
-/////////////////////////////////////////////////////////////////// 
-// Const methods: 
-///////////////////////////////////////////////////////////////////
-
-StatusCode 
-DataHandleBase::setState(SG::ConstProxyIterator &itr, 
-                         const SG::ConstProxyIterator &itrEnd) const 
-{
-  if (m_proxy) m_proxy->release();
-
-  m_itr = itr;
-  m_itrEnd = itrEnd;
-  m_useItr = true;
-
-  // ouch! FIXME ?
-  // we could have a void* m_ptr data member and have a
-  // typeless_dataPointer method using the typeless machinery of
-  // DataProxy+DataBucketBase...
-  const_cast<DataHandleBase*>(this)->reset();
-
-  // scan from itr to itrEnd and set m_itr to the first valid iterator:
-
-  for (; itr != itrEnd; itr++) {
-    if (itr->second->isValid()) {
-      m_itr = itr;
-      m_proxy = m_itr->second;
-      if (m_proxy) m_proxy->addRef();
-      return StatusCode::SUCCESS;
-    }
-  }
-
-  m_itr = itrEnd;
-  m_proxy = 0;
-  
-  return StatusCode::FAILURE; 
-}
-
-StatusCode 
-DataHandleBase::setState(SG::DataProxy* proxy) const
-{
-  if (0 == proxy || !proxy->isValid()) {
-    return StatusCode::FAILURE;
-  }
-
-  if (m_proxy != proxy) {
-    if (m_proxy) m_proxy->release();
-    m_proxy = proxy;
-    m_proxy->addRef();
-  }
-
-  m_useItr = false;
-  const_cast<DataHandleBase*>(this)->reset();
-
-  return StatusCode::SUCCESS;
-}
-
-StatusCode 
-DataHandleBase::setState(IProxyDict* store, const ID_type& key) const 
-{
-  if (0 == store) {
-    return StatusCode::FAILURE;
-  }
-  CLID cid = this->clid();
-  SG::DataProxy* proxy = store->proxy(cid, key);
-  return this->setState(proxy);
-}
-
-const std::string& 
-DataHandleBase::key() const
-{
-  if (m_itr == m_itrEnd) {
-    return m_proxy->name();
-  } else {
-    return m_itr->first;
-  }
-}
-
-bool 
-DataHandleBase::isConst() const
-{
-  return 0 != m_proxy 
-    ? m_proxy->isConst() 
-    : false;
-}
-
-
-// A weaker test that
-// *does not* retrieve the GaudiObject to check validity if not already done
-bool 
-DataHandleBase::isInitialized() const
-{
-  return (0 != m_proxy);
-}
-
-/////////////////////////////////////////////////////////////////// 
-// Non-const methods: 
-/////////////////////////////////////////////////////////////////// 
-
-StatusCode 
-DataHandleBase::setState(SG::DataProxy* proxy)
-{
-  if (0 == proxy || !proxy->isValid() || proxy->isConst()) {
-    return StatusCode::FAILURE;
-  }
-
-  if (m_proxy != proxy) {
-    if (m_proxy) m_proxy->release();
-    m_proxy = proxy;
-    m_proxy->addRef();
-  }
-
-  m_useItr = false;
-  this->reset();
-  return StatusCode::SUCCESS;
-}
-
-StatusCode 
-DataHandleBase::setState(IProxyDict* store, const ID_type& key)
-{
-  if (0 == store) {
-    return StatusCode::FAILURE;
-  }
-  CLID cid = this->clid();
-  SG::DataProxy* proxy = store->proxy(cid, key);
-  return this->setState(proxy);
-}
-
-/////////////////////////////////////////////////////////////////// 
-// Protected methods: 
-/////////////////////////////////////////////////////////////////// 
-
-

File src/DataProxy.cxx

-#include <cassert>
-
-#include "AthenaKernel/IResetable.h"
-#include "AthenaKernel/getMessageSvc.h"
-#include "GaudiKernel/MsgStream.h"
-
-#include "GaudiKernel/DataObject.h"
-#include "GaudiKernel/IConversionSvc.h"
-#include "GaudiKernel/GenericAddress.h"
-#include "SGTools/TransientAddress.h"
-#include "SGTools/T2pMap.h"
-#include "SGTools/DataBucketBase.h"
-#include <stdexcept>
-using SG::TransientAddress;
-
-
-#include "SGTools/DataProxy.h"
-using SG::DataProxy;
-
-
-namespace {
-  ///sets pMember to pgref (resetting it if pgref is 0). Handles Gaudi refcount
-  template <class GAUDIREF>
-  void setGaudiRef(GAUDIREF* pgref, GAUDIREF*& pMember) {
-    if (0 != pgref) pgref->addRef();
-    if (0 != pMember) pMember->release();
-    pMember = pgref;
-  }
-  
-  ///resets pMember. Handles Gaudi refcount
-  template <class GAUDIREF>
-  void resetGaudiRef(GAUDIREF*& pMember) { setGaudiRef((GAUDIREF*)0, pMember); }
-  
-} //end of unnamed namespace
-
-// Default Constructor
-DataProxy::DataProxy():
-  m_tAddress(new TransientAddress()),
-  m_refCount(0),
-  m_dObject(0), 
-  m_dataLoader(0),
-  m_const(false),
-  m_storageType(0),
-  m_resetFlag(true),
-  m_t2p(0),
-  m_errno(ALLOK)
-{ 
-}
-
-// DataProxy constructor with Transient Address
-// (typically called from Proxy Provider)
-DataProxy::DataProxy(TransientAddress* tAddr, 
-		     IConversionSvc* svc,
-		     bool constFlag, bool resetOnly):
-  m_tAddress(tAddr),
-  m_refCount(0),
-  m_dObject(0), 
-  m_dataLoader(svc),
-  m_const(constFlag),
-  m_storageType(0),
-  m_resetFlag(resetOnly),
-  m_t2p(0),
-  m_errno(ALLOK)
-{
-  assert( tAddr->clID() != 0 );
-  if (svc) svc->addRef();
-}
-
-// with Data Object:
-// (typically called from a StoreGate record
-DataProxy::DataProxy(DataObject* dObject, 
-		     TransientAddress* tAddr,
-		     bool constFlag, bool resetOnly):
-  m_tAddress(tAddr),
-  m_refCount(0),
-  m_dObject(0), 
-  m_dataLoader(0),
-  m_const(constFlag),
-  m_storageType(0),
-  m_resetFlag(resetOnly),
-  m_t2p(0),
-  m_errno(ALLOK)
-{
-  setObject(dObject);
-}
-
-// Destructor
-DataProxy::~DataProxy()
-{  
-  resetGaudiRef(m_dataLoader);
-  resetGaudiRef(m_dObject);
-  delete m_tAddress;
-}
-
-void DataProxy::setT2p(T2pMap* t2p)
-{
-  m_t2p = t2p;
-}
-
-
-bool DataProxy::bindHandle(IResetable* ir) {
-  if (ir->isSet()) {
-    return false;
-  } else {
-    m_handles.push_back(ir); 
-    return true;
-  }
-}
-
-
-
-void DataProxy::reset()
-{
-
-  if (! m_handles.empty()) { resetBoundHandles(); }
-
-  resetGaudiRef(m_dObject);
-  m_tAddress->reset();
-  m_const = false;
-
-}
-
-/// don't need a comment
-void DataProxy::resetBoundHandles() {
-  std::list<IResetable*>::iterator itre=m_handles.end();
-  for (std::list<IResetable*>::iterator itr=m_handles.begin();
-       itr != itre; ++itr) {
-    (*itr)->reset();
-  }
-}
-
-void DataProxy::unbindHandle(IResetable *ir) {
-  if( m_handles.empty() ) { return; }
-  m_handles.remove( ir );
-}
-  
-/// return refCount
-unsigned long DataProxy::refCount() const
-{
-  return m_refCount;
-}
-
-/// Add reference to object
-unsigned long DataProxy::addRef()
-{ 
-  return ++m_refCount;
-}
-
-/// release reference to object
-unsigned long DataProxy::release()
-{ 
-  unsigned long count(--m_refCount);
-  if ( 0 == count ) delete this;
-  return count;
-}
-
-
-///request to release the instance (may just reset it)
-bool DataProxy::requestRelease(bool force /*= false*/) {
-  bool canRelease = !isResetOnly() || force;
-#ifndef NDEBUG
-  MsgStream gLog(m_ims, "DataProxy");
-  gLog << MSG::VERBOSE << "requestRelease(): "
-       << (canRelease ? " release " : " reset")
-       <<" object " 
-       << name() << " CLID " << clID() << " address " << MSG::hex
-       << object() << MSG::dec << endreq;
-#endif
-  if (canRelease)  release();
-    else             reset();
-  return canRelease;
-}
-
-/// set a DataObject address
-void DataProxy::setObject(DataObject* dObject)
-{
-  setGaudiRef(dObject, m_dObject);
-  if (0 != m_dObject) m_dObject->setRegistry(this);
-}
-
-
-// set IOpaqueAddress
-void DataProxy::setAddress(IOpaqueAddress* address)
-{
-  m_tAddress->setAddress(address);
-}
-//////////////////////////////////////////////////////////////
-
-/// Access DataObject on-demand using conversion service
-DataObject* DataProxy::accessData()
-{
-  if (0 != m_dObject) return m_dObject;  // cached object
-
-  if (0 == m_dataLoader) {
-    MsgStream gLog(m_ims, "DataProxy");
-    gLog << MSG::WARNING
-	 << "accessData:  IConversionSvc ptr not set" <<endreq;
-    m_errno=NOCNVSVC;
-    setObject(0);
-    return 0;   
-  }
-  if (!isValidAddress()) {
-    MsgStream gLog(m_ims, "DataProxy");
-    gLog << MSG::WARNING
-	 << "accessData:  IOA pointer not set" <<endreq;
-    m_errno=NOIOA;
-    setObject(0);
-    return 0;
-  }
-
-  DataObject* obj(0);
-  StatusCode sc = m_dataLoader->createObj(m_tAddress->address(), obj);
-
-  if ( sc.isSuccess() )
-  {  
-    setObject(obj);
-    DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(obj);
-    if (bucket) {
-      void* payload = bucket->object();
-      m_t2p->t2pRegister(payload, this);
-      m_errno=ALLOK;
-
-  
-      // Register bases as well.
-      const SG::BaseInfoBase* bi = SG::BaseInfoBase::find (m_tAddress->clID());
-      if (bi) {
-        std::vector<CLID> base_clids = bi->get_bases();
-        for (unsigned i=0; i < base_clids.size(); i++) {
-          void* bobj = SG::DataProxy_cast (this, base_clids[i]);
-          if (bobj && bobj != payload)
-            m_t2p->t2pRegister (bobj, this);
-        }
-      }
-    } else {
-      MsgStream gLog(m_ims, "DataProxy");
-      gLog << MSG::ERROR
-	   << "accessData: ERROR registering object in t2p map" 
-	   <<m_tAddress->clID() << '/' << m_tAddress->name() << '\n'
-	   <<" Returning NULL DataObject pointer  " << endreq;
-      obj=0; 
-      setObject(0);
-      m_errno=T2PREGFAILED;
-      }
-  } else {
-    MsgStream gLog(m_ims, "DataProxy");
-    gLog << MSG::WARNING 
-	 << "accessData: conversion failed for data object " 
-	 <<m_tAddress->clID() << '/' << m_tAddress->name() << '\n'
-	 <<" Returning NULL DataObject pointer  " << endreq;
-    obj=0; 
-    setObject(0);
-    m_errno=CNVFAILED;
-  }
-
-  return obj;
-
-}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-bool DataProxy::isValidAddress() const
-{
-  return (0 != m_tAddress && m_tAddress->isValid());
-}
-
-bool DataProxy::isValidObject() const
-{
-  // FIXME: should we try to chase?
-  return (0!= m_dObject);
-}
-  
-bool DataProxy::isValid() const
-{
-  return (isValidObject() || isValidAddress());
-}
-
-
-/**
- * @brief Try to get the pointer back from a @a DataProxy,
- *        converted to be of type @a clid.
- * @param proxy The @a DataProxy.
- * @param clid The ID of the class to which to convert.
- *
- * Only works if the held object is a @a DataBucket.
- * Returns 0 on failure,
- */
-void* SG::DataProxy_cast (SG::DataProxy* proxy, CLID clid)
-{
-  if (0 == proxy || !proxy->isValid())
-    return 0;
-  DataObject* pObject = proxy->accessData();
-  if (0 == pObject)
-    return 0;
-  return SG::Storable_cast (pObject, clid, proxy);
-}
-
-  
-/**
- * @brief Register a transient object in a t2p map.
- * @param trans The object to register.
- */
-void DataProxy::registerTransient (void* p)
-{
-  if (m_t2p)
-    m_t2p->t2pRegister (p, this);
-}

File src/IProxyDictWithPool.cxx

-// $Id: IProxyDictWithPool.cxx,v 1.1 2008-04-18 03:18:24 ssnyder Exp $
-/**
- * @file SGTools/src/IProxyDictWithPool.cxx
- * @author scott snyder <snyder@bnl.gov>
- * @date Mar, 2007
- * @brief Combine IProxyDict and IStringPool.
- */
-
-
-#include "SGTools/IProxyDictWithPool.h"
-
-
-/**
- * @brief Test to see if the target of an ElementLink has moved.
- * @param sgkey_in Original hashed key of the EL.
- * @param index_in Original index of the EL.
- * @param sgkey_out[out] New hashed key for the EL.
- * @param index_out[out] New index for the EL.
- * @return True if there is a remapping; false otherwise.
- *
- * The default implementation here always returns false.
- */
-bool IProxyDictWithPool::tryELRemap (sgkey_t /*sgkey_in*/,
-                                     size_t /*index_in*/,
-                                     sgkey_t& /*sgkey_out*/,
-                                     size_t& /*index_out*/)
-{
-  return false;
-}
-

File src/SGFolderItem.cxx

-#include "SGTools/SGFolderItem.h"
-
-bool
-SG::FolderItem::isFolder() const {
-  return false;
-  //FIXME  return (m_id == ClassID_traits<Folder>::ID());
-}
-

File src/SGToolsClids.cxx

-// anchor for the clids defined by this package
-
-#include "SGTools/BuiltinsClids.h"
-#include "SGTools/StlMapClids.h"
-#include "SGTools/StlVectorClids.h"

File src/SGVersionedKey.cxx

-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <iostream>
-#include <stdexcept>
-#include <cassert>
-#include "SGTools/SGVersionedKey.h"
-using namespace SG;
-using namespace std;
-
-VersionedKey::~VersionedKey() {
-  //  if (m_versionKey) std::cout << "about to free " << 
-  //  m_versionKey << "@" << (void*)m_versionKey << 
-  // "@this " << this << std::endl;
-  free(m_versionKey); 
-}
-
-bool
-VersionedKey::isVersionedKey(const char * vkey) { 
-  return (vkey[0]==separator() && vkey[3]==separator());
-}
-
-bool 
-VersionedKey::isVersionedKey(const std::string& vkey) {
-  return isVersionedKey(vkey.c_str());
-}
-
-VersionedKey::VersionedKey(const char* key, unsigned char version) {
-  encode(key, version);
-}
-VersionedKey::VersionedKey(const std::string& key, unsigned char version) {
-  encode(key.c_str(), version);
-}
-VersionedKey::VersionedKey(const std::string& versionedKey) {
-  copyVK(versionedKey.c_str());
-}
-VersionedKey::VersionedKey(const char* versionedKey) {
-  copyVK(versionedKey);
-}
-VersionedKey::VersionedKey(const VersionedKey& versionedKey) :
-  m_versionKey(versionedKey.m_versionKey) {
-  versionedKey.m_versionKey=0; //a la auto-ptr
-}
-void VersionedKey::decode(char*& key, unsigned char& version) const {
-  key = m_versionKey+4;
-  version = (unsigned char)strtol(m_versionKey+1, NULL, 10);
-  assert(version <= 99);
-  // possibly faster, disgusting, version decoding
-  // equivalent to version = atoi(m_versionKey[2:3]);
-  //   char *cptr(m_versionKey+1);
-  //   if (*cptr>='0' && *cptr<='9') {
-  //     version = 10 * (*cptr - '0');
-  //     ++cptr;
-  //     if (*cptr>='0' && *cptr<='9') version += *cptr - '0';
-  //     else version = 0;
-  //   } else version = 0;
-}
-
-void VersionedKey::encode(const char* key, unsigned char version) {
-  assert(version <= 99);
-  m_versionKey = (char *)malloc(strlen(key)+5);
-  sprintf(m_versionKey, formatString(), version, key);
-}
-
-void VersionedKey::copyVK(const char* versionedKey) {
-  if (isVersionedKey(versionedKey)) {
-    m_versionKey = (char *)malloc(strlen(versionedKey)+1);
-    strcpy(m_versionKey, versionedKey);
-  }
-  else {
-    encode(versionedKey, 0);
-  }
-}
-unsigned char VersionedKey::version() const {
-  return (unsigned char)strtol(m_versionKey+1, NULL, 10);
-}
-/// @returns base key
-const char* VersionedKey::key() const { 
-  return m_versionKey+4; 
-}
-
-bool 
-VersionedKey::sameKey(const VersionedKey& vkey) const {
-  return (0 == strcmp(this->key(),vkey.key())); 
-}
-
-bool 
-VersionedKey::sameKey(const std::string& baseKey) const {
-  return (0 == strcmp(this->key(),baseKey.c_str())); 
-}
-
-bool 
-VersionedKey::sameKey(const char* baseKey) const {
-  return (0 == strcmp(this->key(),baseKey)); 
-}
-
-/// sort according to highest key version
-bool operator < (const SG::VersionedKey& lhs, const SG::VersionedKey& rhs) {
-  char *lhskey(0);
-  unsigned char lhsVersion(0);
-  lhs.decode(lhskey, lhsVersion);
-  unsigned char rhsVersion(0);
-  char *rhskey(0);
-  rhs.decode(rhskey, rhsVersion);
-  int keyCompare(strcmp(lhskey, rhskey));
-  return ( ( keyCompare < 0) ||
-	   ( (keyCompare == 0) && (lhsVersion < rhsVersion) ) ) ;
-	  
-}

File src/StorableConversions.cxx

-/** @file StorableConversions.cxx
- *  @brief convert to and from a SG storable
- * $Id: StorableConversions.cxx,v 1.2 2008-04-08 16:05:32 ssnyder Exp $
- * @author ATLAS Collaboration
- **/
-
-#include "SGTools/StorableConversions.h"
-
-
-namespace SG {
-
-
-/**
- * @brief Try to get the pointer back from a @a DataObject,
- *        converted to be of type @a clid.
- * @param pDObj The @a DataObject.
- * @param clid The ID of the class to which to convert.
- * @param irt To be called if we make a new instance.
- *
- * Only works if the @a DataObject is a @a DataBucket.
- * Returns 0 on failure,
- */
-void* fromStorable(DataObject* pDObj, CLID clid, IRegisterTransient*irt/*= 0*/)
-{
-  // Try to use BaseInfo information to convert pointers.
-  DataBucketBase* b = dynamic_cast<DataBucketBase*>(pDObj);
-  if (b)
-    return b->cast (clid, irt);
-  return 0;
-}
-
-
-/**
- * @brief Try to get the pointer back from a @a DataObject,
- *        converted to be of type @a clid.
- * @param pDObj The @a DataObject.
- * @param clid The ID of the class to which to convert.
- * @param irt To be called if we make a new instance.
- *
- * Only works if the @a DataObject is a @a DataBucket.
- * Returns 0 on failure,
- */
-void* Storable_cast(DataObject* pDObj, CLID clid,
-                    IRegisterTransient* irt /*= 0*/)
-{
-  return fromStorable (pDObj, clid, irt);
-}
-
-
-/**
- * @brief Try to get the pointer back from a @a DataObject,
- *        converted to be of type @a clid.
- * @param pDObj The @a DataObject.
- * @param clid The ID of the class to which to convert.
- * @param irt To be called if we make a new instance.
- *
- * Only works if the @a DataObject is a @a DataBucket.
- * Returns 0 on failure,
- */
-const void* Storable_cast(const DataObject* pDObj, CLID clid,
-                          IRegisterTransient* irt /*= 0*/)
-{
-  return fromStorable (const_cast<DataObject*> (pDObj), clid, irt);
-}
-
-
-} // namespace SG

File src/StringPool.cxx

-// $Id: StringPool.cxx,v 1.3 2007-12-10 22:20:03 ssnyder Exp $
-/**
- * @file  SGTools/StringPool.cxx
- * @author scott snyder
- * @date Mar 2007
- * @brief Maintain a mapping of strings to 64-bit ints.
- */
-
-
-#include "SGTools/StringPool.h"
-#include "SGTools/crc64.h"
-#include "CxxUtils/unordered_map.h"
-#include <map>
-#include <cstdlib>
-#include <iostream>
-#include <iomanip>
-
-
-namespace SG {
-
-
-//***************************************************************************
-// Implementation class.
-//
-
-
-class StringPoolImpl
-{
-public:
-  /// Remember an additional mapping from key to string.
-  bool registerKey (StringPool::sgkey_t key,
-                    const std::string& str,
-                    StringPool::sgaux_t aux);
-
-  /// Find the string corresponding to a given key.
-  const std::string* keyToString (StringPool::sgkey_t key,
-                                  StringPool::sgaux_t& aux) const;
-
-  /// Debugging dump.  Write to stdout.
-  void dump() const;
-
-private:
-  // Hash function for the key.
-  // Just cast the low bits to a size_t.
-  struct keyhash
-  {
-    std::size_t operator() (StringPool::sgkey_t key) const
-    { return static_cast<std::size_t> (key); }
-  };
-
-  // The key hash table.
-  typedef std::pair<StringPool::sgaux_t, std::string> pair_t;
-  typedef SG::unordered_map<StringPool::sgkey_t, pair_t, keyhash> keymap_t;
-  keymap_t m_keymap;
-};
-
-
-/**
- * @brief Remember an additional mapping from key to string.
- * @param key The key to enter.
- * @param str The string to enter.
- * @param aux Auxiliary data to include along with the string.
- * @return True if successful; false if the @c key already
- *         corresponds to a different string.
- */
-bool StringPoolImpl::registerKey (StringPool::sgkey_t key,
-                                  const std::string& str,
-                                  StringPool::sgaux_t aux)
-{
-  StringPoolImpl::keymap_t::iterator i = m_keymap.find (key);
-  if (i == m_keymap.end()) {
-    pair_t& p = m_keymap[key];
-    p.first = aux;
-    p.second = str;
-  }
-  else if (i->second.first != aux || i->second.second != str)
-    return false;
-  return true;
-}
-
-
-/**
- * @brief Find the string corresponding to a given key.
- * @param key The key to look up.
- * @param aux[out] Auxiliary data associated with the key.
- * @return Pointer to the string found, or null.
- *         We can find keys as long as the corresponding string
- *         was given to either @c stringToKey() or @c registerKey().
- */
-const std::string*
-StringPoolImpl::keyToString (StringPool::sgkey_t key,
-                             StringPool::sgaux_t& aux) const
-{
-  StringPoolImpl::keymap_t::const_iterator i = m_keymap.find (key);
-  if (i != m_keymap.end()) {
-    aux = i->second.first;
-    return &i->second.second;
-  }
-  return 0;
-}
-
-
-/**
- * @brief Debugging dump.  Write to cout.
- */
-void StringPoolImpl::dump() const
-{
-  for (keymap_t::const_iterator i = m_keymap.begin();
-       i != m_keymap.end();
-       ++i)
-  {
-    std::cout << std::hex << std::setw(18) << i->first << " "
-              << std::dec << std::setw(9) << i->second.first << " "
-              << i->second.second << "\n";
-  }
-}
-
-
-//***************************************************************************
-// StringPool class.
-//
-
-/**
- * @brief Constructor.
- */
-StringPool::StringPool()
-  : m_impl (new StringPoolImpl)
-{
-}
-
-
-/**
- * @brief Destructor.
- */
-StringPool::~StringPool()
-{
-  delete m_impl;
-}
-
-
-/**
- * @brief Find the key for a string.
- * @param str The string to look up.
- * @param aux Auxiliary data to include along with the string.
- * @return A key identifying the string.
- *         A given string will always return the same key.
- *         Will abort in case of a hash collision!
- */
-StringPool::sgkey_t StringPool::stringToKey (const std::string& str,
-                                             sgaux_t aux /*= 0*/)
-{
-  uint64_t crc = crc64 (str);
-  if (aux) crc = crc64addint (crc, aux);
-  sgkey_t key = (crc & sgkey_t_max);
-  if (!m_impl->registerKey (key, str, aux))
-    std::abort();
-  return key;
-}
-
-
-/**
- * @brief Find the string corresponding to a given key.
- * @param key The key to look up.
- * @return Pointer to the string found, or null.
- *         We can find keys as long as the corresponding string
- *         was given to either @c stringToKey() or @c registerKey().
- */
-const std::string* StringPool::keyToString (sgkey_t key) const
-{
-  sgaux_t aux;
-  return m_impl->keyToString (key, aux);
-}
-
-
-/**
- * @brief Find the string corresponding to a given key.
- * @param key The key to look up.
- * @param aux[out] Auxiliary data associated with the key.
- * @return Pointer to the string found, or null.
- *         We can find keys as long as the corresponding string
- *         was given to either @c stringToKey() or @c registerKey().
- */
-const std::string* StringPool::keyToString (sgkey_t key,
-                                            sgaux_t& aux) const
-{
-  return m_impl->keyToString (key, aux);
-}
-
-
-/**
- * @brief Remember an additional mapping from key to string.
- * @param key The key to enter.
- * @param str The string to enter.
- * @param aux Auxiliary data to include along with the string.
- * @return True if successful; false if the @c key already
- *         corresponds to a different string.
- *
- * This registers an additional mapping from a key to a string;
- * it can be found later through @c lookup() on the string.
- */
-bool StringPool::registerKey (sgkey_t key,
-                              const std::string& str,
-                              sgaux_t aux /*= 0*/)
-{
-  // Make sure the primary mapping is registered first.
-  stringToKey (str, aux);
-  return m_impl->registerKey (key, str, aux);
-}
-
-
-/**
- * @brief Debugging dump.  Write to cout.
- */
-void StringPool::dump () const
-{
-  m_impl->dump();
-}
-
-
-} // namespace SG

File src/T2pMap.cxx

-#include "SGTools/T2pMap.h"
-using namespace SG;
-std::vector<DataProxy*> T2pMap::pacReport() const {
-  std::vector<DataProxy*> notAccessed;
-  if (m_pac) {
-    t2p::const_iterator i(m_t2p.begin()), e(m_t2p.end());
-    while (i != e) {
-      if (!m_pac->accessed(i->first)) notAccessed.push_back(i->second);
-      ++i;
-    }
-  }
-  return notAccessed;
-}

File src/TransientAddress.cxx

-#include "SGTools/TransientAddress.h"
-#include "AthenaKernel/IAddressProvider.h"
-#include "GaudiKernel/IOpaqueAddress.h"
-
-using SG::TransientAddress;
-
-// Default Constructor:
-TransientAddress::TransientAddress()
-  : m_clid(0), m_name(""), m_address(0), m_clearAddress(true),
-    m_consultProvider(false), m_pAddressProvider(0)
-{ }
-
-// Constructor with CLID and string key:
-// (typically used through a StoreGate::record()
-TransientAddress::TransientAddress(const CLID& id, const std::string& key)
-  : m_clid(id), m_name(key), m_address(0), m_clearAddress(true),
-    m_consultProvider(false), m_pAddressProvider(0)
-{ 
-  m_transientID.insert(id);
-}
-
-// Constructor with CLID, string key and IOpaqueAddress:
-// (typically used by a ProxyProvider)
-TransientAddress::TransientAddress(const CLID& id, const std::string& key, 
-				   IOpaqueAddress* addr, 
-				   bool clearAddress)
-  : m_clid(id), m_name(key), m_address(0), m_clearAddress(clearAddress),
-    m_consultProvider(true), m_pAddressProvider(0)
-{ 
-  m_transientID.insert(id);
-  setAddress(addr);
-}
-
-// Destructor
-TransientAddress::~TransientAddress() 
-{ 
-  setAddress(0);
-}
-
-/// set IOpaqueAddress
-void TransientAddress::setAddress(IOpaqueAddress* pAddress)
-{ 
-  if (0 != pAddress) pAddress->addRef();
-  if (0 != m_address) m_address->release();
-  m_address = pAddress;
-}
-
-bool TransientAddress::isValid()
-{
-  if (0 != address()) return true;
-
-  // FIXME CGL
-//    if (!m_consultProvider) {
-//      if ( m_clid != 0 && m_name != "" ) { return true; }
-//    }
-  if (m_consultProvider && 0 != provider()) {
-    if ((provider()->updateAddress(this)).isSuccess())
-      return true;
-  }
-  return false;
-}
-
-
-
-
-

File src/crc64.cxx

-// $Id: crc64.cxx,v 1.2 2007-03-08 02:02:06 ssnyder Exp $
-/**
- * @file  SGTools/crc64.cxx
- * @author scott snyder, originally from David T. Jones
- * @date Mar 2007
- * @brief A CRC-64 implementation.
- */
-/*
- * Original comments:
- * Improved calculation of CRC-64 values for protein sequences
- * By David T. Jones (dtj@cs.ucl.ac.uk)  - September 28th 2002
- * 
- * Modified from code at URL:
- * ftp://ftp.ebi.ac.uk/pub/software/swissprot/Swissknife/old/SPcrc.tar.gz
- *
- * Changed to C++ and moved into a namespace.
- */
-
-
-#include "SGTools/crc64.h"
-#include <cstdio>
-using namespace std;
-
-
-// I don't have a citation for the source of this polynomial.
-// Maybe should replace it with the ECMA DLT poly?
-#define POLY64REV     0x95AC9329AC4BC9B5ULL
-#define INITIALCRC    0xFFFFFFFFFFFFFFFFULL
-
-// Original SWISSPROT/TrEMBL poly.  Shown to be weak.
-//#define POLY64REV	0xd800000000000000ULL
-//#define INITIALCRC	0x0000000000000000ULL
-
-
-namespace {
-
-bool crc_init = false;
-uint64_t CRCTable[256];
-
-// Initialize the CRC table.
-void init_table()
-{
-  crc_init = true;
-  for (int i = 0; i < 256; i++)
-  {
-    uint64_t part = i;
-    for (int j = 0; j < 8; j++)
-    {
-      if (part & 1)
-        part = (part >> 1) ^ POLY64REV;
-      else
-        part >>= 1;
-    }
-    CRCTable[i] = part;
-  }
-}
-
-} // anonymous namespace
-
-
-namespace SG {
-
-
-/**
- * @brief Find the CRC-64 of a string.
- * @param str The string to hash.
- */
-uint64_t crc64 (const std::string& str)
-{
-  if (!crc_init)
-    init_table();
-
-  uint64_t crc = INITIALCRC;
-  const char* seq = str.data();
-  const char* end = seq + str.size();
-  while (seq < end)
-    crc = CRCTable[(crc ^ *seq++) & 0xff] ^ (crc >> 8);
-  return crc;
-}
-
-
-/**
- * @brief Extend a previously-calculated CRC to include an int.
- * @param crc The previously-calculated CRC.
- * @param x The integer to add.
- * @return The new CRC.
- */
-uint64_t crc64addint (uint64_t crc, unsigned int x)
-{
-  if (!crc_init)
-    init_table();
-
-  while (x > 0) {
-    crc = CRCTable[(crc ^ x) & 0xff] ^ (crc >> 8);
-    x >>= 8;
-  }
-  return crc;
-}
-
-
-/**
- * @brief Format a CRC-64 as a string.
- * @param crc The CRC to format.
- */
-std::string crc64format (uint64_t crc)
-{
-  char buf[64];
-  sprintf (buf, "%08X%08X",
-           (unsigned)((crc>>32)&0xffffffff), (unsigned)(crc&0xffffffff));
-  return buf;
-}
-
-
-/**
- * @brief Return a CRC-64 digest of a string.
- * @param str The string to hash.
- * @return The CRC-64 digest of the string.
- *         This is the hash code, expressed as hex as a string.
- */
-std::string crc64digest (const std::string& str)
-{
-  return crc64format (crc64 (str));
-}
-
-
-} // namespace SG