Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Object_Ref_Table Class Reference

Keep a table de-stringified object references registered with the ORB. More...

#include <Object_Ref_Table.h>

Collaboration diagram for TAO_Object_Ref_Table:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Hash_Map_Manager_Ex<
const char *, CORBA::Object_ptr,
ACE_Hash< const char * >,
ACE_Equal_To< const char * >,
TAO_SYNCH_MUTEX > 
Table
typedef Table::iterator Iterator

Public Methods

 TAO_Object_Ref_Table (void)
 Constructor. More...

 ~TAO_Object_Ref_Table (void)
 Destructor. More...

void register_initial_reference (const char *id, CORBA::Object_ptr obj ACE_ENV_ARG_DECL)
 Register an object reference with the table, and map the given ID to it. More...

CORBA::Object_ptr resolve_initial_references (const char *id ACE_ENV_ARG_DECL)
 Return the object reference associated with the given ID. A duplicate is returned. More...

void destroy (void)
 Explicitly destroy the contents of the object reference table. More...

size_t current_size (void) const
 Return the current size of the underlying table. More...

Forward Iterators
Iterator begin (void)
Iterator end (void)

Private Methods

 TAO_Object_Ref_Table (const TAO_Object_Ref_Table &)
 Prevent copying. More...

void operator= (const TAO_Object_Ref_Table &)
The canonical ACE_Map methods
int bind (const char *orb_id, CORBA::Object_ptr obj)
CORBA::Object_ptr find (const char *orb_id)
int unbind (const char *orb_id)

Private Attributes

Table table_
 The implementation. More...


Detailed Description

Keep a table de-stringified object references registered with the ORB.

The class is necessary to allow local objects to be accessible via the resolve_initial_references() mechanism. Since local object references cannot be stringified, they cannot be placed into the initial reference map that maps object key/name to stringified object reference. Hence, another table is needed.

Note:
The stringified reference table is still needed since it is sometimes necessary to delay de-stringification of an IOR until it is needed. For example, "corbaname" may return different results on each use.

Definition at line 48 of file Object_Ref_Table.h.


Member Typedef Documentation

typedef Table::iterator TAO_Object_Ref_Table::Iterator
 

Definition at line 53 of file Object_Ref_Table.h.

Referenced by destroy, and TAO_ORB_Core::list_initial_references.

typedef ACE_Hash_Map_Manager_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX> TAO_Object_Ref_Table::Table
 

Definition at line 52 of file Object_Ref_Table.h.


Constructor & Destructor Documentation

TAO_Object_Ref_Table::TAO_Object_Ref_Table void   
 

Constructor.

Definition at line 16 of file Object_Ref_Table.cpp.

References TAO_DEFAULT_OBJECT_REF_TABLE_SIZE.

00017   : table_ (TAO_DEFAULT_OBJECT_REF_TABLE_SIZE)
00018 {
00019 }

TAO_Object_Ref_Table::~TAO_Object_Ref_Table void   
 

Destructor.

Definition at line 21 of file Object_Ref_Table.cpp.

References destroy.

00022 {
00023   // Must explicitly call destroy() in the destructor since not all
00024   // applications will invoke ORB::shutdown() or ORB::destroy().
00025   this->destroy ();
00026 }

TAO_Object_Ref_Table::TAO_Object_Ref_Table const TAO_Object_Ref_Table &    [private]
 

Prevent copying.


Member Function Documentation

TAO_Object_Ref_Table::Iterator TAO_Object_Ref_Table::begin void   
 

Definition at line 93 of file Object_Ref_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::begin, and table_.

Referenced by destroy, and TAO_ORB_Core::list_initial_references.

00094 {
00095   return this->table_.begin ();
00096 }

int TAO_Object_Ref_Table::bind const char *    orb_id,
CORBA::Object_ptr    obj
[private]
 

Definition at line 111 of file Object_Ref_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::bind, CORBA::is_nil, CORBA::string_dup, and table_.

Referenced by register_initial_reference.

00113 {
00114   // Make sure that the supplied Object reference is valid,
00115   // i.e. not nil.
00116   if (id == 0 || CORBA::is_nil (obj))
00117     {
00118       errno = EINVAL;
00119       return -1;
00120     };
00121 
00122   CORBA::String_var name = CORBA::string_dup (id);
00123   CORBA::Object_var object = CORBA::Object::_duplicate (obj);
00124 
00125   int result = this->table_.bind (name.in (),
00126                                   object.in ());
00127 
00128   if (result == 0)
00129     {
00130       // Transfer ownership to the Object Table.
00131       (void) name._retn ();
00132       (void) object._retn ();
00133     }
00134 
00135   return result;
00136 }

size_t TAO_Object_Ref_Table::current_size void    const
 

Return the current size of the underlying table.

Definition at line 105 of file Object_Ref_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::current_size, and table_.

Referenced by TAO_ORB_Core::list_initial_references.

00106 {
00107   return this->table_.current_size ();
00108 }

void TAO_Object_Ref_Table::destroy void   
 

