TAO_AV_Acceptor_Registry Class Reference

#include <Transport.h>

Collaboration diagram for TAO_AV_Acceptor_Registry:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_AV_Acceptor_Registry (void)
 ~TAO_AV_Acceptor_Registry (void)
int open (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, TAO_AV_FlowSpecSet &flow_spec_set)
int close (TAO_AV_Acceptor *acceptor)
int close_all (void)
TAO_AV_AcceptorSetItor begin (void)
TAO_AV_AcceptorSetItor end (void)

Protected Member Functions

int open_default (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, TAO_FlowSpec_Entry *entry)

Protected Attributes

TAO_AV_AcceptorSet acceptors_

Detailed Description

Definition at line 302 of file Transport.h.


Constructor & Destructor Documentation

TAO_AV_Acceptor_Registry::TAO_AV_Acceptor_Registry ( void   ) 

Definition at line 204 of file Transport.cpp.

00205 {
00206 }

TAO_AV_Acceptor_Registry::~TAO_AV_Acceptor_Registry ( void   ) 

Definition at line 208 of file Transport.cpp.

References close_all().

00209 {
00210   this->close_all();
00211 }


Member Function Documentation

ACE_INLINE TAO_AV_AcceptorSetItor TAO_AV_Acceptor_Registry::begin ( void   ) 

Definition at line 79 of file Transport.inl.

References acceptors_, and ACE_Unbounded_Set_Ex< T, C >::begin().

Referenced by TAO_AV_Core::get_acceptor(), and TAO_AV_Core::remove_acceptor().

00080 {
00081   return this->acceptors_.begin ();
00082 }

int TAO_AV_Acceptor_Registry::close ( TAO_AV_Acceptor acceptor  ) 

Definition at line 437 of file Transport.cpp.

References acceptors_, and ACE_Unbounded_Set_Ex< T, C >::remove().

Referenced by TAO_AV_Core::remove_acceptor().

00438 {
00439   this->acceptors_.remove (acceptor);
00440   delete acceptor;
00441 
00442   return 0;
00443 }

int TAO_AV_Acceptor_Registry::close_all ( void   ) 

Definition at line 446 of file Transport.cpp.

References acceptors_, ACE_Unbounded_Set_Ex< T, C >::end(), and ACE_Unbounded_Set_Ex< T, C >::reset().

Referenced by ~TAO_AV_Acceptor_Registry().

00447 {
00448   for (TAO_AV_AcceptorSetItor i = this->acceptors_.begin ();
00449        i != this->acceptors_.end ();
00450        ++i)
00451     {
00452       if (*i == 0)
00453         continue;
00454 
00455       (*i)->close ();
00456 
00457       delete *i;
00458     }
00459 
00460   this->acceptors_.reset ();
00461   return 0;
00462 }

ACE_INLINE TAO_AV_AcceptorSetItor TAO_AV_Acceptor_Registry::end ( void   ) 

Definition at line 86 of file Transport.inl.

References acceptors_, and ACE_Unbounded_Set_Ex< T, C >::end().

Referenced by TAO_AV_Core::get_acceptor(), and TAO_AV_Core::remove_acceptor().

00087 {
00088   return this->acceptors_.end ();
00089 }

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

Definition at line 214 of file Transport.cpp.

References acceptors_, ACE_DEBUG, ACE_ERROR_RETURN, ACE_Unbounded_Set_Ex< T, C >::begin(), TAO_AV_Flow_Protocol_Factory::control_flow_factory(), ACE_Unbounded_Set_Ex< T, C >::end(), TAO_AV_Core::get_flow_protocol_factory(), TAO_AV_Core::get_transport_factory(), ACE_Unbounded_Set_Ex< T, C >::insert(), LM_DEBUG, LM_ERROR, TAO_AV_Transport_Factory::make_acceptor(), TAO_AV_Acceptor::open(), open_default(), ACE_OS::strcmp(), TAO_AV_Core::TAO_AV_CONTROL, TAO_AV_Core::TAO_AV_DATA, and TAO_debug_level.

Referenced by TAO_FlowProducer::connect_mcast(), TAO_FlowEndPoint::go_to_listen_i(), TAO_AV_Core::init_forward_flows(), and TAO_StreamEndPoint_A::multiconnect().

00217 {
00218   int retv = 0;
00219 
00220   if (TAO_debug_level > 0)
00221     ACE_DEBUG ((LM_DEBUG,
00222                 "TAO_AV_Acceptor_Registry::open \n"));
00223 
00224   TAO_AV_FlowSpecSetItor last_flowspec
00225     = flow_spec_set.end ();
00226 
00227   for (TAO_AV_FlowSpecSetItor flow_spec = flow_spec_set.begin ();
00228        flow_spec != last_flowspec;
00229        ++flow_spec)
00230     {
00231       TAO_FlowSpec_Entry *entry = (*flow_spec);
00232       ACE_Addr *address = entry->address ();
00233       const char *flow_protocol = entry->flow_protocol_str ();
00234       const char *transport_protocol = entry->carrier_protocol_str ();
00235 
00236       if (ACE_OS::strcmp (flow_protocol,"") == 0)
00237         flow_protocol = transport_protocol;
00238 
00239       if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,
00240                                            "TAO_AV_Acceptor_Registry::protocol for flow %s is %s\n",
00241                                            entry->flowname (),
00242                                            transport_protocol));
00243 
00244       if (address == 0)
00245         {
00246           retv = this->open_default (endpoint,
00247                                      av_core,
00248                                      entry);
00249           if(retv < 0)
00250                   return retv;
00251           continue;
00252         }
00253       else
00254         {
00255           TAO_AV_Flow_Protocol_Factory *flow_factory =
00256             av_core->get_flow_protocol_factory (flow_protocol);
00257 
00258           if (flow_protocol != 0)
00259             {
00260               TAO_AV_Transport_Factory *transport_factory =
00261                 av_core->get_transport_factory (transport_protocol);
00262 
00263               if (transport_protocol != 0)
00264                 {
00265                   TAO_AV_Acceptor *acceptor = transport_factory->make_acceptor ();
00266                   if (acceptor != 0)
00267                     {
00268                       // add acceptor to list.
00269                       this->acceptors_.insert (acceptor);
00270 
00271                       if (acceptor->open (endpoint,
00272                                           av_core,
00273                                           entry,
00274                                           flow_factory,
00275                                           TAO_AV_Core::TAO_AV_DATA) == -1)
00276                         return -1;
00277 
00278                       TAO_AV_Flow_Protocol_Factory *control_flow_factory =
00279                         av_core->get_flow_protocol_factory (flow_factory->control_flow_factory ());
00280 
00281                       if (control_flow_factory != 0)
00282                         {
00283                           TAO_AV_Acceptor *acceptor = transport_factory->make_acceptor ();
00284                           if (acceptor != 0)
00285                             {
00286                               if (acceptor->open (endpoint,
00287                                                   av_core,
00288                                                   entry,
00289                                                   control_flow_factory,
00290                                                   TAO_AV_Core::TAO_AV_CONTROL) == -1)
00291                                 return -1;
00292                               // add acceptor to list.
00293                               this->acceptors_.insert (acceptor);
00294 
00295                               entry->protocol_object ()->control_object (entry->control_protocol_object ());
00296 
00297                              }
00298                            else
00299                              ACE_ERROR_RETURN ((LM_ERROR,
00300                                                 "(%P|%t) Unable to create an "
00301                                                 "acceptor for <%s>\n",
00302                                                 entry->flowname ()),
00303                                                -1);
00304                         }
00305                     }
00306                   else
00307                     ACE_ERROR_RETURN ((LM_ERROR,
00308                                        "(%P|%t) Unable to create an "
00309                                        "acceptor for <%s>\n",
00310                                        entry->flowname ()),
00311                                       -1);
00312                 }
00313             }
00314         }
00315     }
00316   return 0;
00317 }

int TAO_AV_Acceptor_Registry::open_default ( TAO_Base_StreamEndPoint endpoint,
TAO_AV_Core av_core,
TAO_FlowSpec_Entry entry 
) [protected]

Definition at line 320 of file Transport.cpp.

References acceptors_, ACE_DEBUG, ACE_ERROR, ACE_ERROR_RETURN, TAO_FlowSpec_Entry::carrier_protocol_str(), TAO_AV_Flow_Protocol_Factory::control_flow_factory(), TAO_AV_Protocol_Object::control_object(), TAO_FlowSpec_Entry::control_protocol_object(), TAO_FlowSpec_Entry::flow_protocol_str(), TAO_AV_Core::get_flow_protocol_factory(), TAO_AV_Core::get_transport_factory(), ACE_Unbounded_Set_Ex< T, C >::insert(), LM_DEBUG, LM_ERROR, TAO_AV_Transport_Factory::make_acceptor(), TAO_AV_Acceptor::open_default(), TAO_FlowSpec_Entry::protocol_object(), ACE_OS::strcmp(), TAO_AV_Core::TAO_AV_CONTROL, TAO_AV_Core::TAO_AV_DATA, and TAO_debug_level.

Referenced by open().

00323 {
00324   if (TAO_debug_level > 0)
00325     ACE_DEBUG ((LM_DEBUG,
00326                 "TAO_AV_Acceptor_Registry::open_default "));
00327 
00328   // No endpoints were specified, we let each protocol pick its own
00329   // default...
00330 
00331   const char *flow_protocol = entry->flow_protocol_str ();
00332   const char *transport_protocol = entry->carrier_protocol_str ();
00333 
00334   if (ACE_OS::strcmp (flow_protocol,"") == 0)
00335     flow_protocol = transport_protocol;
00336 
00337   TAO_AV_Flow_Protocol_Factory *flow_factory =
00338     av_core->get_flow_protocol_factory (flow_protocol);
00339 
00340   // No matching flow protocol.
00341   if (flow_factory == 0)
00342     ACE_ERROR_RETURN ((LM_ERROR,
00343                        "TAO (%P|%t) (%N,%l) Unable to match protocol prefix "
00344                        "for <%s>\n",
00345                        flow_protocol),
00346                       -1);
00347 
00348   if (TAO_debug_level > 0)
00349     ACE_DEBUG((LM_DEBUG, "(%N,%l) Matched flow_protocol: %s, Looking for transport protocol: %s\n", flow_protocol, transport_protocol));
00350 
00351   TAO_AV_Transport_Factory *transport_factory =
00352     av_core->get_transport_factory (transport_protocol);
00353 
00354   if (transport_factory == 0)
00355     ACE_ERROR_RETURN ((LM_ERROR,
00356                         "TAO (%P|%t) (%N,%l) Unable to match protocol prefix "
00357                         "for <%s>\n",
00358                         transport_protocol),
00359                        -1);
00360 
00361   // make an acceptor
00362   TAO_AV_Acceptor *acceptor =
00363     transport_factory->make_acceptor();
00364 
00365   if (acceptor == 0)
00366     ACE_ERROR_RETURN ((LM_ERROR,
00367                         "TAO (%P|%t) unable to create "
00368                         "an acceptor for <%d>\n",
00369                         transport_protocol),
00370                        -1);
00371 
00372   if (acceptor->open_default (endpoint,
00373                               av_core,
00374                               entry,
00375                               flow_factory,
00376                               TAO_AV_Core::TAO_AV_DATA) == -1)
00377     ACE_ERROR_RETURN ((LM_ERROR,
00378                        "TAO (%P|%t) unable to open "
00379                        "default acceptor for <%s>%p\n",
00380                        flow_protocol),
00381                       -1);
00382 
00383   this->acceptors_.insert (acceptor);
00384 
00385   const char *control_flow_factory_name = flow_factory->control_flow_factory ();
00386 
00387   if (control_flow_factory_name != 0)
00388     {
00389 
00390       TAO_AV_Flow_Protocol_Factory *control_flow_factory =
00391         av_core->get_flow_protocol_factory (control_flow_factory_name);
00392 
00393       if (control_flow_factory == 0)
00394         ACE_ERROR_RETURN ((LM_ERROR,
00395                            "TAO (%P|%t) Unable to match control flow "
00396                            "for <%s>\n",
00397                            control_flow_factory_name),
00398                           -1);
00399 
00400       TAO_AV_Acceptor *control_acceptor = transport_factory->make_acceptor ();
00401 
00402       if (control_acceptor == 0)
00403         ACE_ERROR_RETURN ((LM_ERROR,
00404                            "TAO (%P|%t) unable to create "
00405                            "an acceptor for <%d>\n",
00406                            transport_protocol),
00407                           -1);
00408 
00409       if (control_acceptor->open_default (endpoint,
00410                                           av_core,
00411                                           entry,
00412                                           control_flow_factory,
00413                                           TAO_AV_Core::TAO_AV_CONTROL) == -1)
00414         ACE_ERROR_RETURN ((LM_ERROR,
00415                            "TAO (%P|%t) unable to open "
00416                            "default acceptor for <%s>%p\n",
00417                            transport_protocol),
00418                           -1);
00419 
00420       this->acceptors_.insert (control_acceptor);
00421 
00422       entry->protocol_object ()->control_object (entry->control_protocol_object ());
00423     }
00424 
00425   if (this->acceptors_.size () == 0)
00426     {
00427       if (TAO_debug_level > 0)
00428         ACE_ERROR ((LM_ERROR,
00429                     "TAO (%P%t) cannot create any default acceptor\n"));
00430       return -1;
00431     }
00432 
00433   return 0;
00434 }


Member Data Documentation

TAO_AV_AcceptorSet TAO_AV_Acceptor_Registry::acceptors_ [protected]

Definition at line 318 of file Transport.h.

Referenced by begin(), close(), close_all(), end(), open(), and open_default().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:47:58 2010 for TAO_AV by  doxygen 1.4.7