Exemplo n.º 1
0
void *
Registry::getFuncPtr(
  const NamePair &      name_pair) const
{
  RegistryMap::const_iterator registry_entry = getRegistryMap().find(name_pair);
  return registry_entry == getRegistryMap().end() ? NULL : (*registry_entry).second;
}
Exemplo n.º 2
0
std::ostream &
Registry::verbose_print(
  std::ostream &                os) const
{
  for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it)
    os << (*it).first.second << " of type " << demangle((*it).first.first->name()) << " at " << (*it).second << std::endl;
  return os;
}
Exemplo n.º 3
0
std::vector<std::string>
Registry::getDerivedNames(
  const std::type_info &        type) const
{
  std::vector<std::string> derived_names;

  for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it)
    if (*(*it).first.first == type)
      derived_names.push_back((*it).first.second);

  return derived_names;
}
Exemplo n.º 4
0
stk::diag::Writer &
Registry::verbose_print(
  stk::diag::Writer &		dout) const
{
  if (dout.shouldPrint()) {
    dout << "Registry, size " << getRegistryMap().size() << stk::diag::push << stk::diag::dendl;

    for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it)
      dout << (*it).first.second << " of type " << demangle((*it).first.first->name()) << " at " << (*it).second << stk::diag::dendl;
    dout << stk::diag::pop;
  }
  return dout;
}
Exemplo n.º 5
0
void
Registry::registerIt(
  const KeyPair &       key_pair,
  void *                func_ptr)
{
  // slibout.m(Slib::LOG_PLUGIN) << "Registering " << key_pair.second
  //                             << " of type " << demangle(key_pair.first->key())
  //                             << " at " << func_ptr << stk::diag::dendl;

  RegistryMap::const_iterator registry_entry = getRegistryMap().find(key_pair);
  if (registry_entry != getRegistryMap().end() && (*registry_entry).second != func_ptr) {
    std::ostringstream strout;
    strout << "Function with signature " << demangle((*registry_entry).first.first->key())
           << " and derived key '" << (*registry_entry).first.second
           << "' already registered to create function at address " << (*registry_entry).second;
    throw std::invalid_argument(strout.str());
  }
  getRegistryMap()[key_pair] = func_ptr;
}