Public Member Functions | Protected Attributes

TAO_AV_Connector_Registry Class Reference

#include <Transport.h>

Collaboration diagram for TAO_AV_Connector_Registry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_AV_Connector_Registry (void)
 ~TAO_AV_Connector_Registry (void)
int open (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, TAO_AV_FlowSpecSet &flow_spec_set)
int close (TAO_AV_Connector *connector)
int close_all (void)
TAO_AV_ConnectorSetItor begin (void)
TAO_AV_ConnectorSetItor end (void)

Protected Attributes

TAO_AV_ConnectorSet connectors_

Detailed Description

Definition at line 273 of file Transport.h.


Constructor & Destructor Documentation

TAO_AV_Connector_Registry::TAO_AV_Connector_Registry ( void   ) 

int connect (TAO_FlowSpec_Entry *flowspec, TAO_AV_Transport *&transport); TAO_AV_Connector *get_connector (TAO_AV_Core::Protocol protocol); Return the connector bridges

Definition at line 50 of file Transport.cpp.

{
}

TAO_AV_Connector_Registry::~TAO_AV_Connector_Registry ( void   ) 

Definition at line 195 of file Transport.cpp.

{
  this->close_all ();
}


Member Function Documentation

TAO_AV_ConnectorSetItor TAO_AV_Connector_Registry::begin ( void   ) 

Definition at line 62 of file Transport.inl.

{
  return this->connectors_.begin ();
}

int TAO_AV_Connector_Registry::close ( TAO_AV_Connector connector  ) 

Definition at line 167 of file Transport.cpp.

{
  this->connectors_.remove (connector);

  if (connector != 0)
    delete connector;
  return 0;
}

int TAO_AV_Connector_Registry::close_all ( void   ) 

Definition at line 177 of file Transport.cpp.

{
  for (TAO_AV_ConnectorSetItor i = this->connectors_.begin ();
       i != this->connectors_.end ();
       ++i)
    {
      if (*i != 0)
        continue;

      (*i)->close ();

      this->close (*i);
    }

  this->connectors_.reset ();
  return 0;
}

TAO_AV_ConnectorSetItor TAO_AV_Connector_Registry::end ( void   ) 

Definition at line 69 of file Transport.inl.

{
  return this->connectors_.end ();
}

int TAO_AV_Connector_Registry::open ( TAO_Base_StreamEndPoint endpoint,
TAO_AV_Core av_core,
TAO_AV_FlowSpecSet flow_spec_set 
)

Definition at line 55 of file Transport.cpp.

{

  TAO_AV_FlowSpecSetItor last_flowspec =  flow_spec_set.end ();

  for (TAO_AV_FlowSpecSetItor flow_spec = flow_spec_set.begin ();
       flow_spec != last_flowspec;
       ++flow_spec)
    {
      TAO_FlowSpec_Entry *entry = (*flow_spec);
      ACE_Addr *address = entry->address ();
      const char *flow_protocol = entry->flow_protocol_str ();
      const char *transport_protocol = entry->carrier_protocol_str ();

      if (ACE_OS::strcmp (flow_protocol,"") == 0)
        flow_protocol = transport_protocol;

      if (address == 0)
        {
          // Protocol was specified without an endpoint.  According to
          // the "iioploc" spec, this is valid.  As such, we extend
          // this feature to all pluggable protocols.  All TAO
           // pluggable protocols are expected to have the ability to
          // create a default endpoint.

          ACE_ERROR_RETURN ((LM_ERROR,
                             "Protocol was specified without an endpoint\n"),
                            -1);
        }
      else
        {
          TAO_AV_Flow_Protocol_Factory *flow_factory =
            av_core->get_flow_protocol_factory (flow_protocol);
          TAO_AV_Transport_Factory *transport_factory =
            av_core->get_transport_factory (transport_protocol);

          if ((flow_factory != 0) && (transport_factory != 0))
            {
              // @@Naga:Instead of making a new connector every time we should try and see if a connector exists
              // for this transport already and hence we can reuse it.

              TAO_AV_Connector *connector = transport_factory->make_connector ();

              if (connector != 0)
                {
                  // add connector to list.
                  this->connectors_.insert (connector);

                  if (connector->open (endpoint,
                                       av_core,
                                       flow_factory) == -1)
                    return -1;

                  TAO_AV_Transport *transport = 0;
                  if (connector->connect (entry,
                                          transport,
                                          TAO_AV_Core::TAO_AV_DATA) == -1)
                    return -1;
                  entry->transport (transport);
                }
              else
                ACE_ERROR_RETURN ((LM_ERROR,
                                   "(%P|%t) Unable to create an "
                                   "connector for <%s>\n",
                                   entry->flowname ()),
                                  -1);

              // Now see if the flow factory has a control flow factory.
              TAO_AV_Flow_Protocol_Factory *control_flow_factory =
                av_core->get_flow_protocol_factory(flow_factory->control_flow_factory ());

              if (control_flow_factory != 0)
                {
                  TAO_AV_Connector *control_connector =
                    transport_factory->make_connector ();

                  if (control_connector != 0)
                    {
                      // add connector to list.
                      this->connectors_.insert (control_connector);

                      if (control_connector->open (endpoint,
                                                   av_core,
                                                   control_flow_factory) == -1)
                        return -1;

                      TAO_AV_Transport *control_transport = 0;
                      if (control_connector->connect (entry,
                                                      control_transport,
                                                      TAO_AV_Core::TAO_AV_CONTROL) == -1)
                        return -1;
                      entry->control_transport (control_transport);

                      // Now set the control object on the data flow object.
                      entry->protocol_object ()->control_object (entry->control_protocol_object ());
                    }
                  else
                    ACE_ERROR_RETURN ((LM_ERROR,
                                       "(%P|%t) Unable to create an "
                                       "connector for <%s>\n",
                                       entry->flowname ()),
                                      -1);
                }
            }
        }
    }
  return 0;
}


Member Data Documentation

Definition at line 292 of file Transport.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines