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_Array_Map< CORBA::String_var,
CORBA::Object_var, TAO::String_Var_Equal_To
Table
typedef Table::iterator iterator

Public Member Functions

 TAO_Object_Ref_Table (void)
 Constructor.

int register_initial_reference (const char *id, CORBA::Object_ptr obj, bool rebind=false)
CORBA::Object_ptr resolve_initial_reference (const char *id)
void destroy (void)
 Explicitly destroy the contents of the object reference table.

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

Forward Iterators
iterator begin (void)
iterator end (void)

Private Member Functions

 TAO_Object_Ref_Table (const TAO_Object_Ref_Table &)
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.

TAO_SYNCH_MUTEX lock_
 Table synchronization lock.


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 56 of file Object_Ref_Table.h.


Member Typedef Documentation

typedef Table::iterator TAO_Object_Ref_Table::iterator
 

Definition at line 64 of file Object_Ref_Table.h.

typedef ACE_Array_Map<CORBA::String_var, CORBA::Object_var, TAO::String_Var_Equal_To> TAO_Object_Ref_Table::Table
 

Definition at line 62 of file Object_Ref_Table.h.

Referenced by destroy().


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_Object_Ref_Table::TAO_Object_Ref_Table void   ) 
 

Constructor.

Definition at line 8 of file Object_Ref_Table.inl.

References TAO_DEFAULT_OBJECT_REF_TABLE_SIZE.

00009   : table_ (TAO_DEFAULT_OBJECT_REF_TABLE_SIZE)
00010   , lock_ ()
00011 {
00012 }

TAO_Object_Ref_Table::TAO_Object_Ref_Table const TAO_Object_Ref_Table  )  [private]
 


Member Function Documentation

ACE_INLINE TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::begin void   ) 
 

Definition at line 51 of file Object_Ref_Table.inl.

References ACE_Array_Map< Key, Value, EqualTo >::begin().

Referenced by TAO_ORB_Core::list_initial_references().

00052 {
00053   return this->table_.begin ();
00054 }

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

Definition at line 27 of file Object_Ref_Table.cpp.

References ACE_ERROR, ACE_GUARD_RETURN, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_Array_Map< Key, Value, EqualTo >::insert(), LM_ERROR, CORBA::Object_ptr, CORBA::Object_var, CORBA::String_var, ACE_OS::strlen(), TAO_debug_level, and TAO_SYNCH_MUTEX.

Referenced by register_initial_reference().

00029 {
00030   // Make sure that the supplied Object reference is valid,
00031   // i.e. not nil.
00032   if (id == 0
00033       || ACE_OS::strlen (id) == 0
00034       || ::CORBA::is_nil (obj))
00035     {
00036       errno = EINVAL;
00037       return -1;
00038     };
00039 
00040   Table::value_type const value =
00041     std::make_pair (CORBA::String_var (id),
00042                     CORBA::Object_var (CORBA::Object::_duplicate (obj)));
00043 
00044   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00045                     guard,
00046                     this->lock_,
00047                     -1);
00048 
00049   std::pair<iterator, bool> const result = this->table_.insert (value);
00050 
00051   if (!result.second)
00052     {
00053       if (TAO_debug_level > 1)
00054         {
00055           ACE_ERROR ((LM_ERROR,
00056                       ACE_TEXT ("(%P|%t) Object_Ref_Table::")
00057                       ACE_TEXT ("bind:")
00058                       ACE_TEXT ("  Could not register duplicate object <%s> ")
00059                       ACE_TEXT ("with the ORB\n"),
00060                       ACE_TEXT_CHAR_TO_TCHAR (id)));
00061         }
00062 
00063       return -1;
00064     }
00065 
00066   return 0;
00067 }

ACE_INLINE size_t TAO_Object_Ref_Table::current_size void   )  const
 

Return the current size of the underlying table.

Definition at line 63 of file Object_Ref_Table.inl.

References ACE_Array_Map< Key, Value, EqualTo >::size().

Referenced by TAO_ORB_Core::list_initial_references().

00064 {
00065   return this->table_.size ();
00066 }

ACE_INLINE void TAO_Object_Ref_Table::destroy void   ) 
 

Explicitly destroy the contents of the object reference table.

Definition at line 39 of file Object_Ref_Table.inl.

References ACE_GUARD, ACE_Array_Map< Key, Value, EqualTo >::swap(), Table, and TAO_SYNCH_MUTEX.

Referenced by TAO_ORB_Core::shutdown().

00040 {
00041   Table tmp;
00042 
00043   ACE_GUARD (TAO_SYNCH_MUTEX,
00044              guard,
00045              this->lock_);
00046 
00047   this->table_.swap (tmp);  // Force release of memory held by our table.
00048 }

ACE_INLINE TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::end void   ) 
 

Definition at line 57 of file Object_Ref_Table.inl.

References ACE_Array_Map< Key, Value, EqualTo >::end().

Referenced by TAO_ORB_Core::list_initial_references().

00058 {
00059   return this->table_.end ();
00060 }

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

Definition at line 70 of file Object_Ref_Table.cpp.

References CORBA::Object::_duplicate(), CORBA::Object::_nil(), ACE_GUARD_RETURN, ACE_Array_Map< Key, Value, EqualTo >::end(), ACE_Array_Map< Key, Value, EqualTo >::find(), CORBA::String_var, and TAO_SYNCH_MUTEX.

Referenced by resolve_initial_reference().

00071 {
00072   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00073                     guard,
00074                     this->lock_,
00075                     CORBA::Object::_nil ());
00076 
00077   iterator const found =
00078     this->table_.find (CORBA::String_var (id));
00079 
00080   if (found == this->table_.end ())
00081     return CORBA::Object::_nil ();
00082 
00083   return CORBA::Object::_duplicate ((*found).second.in ());
00084 }

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

ACE_INLINE int TAO_Object_Ref_Table::register_initial_reference const char *  id,
CORBA::Object_ptr  obj,
bool  rebind = false
 

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

Return values:
0 Success
-1 Duplicate id if rebind is false

Definition at line 15 of file Object_Ref_Table.inl.

References bind(), CORBA::Object_ptr, and unbind().

Referenced by CORBA::ORB::register_initial_reference().

00019 {
00020   if (rebind)
00021     {
00022       if (this->unbind (id) == -1)
00023         return -1;
00024       else
00025         return this->bind (id, obj);
00026     }
00027   else
00028     return this->bind (id, obj);
00029 }

ACE_INLINE CORBA::Object_ptr TAO_Object_Ref_Table::resolve_initial_reference const char *  id  ) 
 

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

Definition at line 32 of file Object_Ref_Table.inl.

References find().

Referenced by CORBA::ORB::resolve_initial_references(), and TAO_ORB_Core::resolve_rt_orb().

00034 {
00035   return this->find (id);  // Returns a duplicate.
00036 }

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

Definition at line 69 of file Object_Ref_Table.inl.

References ACE_Array_Map< Key, Value, EqualTo >::erase(), and CORBA::String_var.

Referenced by register_initial_reference().

00070 {
00071   return
00072     (this->table_.erase (CORBA::String_var (id)) == 0 ? -1 : 0);
00073 }


Member Data Documentation

TAO_SYNCH_MUTEX TAO_Object_Ref_Table::lock_ [private]
 

Table synchronization lock.

Definition at line 120 of file Object_Ref_Table.h.

Table TAO_Object_Ref_Table::table_ [private]
 

The implementation.

Definition at line 117 of file Object_Ref_Table.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:22:36 2006 for TAO by doxygen 1.3.6