TAO_Portable_Group_Map Class Reference

Map of GroupIds to ObjectKeys. More...

#include <Portable_Group_Map.h>

Collaboration diagram for TAO_Portable_Group_Map:

Collaboration graph
[legend]
List of all members.

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.


Detailed Description

Map of GroupIds to ObjectKeys.

Definition at line 71 of file Portable_Group_Map.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager_Ex< PortableGroup::TagGroupTaggedComponent *, Map_Entry *, TAO_GroupId_Hash, TAO_GroupId_Equal_To, ACE_Null_Mutex> TAO_Portable_Group_Map::GroupId_Table
 

Id hash map.

Definition at line 118 of file Portable_Group_Map.h.

typedef GroupId_Table::iterator TAO_Portable_Group_Map::Iterator
 

Definition at line 119 of file Portable_Group_Map.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Portable_Group_Map::TAO_Portable_Group_Map  ) 
 

Constructor.

Definition at line 15 of file Portable_Group_Map.cpp.

00016 {
00017 }

TAO_Portable_Group_Map::~TAO_Portable_Group_Map void   ) 
 

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 }


Member Function Documentation

void TAO_Portable_Group_Map::add_groupid_objectkey_pair PortableGroup::TagGroupTaggedComponent *  group_id,
const TAO::ObjectKey key
 

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_GUARD, ACE_NEW_THROW_EX, 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().

00049 {
00050   ACE_GUARD (TAO_SYNCH_MUTEX,
00051              guard,
00052              this->lock_);
00053 
00054   Map_Entry *new_entry;
00055 
00056   // We take ownership of the group_id memory.  Be sure we don't
00057   // forget about it.
00058   PortableGroup::TagGroupTaggedComponent_var safe_group = group_id;
00059 
00060   ACE_NEW_THROW_EX (new_entry,
00061                     Map_Entry (),
00062                     CORBA::NO_MEMORY (
00063                                       CORBA::SystemException::_tao_minor_code (
00064                                                                                TAO::VMCID,
00065                                                                                ENOMEM),
00066                                       CORBA::COMPLETED_NO));
00067 
00068   // Fill out the entry.
00069   new_entry->key = key;
00070 
00071   // First, check if the GroupId is already in the map.
00072   Map_Entry *entry;
00073   if (this->map_.find (group_id,
00074                        entry) == 0)
00075     {
00076       // Add the object key to the list of object keys serviced by this GroupId.
00077       new_entry->next = entry->next;
00078       entry->next = new_entry;
00079     }
00080   else
00081     {
00082       new_entry->next = 0;
00083 
00084       // Add the
00085       int result =
00086         this->map_.bind (group_id,
00087                          new_entry);
00088 
00089       if (result != 0)
00090         {
00091           delete new_entry;
00092           throw CORBA::INTERNAL ();
00093         }
00094 
00095       // Transfer ownership of group_id to the map.
00096       (void) safe_group._retn ();
00097     }
00098 }

void TAO_Portable_Group_Map::dispatch PortableGroup::TagGroupTaggedComponent *  group_id,
TAO_ORB_Core orb_core,
TAO_ServerRequest request,
CORBA::Object_out  forward_to
 

Dispatch a request to all of the ObjectIds that belong to the specified group.

Definition at line 109 of file Portable_Group_Map.cpp.

References 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().

00113 {
00114   ACE_GUARD (TAO_SYNCH_MUTEX,
00115              guard,
00116              this->lock_);
00117 
00118   // Look up the GroupId.
00119   Map_Entry *entry = 0;
00120   if (this->map_.find (group_id,
00121                        entry) == 0)
00122     {
00123 
00124       // Save the read pointer in the message block since
00125       // every time we dispatch the request, we need to
00126       // reset it so that the request demarshals correctly.
00127       TAO_InputCDR *tao_in = request.incoming ();
00128       ACE_Message_Block *msgblk =
00129           const_cast<ACE_Message_Block *> (tao_in->start ());
00130       char *read_ptr = msgblk->rd_ptr ();
00131 
00132       // Iterate through the list of ObjectKeys.
00133       while (entry)
00134         {
00135           orb_core->adapter_registry ()->dispatch (entry->key,
00136                                                    request,
00137                                                    forward_to);
00138 
00139           // Reset the read pointer in the message block.
00140           msgblk->rd_ptr (read_ptr);
00141           entry = entry->next;
00142         }
00143     }
00144 }

void TAO_Portable_Group_Map::remove_groupid_objectkey_pair const PortableGroup::TagGroupTaggedComponent *  group_id,
const TAO::ObjectKey key
 

Remove a GroupId->ObjectKey mapping from the map.

Definition at line 101 of file Portable_Group_Map.cpp.

00103 {
00104 
00105 }


Member Data Documentation

TAO_SYNCH_MUTEX TAO_Portable_Group_Map::lock_ [protected]
 

Lock used to synchronize access to map_.

Definition at line 123 of file Portable_Group_Map.h.

GroupId_Table TAO_Portable_Group_Map::map_ [protected]
 

Id map.

Definition at line 126 of file Portable_Group_Map.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 16:24:14 2008 for TAO_PortableGroup by doxygen 1.3.6