Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include "DataFormats/Provenance/interface/ParentageRegistry.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"

namespace edm {
  ParentageRegistry* ParentageRegistry::instance() {
    CMS_THREAD_SAFE static ParentageRegistry s_reg;
    return &s_reg;
  }

  bool ParentageRegistry::getMapped(key_type const& k, value_type& result) const {
    auto it = m_map.find(k);
    bool found = it != m_map.end();
    if (found) {
      result = it->second;
    }
    return found;
  }

  ParentageRegistry::value_type const* ParentageRegistry::getMapped(key_type const& k) const {
    auto it = m_map.find(k);
    bool found = it != m_map.end();
    return found ? &(it->second) : static_cast<value_type const*>(nullptr);
  }

  bool ParentageRegistry::insertMapped(value_type const& v) { return m_map.insert(std::make_pair(v.id(), v)).second; }

  bool ParentageRegistry::insertMapped(value_type&& v) { return m_map.emplace(v.id(), std::move(v)).second; }

  void ParentageRegistry::clear() { m_map.clear(); }
}  // namespace edm