Exemplo n.º 1
0
 virtual
 std::shared_ptr<void>
 construct(di::type_info const & type,
           di::type_provider & unscoped)
 {
   return unscoped.untyped_get();
 }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
 virtual
 boost::shared_ptr<void>
 construct(di::type_info const & type,
           di::type_provider & unscoped)
 {
   if(!m_instances.get())
     m_instances.reset(new instance_map_t);
   instance_map_t::iterator it = m_instances->find(type);
   if(it == m_instances->end())
     (*m_instances)[type] = unscoped.untyped_get();
   return (*m_instances)[type];
 }
Exemplo n.º 4
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];
  }
}