#include <Portable_Group_Map.h>
Collaboration diagram for TAO_Portable_Group_Map:
Public Types | |
typedef ACE_Hash_Map_Manager_Ex< PortableGroup::TagGroupTaggedComponent *, Map_Entry *, TAO_GroupId_Hash, TAO_GroupId_Equal_To, ACE_Null_Mutex > | GroupId_Table |
Id hash map. | |
typedef GroupId_Table::iterator | Iterator |
Public Member Functions | |
TAO_Portable_Group_Map () | |
Constructor. | |
~TAO_Portable_Group_Map (void) | |
Destructor. | |
void | add_groupid_objectkey_pair (PortableGroup::TagGroupTaggedComponent *group_id, const TAO::ObjectKey &key) |
void | remove_groupid_objectkey_pair (const PortableGroup::TagGroupTaggedComponent *group_id, const TAO::ObjectKey &key) |
Remove a GroupId->ObjectKey mapping from the map. | |
void | dispatch (PortableGroup::TagGroupTaggedComponent *group_id, TAO_ORB_Core *orb_core, TAO_ServerRequest &request, CORBA::Object_out forward_to) |
Protected Attributes | |
TAO_SYNCH_MUTEX | lock_ |
Lock used to synchronize access to map_. | |
GroupId_Table | map_ |
Id map. |
Definition at line 71 of file Portable_Group_Map.h.
|
Id hash map.
Definition at line 121 of file Portable_Group_Map.h. |
|
Definition at line 122 of file Portable_Group_Map.h. |
|
Constructor.
Definition at line 15 of file Portable_Group_Map.cpp.
00016 { 00017 } |
|
Destructor.
Definition at line 20 of file Portable_Group_Map.cpp. References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::begin(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::close(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and TAO_Portable_Group_Map::Map_Entry::next.
00021 { 00022 for (Iterator i = this->map_.begin (); 00023 i != this->map_.end (); 00024 ++i) 00025 { 00026 // Deallocate the id. 00027 delete (*i).ext_id_; 00028 00029 // Delete the chain of Map_Entries. 00030 Map_Entry *entry = (*i).int_id_; 00031 while (entry) 00032 { 00033 Map_Entry *next = entry->next; 00034 delete entry; 00035 entry = next; 00036 } 00037 00038 } 00039 00040 this->map_.close (); 00041 } |
|
Add a GroupId->ObjectKey mapping to the map. This function takes ownership of the memory pointed to be group_id Definition at line 45 of file Portable_Group_Map.cpp. References ACE_CHECK, ACE_GUARD, ACE_NEW_THROW_EX, ACE_THROW, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), TAO_Portable_Group_Map::Map_Entry::key, TAO_Portable_Group_Map::Map_Entry::next, and TAO_SYNCH_MUTEX. Referenced by TAO_GOA::associate_group_with_ref().
00050 { 00051 ACE_GUARD (TAO_SYNCH_MUTEX, 00052 guard, 00053 this->lock_); 00054 00055 Map_Entry *new_entry; 00056 00057 // We take ownership of the group_id memory. Be sure we don't 00058 // forget about it. 00059 PortableGroup::TagGroupTaggedComponent_var safe_group = group_id; 00060 00061 ACE_NEW_THROW_EX (new_entry, 00062 Map_Entry (), 00063 CORBA::NO_MEMORY ( 00064 CORBA::SystemException::_tao_minor_code ( 00065 TAO::VMCID, 00066 ENOMEM), 00067 CORBA::COMPLETED_NO)); 00068 ACE_CHECK; 00069 00070 // Fill out the entry. 00071 new_entry->key = key; 00072 00073 // First, check if the GroupId is already in the map. 00074 Map_Entry *entry; 00075 if (this->map_.find (group_id, 00076 entry) == 0) 00077 { 00078 // Add the object key to the list of object keys serviced by this GroupId. 00079 new_entry->next = entry->next; 00080 entry->next = new_entry; 00081 } 00082 else 00083 { 00084 new_entry->next = 0; 00085 00086 // Add the 00087 int result = 00088 this->map_.bind (group_id, 00089 new_entry); 00090 00091 if (result != 0) 00092 { 00093 delete new_entry; 00094 ACE_THROW (CORBA::INTERNAL ()); 00095 } 00096 00097 // Transfer ownership of group_id to the map. 00098 (void) safe_group._retn (); 00099 } 00100 } |
|
Dispatch a request to all of the ObjectIds that belong to the specified group. Definition at line 112 of file Portable_Group_Map.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_GUARD, TAO_ORB_Core::adapter_registry(), TAO_Adapter_Registry::dispatch(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), TAO_ServerRequest::incoming(), TAO_Portable_Group_Map::Map_Entry::key, TAO_Portable_Group_Map::Map_Entry::next, ACE_Message_Block::rd_ptr(), ACE_InputCDR::start(), and TAO_SYNCH_MUTEX. Referenced by PortableGroup_Request_Dispatcher::dispatch().
00117 { 00118 ACE_GUARD (TAO_SYNCH_MUTEX, 00119 guard, 00120 this->lock_); 00121 00122 // Look up the GroupId. 00123 Map_Entry *entry = 0; 00124 if (this->map_.find (group_id, 00125 entry) == 0) 00126 { 00127 00128 // Save the read pointer in the message block since 00129 // every time we dispatch the request, we need to 00130 // reset it so that the request demarshals correctly. 00131 TAO_InputCDR *tao_in = request.incoming (); 00132 ACE_Message_Block *msgblk = 00133 const_cast<ACE_Message_Block *> (tao_in->start ()); 00134 char *read_ptr = msgblk->rd_ptr (); 00135 00136 // Iterate through the list of ObjectKeys. 00137 while (entry) 00138 { 00139 orb_core->adapter_registry ()->dispatch (entry->key, 00140 request, 00141 forward_to 00142 ACE_ENV_ARG_PARAMETER); 00143 ACE_CHECK; 00144 00145 // Reset the read pointer in the message block. 00146 msgblk->rd_ptr (read_ptr); 00147 entry = entry->next; 00148 } 00149 } 00150 } |
|
Remove a GroupId->ObjectKey mapping from the map.
Definition at line 103 of file Portable_Group_Map.cpp.
00106 { 00107 00108 } |
|
Lock used to synchronize access to map_.
Definition at line 126 of file Portable_Group_Map.h. |
|
Id map.
Definition at line 129 of file Portable_Group_Map.h. |