TAO_PortableGroup_Acceptor_Registry Class Reference

More...

#include <PortableGroup_Acceptor_Registry.h>

Collaboration diagram for TAO_PortableGroup_Acceptor_Registry:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Unbounded_Queue<
Entry
Acceptor_Registry
typedef ACE_Unbounded_Queue_Iterator<
Entry
Acceptor_Registry_Iterator

Public Member Functions

 TAO_PortableGroup_Acceptor_Registry (void)
 Default constructor.

 ~TAO_PortableGroup_Acceptor_Registry (void)
 Default destructor.

void open (const TAO_Profile *profile, TAO_ORB_Core &orb_core)
 Open an acceptor based on a tagged profile.

int close_all (void)
 Close all open acceptors.


Protected Member Functions

void open_i (const TAO_Profile *profile, TAO_ORB_Core &orb_core, TAO_ProtocolFactorySetItor &factory)
 Helper function to open a group acceptor.

int find (const TAO_Profile *profile, Entry *&entry)
 Find an acceptor by using a profile.


Private Member Functions

 TAO_PortableGroup_Acceptor_Registry (const TAO_PortableGroup_Acceptor_Registry &)
void operator= (const TAO_PortableGroup_Acceptor_Registry &)

Private Attributes

Acceptor_Registry registry_
 List of acceptors that are currently open.


Detailed Description

There is one TAO_PortableGroup_Acceptor_Registry per ORB_Core.

Definition at line 49 of file PortableGroup_Acceptor_Registry.h.


Member Typedef Documentation

typedef ACE_Unbounded_Queue<Entry> TAO_PortableGroup_Acceptor_Registry::Acceptor_Registry
 

Definition at line 86 of file PortableGroup_Acceptor_Registry.h.

typedef ACE_Unbounded_Queue_Iterator<Entry> TAO_PortableGroup_Acceptor_Registry::Acceptor_Registry_Iterator
 

Definition at line 87 of file PortableGroup_Acceptor_Registry.h.

Referenced by find(), and ~TAO_PortableGroup_Acceptor_Registry().


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_PortableGroup_Acceptor_Registry::TAO_PortableGroup_Acceptor_Registry void   ) 
 

Default constructor.

Definition at line 19 of file PortableGroup_Acceptor_Registry.cpp.

00020 {
00021 }

TAO_PortableGroup_Acceptor_Registry::~TAO_PortableGroup_Acceptor_Registry void   ) 
 

Default destructor.

Definition at line 23 of file PortableGroup_Acceptor_Registry.cpp.

References TAO_PortableGroup_Acceptor_Registry::Entry::acceptor, Acceptor_Registry_Iterator, ACE_Unbounded_Queue_Iterator< Entry >::advance(), TAO_PortableGroup_Acceptor_Registry::Entry::endpoint, and ACE_Unbounded_Queue_Iterator< Entry >::next().

00024 {
00025   // Free the memory for the endpoints.
00026   Entry *entry;
00027   Acceptor_Registry_Iterator iter (this->registry_);
00028 
00029   while (iter.next (entry))
00030     {
00031       delete entry->endpoint;
00032       delete entry->acceptor;
00033       iter.advance ();
00034     }
00035 }

TAO_PortableGroup_Acceptor_Registry::TAO_PortableGroup_Acceptor_Registry const TAO_PortableGroup_Acceptor_Registry  )  [private]
 


Member Function Documentation

int TAO_PortableGroup_Acceptor_Registry::close_all void   ) 
 

Close all open acceptors.

int TAO_PortableGroup_Acceptor_Registry::find const TAO_Profile profile,
Entry *&  entry
[protected]
 

Find an acceptor by using a profile.

Definition at line 171 of file PortableGroup_Acceptor_Registry.cpp.

References Acceptor_Registry_Iterator, ACE_Unbounded_Queue_Iterator< Entry >::advance(), TAO_Profile::endpoint(), TAO_PortableGroup_Acceptor_Registry::Entry::endpoint, TAO_Endpoint::is_equivalent(), and ACE_Unbounded_Queue_Iterator< Entry >::next().

Referenced by open().

00173 {
00174   Acceptor_Registry_Iterator iter (this->registry_);
00175 
00176   while (iter.next (entry))
00177     {
00178       // Since the endpoint routine is nonconst, need to
00179       // cast away the constness even though we're not
00180       // changing anything.
00181       TAO_Profile *nc_profile = const_cast<TAO_Profile *> (profile);
00182       if (entry->endpoint->is_equivalent (nc_profile->endpoint ()))
00183         return 1;
00184 
00185       iter.advance ();
00186    }
00187 
00188    return 0;
00189 }

void TAO_PortableGroup_Acceptor_Registry::open const TAO_Profile profile,
TAO_ORB_Core orb_core
 

Open an acceptor based on a tagged profile.

Definition at line 39 of file PortableGroup_Acceptor_Registry.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, TAO_PortableGroup_Acceptor_Registry::Entry::cnt, find(), open_i(), TAO_Profile::tag(), and TAO_ProtocolFactorySetItor.

Referenced by TAO_GOA::create_group_acceptors().

