#include <Object_Ref_Table.h>
Collaboration diagram for TAO_Object_Ref_Table:
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. |
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.
Definition at line 51 of file Object_Ref_Table.h.
Definition at line 59 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 57 of file Object_Ref_Table.h.
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.
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] |
ACE_INLINE TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::begin | ( | void | ) |
Definition at line 50 of file Object_Ref_Table.inl.
References ACE_Array_Map< Key, Value, EqualTo >::begin(), and table_.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL int TAO_Object_Ref_Table::bind | ( | const char * | orb_id, | |
CORBA::Object_ptr | obj | |||
) | [private] |
Definition at line 26 of file Object_Ref_Table.cpp.
References CORBA::Object::_duplicate(), ACE_ERROR, ACE_GUARD_RETURN, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_Array_Map< Key, Value, EqualTo >::insert(), CORBA::is_nil(), LM_ERROR, ACE_OS::strlen(), table_, TAO_debug_level, and TAO_SYNCH_MUTEX.
Referenced by register_initial_reference().
00027 { 00028 // Make sure that the supplied Object reference is valid, 00029 // i.e. not nil. 00030 if (id == 0 00031 || ACE_OS::strlen (id) == 0 00032 || ::CORBA::is_nil (obj)) 00033 { 00034 errno = EINVAL; 00035 return -1; 00036 }; 00037 00038 Table::value_type const value = 00039 std::make_pair (CORBA::String_var (id), 00040 CORBA::Object_var (CORBA::Object::_duplicate (obj))); 00041 00042 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00043 guard, 00044 this->lock_, 00045 -1); 00046 00047 std::pair<iterator, bool> const result = this->table_.insert (value); 00048 00049 if (!result.second) 00050 { 00051 if (TAO_debug_level > 1) 00052 { 00053 ACE_ERROR ((LM_ERROR, 00054 ACE_TEXT ("(%P|%t) Object_Ref_Table::") 00055 ACE_TEXT ("bind:") 00056 ACE_TEXT (" Could not register duplicate object <%s> ") 00057 ACE_TEXT ("with the ORB\n"), 00058 ACE_TEXT_CHAR_TO_TCHAR (id))); 00059 } 00060 00061 return -1; 00062 } 00063 00064 return 0; 00065 }
ACE_INLINE size_t TAO_Object_Ref_Table::current_size | ( | void | ) | const |
Return the current size of the underlying table.
Definition at line 62 of file Object_Ref_Table.inl.
References ACE_Array_Map< Key, Value, EqualTo >::size(), and table_.
Referenced by TAO_ORB_Core::list_initial_references().
ACE_INLINE void TAO_Object_Ref_Table::destroy | ( | void | ) |
Explicitly destroy the contents of the object reference table.
Definition at line 38 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().
00039 { 00040 Table tmp; 00041 00042 ACE_GUARD (TAO_SYNCH_MUTEX, 00043 guard, 00044 this->lock_); 00045 00046 this->table_.swap (tmp); // Force release of memory held by our table. 00047 }
ACE_INLINE TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::end | ( | void | ) |
Definition at line 56 of file Object_Ref_Table.inl.
References ACE_Array_Map< Key, Value, EqualTo >::end(), and table_.
Referenced by TAO_ORB_Core::list_initial_references().
CORBA::Object_ptr TAO_Object_Ref_Table::find | ( | const char * | orb_id | ) | [private] |
Definition at line 68 of file Object_Ref_Table.cpp.
References CORBA::Object::_duplicate(), CORBA::Object::_nil(), ACE_GUARD_RETURN, ACE_Array_Map< Key, Value, EqualTo >::find(), table_, and TAO_SYNCH_MUTEX.
Referenced by resolve_initial_reference().
00069 { 00070 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00071 guard, 00072 this->lock_, 00073 CORBA::Object::_nil ()); 00074 00075 iterator const found = 00076 this->table_.find (CORBA::String_var (id)); 00077 00078 if (found == this->table_.end ()) 00079 return CORBA::Object::_nil (); 00080 00081 return CORBA::Object::_duplicate ((*found).second.in ()); 00082 }
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.
0 | Success | |
-1 | Duplicate id if rebind is false |
Definition at line 15 of file Object_Ref_Table.inl.
References bind().
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().
00033 { 00034 return this->find (id); // Returns a duplicate. 00035 }
ACE_INLINE int TAO_Object_Ref_Table::unbind | ( | const char * | orb_id | ) | [private] |
Definition at line 68 of file Object_Ref_Table.inl.
00069 { 00070 return 00071 (this->table_.erase (CORBA::String_var (id)) == 0 ? -1 : 0); 00072 }
TAO_SYNCH_MUTEX TAO_Object_Ref_Table::lock_ [private] |
Table TAO_Object_Ref_Table::table_ [private] |
The implementation.
Definition at line 112 of file Object_Ref_Table.h.
Referenced by begin(), bind(), current_size(), destroy(), end(), and find().