Explicitly destroy the contents of the object reference table.

Definition at line 76 of file Object_Ref_Table.cpp.

References begin, end, Iterator, CORBA::release, CORBA::string_free, table_, and ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::unbind_all.

Referenced by ~TAO_Object_Ref_Table.

00077 {
00078   for (Iterator i = this->begin ();
00079        i != this->end ();
00080        ++i)
00081     {
00082       // Deallocate the id.
00083       CORBA::string_free (ACE_const_cast (char *, (*i).ext_id_));
00084 
00085       // Release the Object.
00086       CORBA::release ((*i).int_id_);
00087     }
00088 
00089   this->table_.unbind_all ();
00090 }

TAO_Object_Ref_Table::Iterator TAO_Object_Ref_Table::end void   
 

Definition at line 99 of file Object_Ref_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::end, and table_.

Referenced by destroy, and TAO_ORB_Core::list_initial_references.

00100 {
00101   return this->table_.end ();
00102 }

CORBA::Object_ptr TAO_Object_Ref_Table::find const char *    orb_id [private]
 

Definition at line 139 of file Object_Ref_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::find, and table_.

Referenced by resolve_initial_references.

00140 {
00141   CORBA::Object_ptr found = CORBA::Object::_nil ();
00142 
00143   this->table_.find (id, found);
00144 
00145   return CORBA::Object::_duplicate (found);
00146 }

void TAO_Object_Ref_Table::operator= const TAO_Object_Ref_Table &    [private]
 

void TAO_Object_Ref_Table::register_initial_reference const char *    id,
CORBA::Object_ptr obj    ACE_ENV_ARG_DECL
 

Register an object reference with the table, and map the given ID to it.

Definition at line 29 of file Object_Ref_Table.cpp.

References ACE_ENV_ARG_DECL, ACE_ERROR, ACE_THROW, bind, CORBA::is_nil, LM_ERROR, and ACE_OS_String::strlen.

Referenced by TAO_ORBInitInfo::register_initial_reference, and CORBA_ORB::register_initial_reference.

00033 {
00034   if (id == 0 || ACE_OS_String::strlen (id) == 0)
00035     ACE_THROW (CORBA::ORB::InvalidName ());
00036   else if (CORBA::is_nil (obj))
00037     ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 27,
00038                                  CORBA::COMPLETED_NO));
00039 
00040   int result = this->bind (id, obj);
00041 
00042   if (result == 1)
00043     {
00044       if (TAO_debug_level > 1)
00045         ACE_ERROR ((LM_ERROR,
00046                     "(%P|%t) Object_Ref_Table::register_initial_reference:\n"
00047                     "  Could not register duplicate object <%s> with "
00048                     "the ORB\n",
00049                     id));
00050 
00051       ACE_THROW (CORBA::ORB::InvalidName ());
00052     }
00053 
00054   if (result == -1)
00055     {
00056       if (TAO_debug_level > 1)
00057         ACE_ERROR ((LM_ERROR,
00058                     "(%P|%t) Object_Ref_Table::register_initial_reference:\n"
00059                     "  Could not register object <%s> with "
00060                     "the ORB\n",
00061                     id));
00062 
00063       ACE_THROW (CORBA::INTERNAL ());
00064     }
00065 }

CORBA::Object_ptr TAO_Object_Ref_Table::resolve_initial_references const char *id    ACE_ENV_ARG_DECL
 

Return the object reference associated with the given ID. A duplicate is returned.

Definition at line 68 of file Object_Ref_Table.cpp.

References ACE_ENV_ARG_DECL_NOT_USED, and find.

Referenced by CORBA_ORB::resolve_initial_references, TAO_ORB_Core::resolve_rt_current, and TAO_ORB_Core::resolve_rt_orb.

00071 {
00072   return this->find (id);  // Returns a duplicate.
00073 }

int TAO_Object_Ref_Table::unbind const char *    orb_id [private]
 

Definition at line 149 of file Object_Ref_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::find, CORBA::release, CORBA::string_free, table_, and ACE_Hash_Map_Manager_Ex< const char *, CORBA::Object_ptr, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_MUTEX >::unbind.

00150 {
00151   Table::ENTRY *entry = 0;
00152 
00153   int result = this->table_.find (id, entry);
00154 
00155   if (result == 0)
00156     {
00157       // Deallocate the external ID and obtain the ORB core pointer
00158       // before unbinding the entry since the entry is deallocated
00159       // during the call to unbind().
00160       CORBA::string_free (ACE_const_cast (char *, entry->ext_id_));
00161       CORBA::Object_ptr obj = entry->int_id_;
00162 
00163       result = this->table_.unbind (entry);
00164 
00165       if (result != 0)
00166         return result;
00167 
00168       CORBA::release (obj);
00169     }
00170 
00171   return result;
00172 }


Member Data Documentation

Table TAO_Object_Ref_Table::table_ [private]
 

The implementation.

Definition at line 107 of file Object_Ref_Table.h.

Referenced by begin, bind, current_size, destroy, end, find, and unbind.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:29:43 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002