Keep a table de-stringified object references registered with the ORB. More...
#include <Object_Ref_Table.h>

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 | unregister_initial_reference (const char *id) |
| 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_i (const char *orb_id, CORBA::Object_ptr obj) |
| CORBA::Object_ptr | find_i (const char *orb_id) |
| int | unbind_i (const char *orb_id) |
Private Attributes | |
| Table | table_ |
| The implementation. | |
| TAO_SYNCH_MUTEX | lock_ |
| Table synchronization lock. | |
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.
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_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] |
| TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::begin | ( | void | ) |
Definition at line 39 of file Object_Ref_Table.inl.
| int TAO_Object_Ref_Table::bind_i | ( | const char * | orb_id, | |
| CORBA::Object_ptr | obj | |||
| ) | [private] |
Definition at line 73 of file Object_Ref_Table.cpp.
00074 { 00075 // Make sure that the supplied Object reference is valid, 00076 // i.e. not nil. 00077 if (id == 0 00078 || ACE_OS::strlen (id) == 0 00079 || ::CORBA::is_nil (obj)) 00080 { 00081 errno = EINVAL; 00082 return -1; 00083 }; 00084 00085 Table::value_type const value = 00086 std::make_pair (CORBA::String_var (id), 00087 CORBA::Object_var (CORBA::Object::_duplicate (obj))); 00088 00089 std::pair<iterator, bool> const result = this->table_.insert (value); 00090 00091 if (!result.second) 00092 { 00093 if (TAO_debug_level > 1) 00094 { 00095 ACE_ERROR ((LM_ERROR, 00096 ACE_TEXT ("(%P|%t) Object_Ref_Table::bind_i: ") 00097 ACE_TEXT ("Could not register duplicate object <%C> ") 00098 ACE_TEXT ("with the ORB\n"), 00099 id)); 00100 } 00101 00102 return -1; 00103 } 00104 00105 return 0; 00106 }
| size_t TAO_Object_Ref_Table::current_size | ( | void | ) | const |
Return the current size of the underlying table.
Definition at line 51 of file Object_Ref_Table.inl.
| void TAO_Object_Ref_Table::destroy | ( | void | ) |
Explicitly destroy the contents of the object reference table.
Definition at line 27 of file Object_Ref_Table.inl.
00028 { 00029 Table tmp; 00030 00031 ACE_GUARD (TAO_SYNCH_MUTEX, 00032 guard, 00033 this->lock_); 00034 00035 this->table_.swap (tmp); // Force release of memory held by our table. 00036 }
| TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::end | ( | void | ) |
Definition at line 45 of file Object_Ref_Table.inl.
| CORBA::Object_ptr TAO_Object_Ref_Table::find_i | ( | const char * | orb_id | ) | [private] |
Definition at line 15 of file Object_Ref_Table.inl.
00016 { 00017 iterator const found = 00018 this->table_.find (CORBA::String_var (id)); 00019 00020 if (found == this->table_.end ()) 00021 return CORBA::Object::_nil (); 00022 00023 return CORBA::Object::_duplicate ((*found).second.in ()); 00024 }
| void TAO_Object_Ref_Table::operator= | ( | const TAO_Object_Ref_Table & | ) | [private] |
| 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 |
| 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 109 of file Object_Ref_Table.cpp.
00110 { 00111 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00112 guard, 00113 this->lock_, 00114 CORBA::Object::_nil ()); 00115 00116 return this->find_i (id); // Returns a duplicate. 00117 }
| int TAO_Object_Ref_Table::unbind_i | ( | const char * | orb_id | ) | [private] |
Definition at line 57 of file Object_Ref_Table.inl.
00058 { 00059 return 00060 (this->table_.erase (CORBA::String_var (id)) == 0 ? -1 : 0); 00061 }
| CORBA::Object_ptr TAO_Object_Ref_Table::unregister_initial_reference | ( | const char * | id | ) |
Unregister an object reference with the table
Definition at line 48 of file Object_Ref_Table.cpp.
00050 { 00051 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00052 guard, 00053 this->lock_, 00054 CORBA::Object::_nil()); 00055 00056 CORBA::Object_ptr obj = this->find_i (id); 00057 if (this->unbind_i (id) == -1) 00058 { 00059 if (TAO_debug_level > 1) 00060 { 00061 ACE_ERROR ((LM_ERROR, 00062 ACE_TEXT ("(%P|%t) Object_Ref_Table::bind_i: ") 00063 ACE_TEXT ("Could not unregister object <%C> ") 00064 ACE_TEXT ("from the ORB\n"), 00065 id)); 00066 } 00067 } 00068 00069 return obj; 00070 }
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.
1.6.1