00042 {
00043   Entry *entry;
00044 
00045   if (this->find (profile, entry) == 1)
00046     {
00047       // Found it.  Increment the reference count.
00048       ++entry->cnt;
00049     }
00050   else
00051     {
00052       // Not found.  Open a new acceptor.
00053 
00054       // Now get the list of available protocol factories.
00055       TAO_ProtocolFactorySetItor end =
00056         orb_core.protocol_factories ()->end ();
00057 
00058       // int found = 0;
00059       // If usable protocol (factory) is found then this will be
00060       // set equal to 1.
00061 
00062       for (TAO_ProtocolFactorySetItor factory =
00063              orb_core.protocol_factories ()->begin ();
00064            factory != end;
00065            ++factory)
00066         {
00067           if ((*factory)->factory ()->tag () == profile->tag ())
00068             {
00069               this->open_i (profile,
00070                             orb_core,
00071                             factory
00072                             ACE_ENV_ARG_PARAMETER);
00073               ACE_CHECK;
00074 
00075               // found = 1;  // A usable protocol was found.
00076             }
00077           else
00078             continue;
00079         }
00080     }
00081 }

void TAO_PortableGroup_Acceptor_Registry::open_i const TAO_Profile profile,
TAO_ORB_Core orb_core,
TAO_ProtocolFactorySetItor factory
[protected]
 

Helper function to open a group acceptor.

Definition at line 86 of file PortableGroup_Acceptor_Registry.cpp.

References TAO_PortableGroup_Acceptor_Registry::Entry::acceptor, ACE_ERROR, ACE_TEXT(), ACE_THROW, TAO_Endpoint::addr_to_string(), TAO_PortableGroup_Acceptor_Registry::Entry::cnt, TAO_Endpoint::duplicate(), TAO_PortableGroup_Acceptor_Registry::Entry::endpoint, TAO_Profile::endpoint(), ACE_Unbounded_Queue< T >::enqueue_tail(), TAO_ORB_Core::lane_resources(), TAO_Thread_Lane_Resources::leader_follower(), LM_ERROR, TAO_GIOP_Message_Version::major, MAX_ADDR_LENGTH, TAO_GIOP_Message_Version::minor, TAO_Acceptor::open(), TAO_Leader_Follower::reactor(), TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, TAO_debug_level, and TAO_Profile::version().

Referenced by open().

00090 {
00091   TAO_Acceptor *acceptor = (*factory)->factory ()->make_acceptor ();
00092 
00093   if (acceptor != 0)
00094     {
00095       // Extract the desired endpoint/protocol version if one
00096       // exists.
00097       const TAO_GIOP_Message_Version &version = profile->version ();
00098       char buffer [MAX_ADDR_LENGTH];
00099 
00100       // Removed the constness of profile.  We're not changing
00101       // anything, but need to call a nonconst function.
00102       TAO_Profile* nc_profile = const_cast<TAO_Profile *> (profile);
00103       nc_profile->endpoint ()->addr_to_string (buffer, MAX_ADDR_LENGTH);
00104 
00105       if (acceptor->open (&orb_core,
00106                           orb_core.lane_resources ().leader_follower ().reactor(),
00107                           version.major,
00108                           version.minor,
00109                           buffer,
00110                           0) == -1)
00111         {
00112           delete acceptor;
00113 
00114           if (TAO_debug_level > 0)
00115             ACE_ERROR ((LM_ERROR,
00116                         ACE_TEXT ("TAO (%P|%t) ")
00117                         ACE_TEXT ("unable to open acceptor ")
00118                         ACE_TEXT ("for <%s>%p\n"),
00119                         buffer,
00120                         ""));
00121 
00122           ACE_THROW (CORBA::BAD_PARAM (
00123               CORBA::SystemException::_tao_minor_code (
00124                 TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE,
00125                 EINVAL),
00126               CORBA::COMPLETED_NO));
00127         }
00128 
00129       // Add acceptor to list.
00130       Entry tmp_entry;
00131       tmp_entry.acceptor = acceptor;
00132       tmp_entry.endpoint = nc_profile->endpoint ()->duplicate ();
00133       tmp_entry.cnt = 1;
00134 
00135       if (this->registry_.enqueue_tail (tmp_entry) == -1)
00136         {
00137           delete acceptor;
00138 
00139           if (TAO_debug_level > 0)
00140             ACE_ERROR ((LM_ERROR,
00141                         ACE_TEXT ("TAO (%P|%t) ")
00142                         ACE_TEXT ("unable to add acceptor to registry")
00143                         ACE_TEXT ("for <%s>%p\n"),
00144                         buffer,
00145                         ""));
00146 
00147           ACE_THROW (CORBA::BAD_PARAM (
00148               CORBA::SystemException::_tao_minor_code (
00149                 TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE,
00150                 EINVAL),
00151               CORBA::COMPLETED_NO));
00152         }
00153     }
00154   else
00155     {
00156       if (TAO_debug_level > 0)
00157         ACE_ERROR ((LM_ERROR,
00158                     ACE_TEXT ("TAO (%P|%t) ")
00159                     ACE_TEXT ("unable to create acceptor ")
00160                     ));
00161 
00162       ACE_THROW (CORBA::BAD_PARAM (
00163           CORBA::SystemException::_tao_minor_code (
00164             TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE,
00165             EINVAL),
00166           CORBA::COMPLETED_NO));
00167     }
00168 }

void TAO_PortableGroup_Acceptor_Registry::operator= const TAO_PortableGroup_Acceptor_Registry  )  [private]
 


Member Data Documentation

Acceptor_Registry TAO_PortableGroup_Acceptor_Registry::registry_ [private]
 

List of acceptors that are currently open.

Definition at line 110 of file PortableGroup_Acceptor_Registry.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:05:03 2006 for TAO_PortableGroup by doxygen 1.3.6