Classes | Functions

TAO::details Namespace Reference

Classes

struct  array_traits
struct  bounded_array_allocation_traits
struct  bounded_reference_allocation_traits
struct  bounded_value_allocation_traits
class  generic_sequence
class  object_reference_const_sequence_element
class  object_reference_sequence_element
struct  object_reference_traits_base
struct  object_reference_traits_decorator
struct  object_reference_traits
struct  range_checking
 Configurable traits to tradeoff safety vs. performance in the implementation of TAO sequences. More...
class  string_const_sequence_element
class  string_sequence_element
struct  string_traits_base
struct  string_traits_base< char >
struct  string_traits_base< CORBA::WChar >
struct  string_traits_decorator
struct  string_traits
struct  unbounded_array_allocation_traits
struct  unbounded_reference_allocation_traits
struct  unbounded_value_allocation_traits
struct  value_traits
struct  bounded_valuetype_allocation_traits
struct  unbounded_valuetype_allocation_traits
class  valuetype_sequence_element
struct  valuetype_traits_base
struct  valuetype_traits_decorator
struct  valuetype_traits

Functions

template<typename T >
int load_protocol_factory (TAO_ProtocolFactorySet &protocol_set, const char *name)

Function Documentation

template<typename T >
int TAO::details::load_protocol_factory ( TAO_ProtocolFactorySet protocol_set,
const char *  name 
)

Definition at line 34 of file Load_Protocol_Factory_T.h.

    {
      TAO_Protocol_Factory *protocol_factory = 0;
      auto_ptr<TAO_Protocol_Factory> safe_protocol_factory;

      TAO_Protocol_Item *item = 0;

      // If a protocol factory is obtained from the Service
      // Configurator then do not transfer ownership to the
      // TAO_Protocol_Item.
      bool transfer_ownership = false;

      protocol_factory =
        ACE_Dynamic_Service<TAO_Protocol_Factory>::instance (
          ACE_TEXT_CHAR_TO_TCHAR (name));

      if (protocol_factory == 0)
        {
          if (TAO_debug_level > 0)
            ACE_ERROR ((LM_WARNING,
                        ACE_TEXT("(%P|%t) WARNING - No <%C> found in Service")
                        ACE_TEXT(" Repository. Using default instance.\n"),
                        name));

          ACE_NEW_RETURN (protocol_factory,
                          T,
                          -1);

          ACE_AUTO_PTR_RESET (safe_protocol_factory,
                              protocol_factory,
                              TAO_Protocol_Factory);

          transfer_ownership = true;
        }
      else
        {
          transfer_ownership = false;
        }

      ACE_NEW_RETURN (item, TAO_Protocol_Item (name), -1);
      // If the TAO_Protocol_Item retains ownership of the
      // TAO_Protocol_Factory then we used an auto_ptr<> above, so
      // release the TAO_Protocol_Factory from it.  Otherwise, we
      // obtained the TAO_Protocol_Factory from the Service
      // Configurator so an auto_ptr<> wasn't used since the Service
      // Configurator retains ownership, hence there was no need to
      // use an auto_ptr<> in this method.
      item->factory ((transfer_ownership ?
                      safe_protocol_factory.release () :
                      protocol_factory),
                      transfer_ownership);

      if (protocol_set.insert (item) == -1)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT("TAO (%P|%t) Unable to add ")
                      ACE_TEXT("<%C> to protocol factory set.\n"),
                      item->protocol_name ().c_str ()));

          delete item;

          if (transfer_ownership == false)
            delete protocol_factory;

          return -1;
        }

      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT("TAO (%P|%t) - Loaded default ")
                      ACE_TEXT("protocol <%C>\n"),
                      name));
        }

      return 0;
    }

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines