Classes | Public Types | Public Member Functions | Protected Attributes

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.

Classes

struct  Map_Entry
 Value field of the portable group map. More...

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

Id hash map.

Definition at line 118 of file Portable_Group_Map.h.

Definition at line 119 of file Portable_Group_Map.h.


Constructor & Destructor Documentation

TAO_Portable_Group_Map::TAO_Portable_Group_Map (  ) 

Constructor.

Definition at line 15 of file Portable_Group_Map.cpp.

{
}

TAO_Portable_Group_Map::~TAO_Portable_Group_Map ( void   ) 

Destructor.

Definition at line 20 of file Portable_Group_Map.cpp.

{
  for (Iterator i = this->map_.begin ();
       i != this->map_.end ();
       ++i)
    {
      // Deallocate the id.
      delete (*i).ext_id_;

      // Delete the chain of Map_Entries.
      Map_Entry *entry = (*i).int_id_;
      while (entry)
        {
          Map_Entry *next = entry->next;
          delete entry;
          entry = next;
        }

    }

  this->map_.close ();
}


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.

{
  ACE_GUARD (TAO_SYNCH_MUTEX,
             guard,
             this->lock_);

  Map_Entry *new_entry;

  // We take ownership of the group_id memory.  Be sure we don't
  // forget about it.
  PortableGroup::TagGroupTaggedComponent_var safe_group = group_id;

  ACE_NEW_THROW_EX (new_entry,
                    Map_Entry (),
                    CORBA::NO_MEMORY (
                                      CORBA::SystemException::_tao_minor_code (
                                                                               TAO::VMCID,
                                                                               ENOMEM),
                                      CORBA::COMPLETED_NO));

  // Fill out the entry.
  new_entry->key = key;

  // First, check if the GroupId is already in the map.
  Map_Entry *entry;
  if (this->map_.find (group_id,
                       entry) == 0)
    {
      // Add the object key to the list of object keys serviced by this GroupId.
      new_entry->next = entry->next;
      entry->next = new_entry;
    }
  else
    {
      new_entry->next = 0;

      // Add the
      int result =
        this->map_.bind (group_id,
                         new_entry);

      if (result != 0)
        {
          delete new_entry;
          throw CORBA::INTERNAL ();
        }

      // Transfer ownership of group_id to the map.
      (void) safe_group._retn ();
    }
}

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.

{
  ACE_GUARD (TAO_SYNCH_MUTEX,
             guard,
             this->lock_);

  // Look up the GroupId.
  Map_Entry *entry = 0;
  if (this->map_.find (group_id,
                       entry) == 0)
    {

      // Save the read pointer in the message block since
      // every time we dispatch the request, we need to
      // reset it so that the request demarshals correctly.
      TAO_InputCDR *tao_in = request.incoming ();
      ACE_Message_Block *msgblk =
          const_cast<ACE_Message_Block *> (tao_in->start ());
      char *read_ptr = msgblk->rd_ptr ();

      // Iterate through the list of ObjectKeys.
      while (entry)
        {
          orb_core->adapter_registry ().dispatch (entry->key,
                                                  request,
                                                  forward_to);

          // Reset the read pointer in the message block.
          msgblk->rd_ptr (read_ptr);
          entry = entry->next;
        }
    }
}

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.

{

}


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.

Id map.

Definition at line 126 of file Portable_Group_Map.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines