示例#1
0
 virtual
 std::shared_ptr<void>
 construct(di::type_info const & type,
           di::type_provider & unscoped)
 {
   std::cout << di::detail::demangle(type.name()) << std::endl;
   ++nobjects;
   return unscoped.untyped_get();
 }
示例#2
0
boost::shared_ptr<void>
di::scopes::singleton::construct( di::type_info const & type,
                                  di::type_provider & unscoped )
{
  boost::recursive_mutex::scoped_lock lock(m_mutex);
  {
    instance_map_t::iterator it = m_instances.find(type);
    if(it == m_instances.end())
    {
      DI_LOG_DEBUG("Singleton: constructing: " << detail::demangle(type.name()));
      m_instances[type] = unscoped.untyped_get();
    }
    else
    {
      DI_LOG_DEBUG("Singleton: returning existing: " << detail::demangle(type.name()));
    }
    return m_instances[type];
  }
}