TAO_Dynamic_Hash_OpTable Class Reference

Dynamic Hashing scheme for CORBA IDL operation name lookup. More...

#include <Operation_Table_Dynamic_Hash.h>

Inheritance diagram for TAO_Dynamic_Hash_OpTable:

Inheritance graph
[legend]
Collaboration diagram for TAO_Dynamic_Hash_OpTable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Dynamic_Hash_OpTable (const TAO_operation_db_entry *db, CORBA::ULong dbsize, CORBA::ULong hashtblsize, ACE_Allocator *alloc)
 ~TAO_Dynamic_Hash_OpTable (void)
 Destructor.
virtual int bind (const char *opname, const TAO::Operation_Skeletons skel_ptr)
 See the documentation in the base class for details.
virtual int find (const char *opname, TAO_Skeleton &skelfunc, const unsigned int length=0)
virtual int find (const char *opname, TAO_Collocated_Skeleton &skelfunc, TAO::Collocation_Strategy s, const unsigned int length=0)

Private Types

typedef ACE_Hash_Map_Manager_Ex<
const char *, TAO::Operation_Skeletons,
ACE_Hash< const char * >,
ACE_Equal_To< const char * >,
ACE_Null_Mutex
OP_MAP_MANAGER

Private Attributes

OP_MAP_MANAGER hash_
 The hash table data structure.

Detailed Description

Dynamic Hashing scheme for CORBA IDL operation name lookup.

Definition at line 36 of file Operation_Table_Dynamic_Hash.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager_Ex<const char *, TAO::Operation_Skeletons, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> TAO_Dynamic_Hash_OpTable::OP_MAP_MANAGER [private]

Definition at line 75 of file Operation_Table_Dynamic_Hash.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Dynamic_Hash_OpTable::TAO_Dynamic_Hash_OpTable ( const TAO_operation_db_entry db,
CORBA::ULong  dbsize,
CORBA::ULong  hashtblsize,
ACE_Allocator alloc 
)

Initialize the dynamic hash operation table with a database of operation names. The hash table size may be different from the size of the database. Hence we use the third argument to specify the size of the internal hash table. The <alloc> argument is used to determine where the memory comes from (usually from <ACE_Static_Allocator_Base>).

Definition at line 35 of file Operation_Table_Dynamic_Hash.cpp.

References ACE_ERROR, ACE_TEXT(), TAO_operation_db_entry::direct_skel_ptr, LM_ERROR, TAO_operation_db_entry::opname, and TAO_operation_db_entry::skel_ptr.

00040   : hash_ (hashtblsize, alloc)
00041 {
00042   // Iterate thru each entry in the database and bind the operation
00043   // name to its corresponding skeleton.
00044   for (CORBA::ULong i = 0; i < dbsize; ++i)
00045     {
00046       TAO::Operation_Skeletons s;
00047       s.skel_ptr = db[i].skel_ptr;
00048       s.thruPOA_skel_ptr = db[i].skel_ptr;
00049       s.direct_skel_ptr = db[i].direct_skel_ptr;
00050 
00051       // @@ (ASG): what happens if bind fails ???
00052       if (this->bind (db[i].opname, s) == -1)
00053         ACE_ERROR ((LM_ERROR,
00054                     ACE_TEXT ("(%P|%t) %p\n"),
00055                     ACE_TEXT ("bind failed")));
00056     }
00057 }

TAO_Dynamic_Hash_OpTable::~TAO_Dynamic_Hash_OpTable ( void   ) 

Destructor.

Definition at line 59 of file Operation_Table_Dynamic_Hash.cpp.

References CORBA::string_free().

00060 {
00061   // Initialize an iterator.  We need to go thru each entry and free
00062   // up storage allocated to hold the external ids.  In this case,
00063   // these are strings.
00064   OP_MAP_MANAGER::ITERATOR iterator (this->hash_);
00065 
00066   for (OP_MAP_MANAGER::ENTRY *entry = 0;
00067        iterator.next (entry) != 0;
00068        iterator.advance ())
00069     {
00070       // We had allocated memory and stored the string. So we free the
00071       // memory.
00072       CORBA::string_free ((char *) entry->ext_id_);
00073       entry->ext_id_ = 0;
00074     }
00075 }


Member Function Documentation

int TAO_Dynamic_Hash_OpTable::bind ( const char *  opname,
const TAO::Operation_Skeletons  skel_ptr 
) [virtual]

See the documentation in the base class for details.

Implements TAO_Operation_Table.

Definition at line 78 of file Operation_Table_Dynamic_Hash.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), hash_, and CORBA::string_dup().

00080 {
00081   return this->hash_.bind (CORBA::string_dup (opname),
00082                            skel_ptr);
00083 }

int TAO_Dynamic_Hash_OpTable::find ( const char *  opname,
TAO_Collocated_Skeleton skelfunc,
TAO::Collocation_Strategy  s,
const unsigned int  length = 0 
) [virtual]

Uses opname to look up the collocated skeleton function and pass it back in skelfunc. Returns non-negative integer on success, or -1 on failure.

Implements TAO_Operation_Table.

Definition at line 106 of file Operation_Table_Dynamic_Hash.cpp.

References ACE_FUNCTION_TIMEPROBE, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), hash_, and TAO::TAO_CS_DIRECT_STRATEGY.

00110 {
00111   ACE_FUNCTION_TIMEPROBE (TAO_DYNAMIC_HASH_OPTABLE_FIND_START);
00112 
00113   TAO::Operation_Skeletons skel;
00114 
00115   int retval =
00116     this->hash_.find ((const char *)opname, skel);
00117 
00118   if (retval != -1)
00119     {
00120       switch (s)
00121         {
00122         case TAO::TAO_CS_DIRECT_STRATEGY:
00123           skel_ptr = skel.direct_skel_ptr;
00124           break;
00125         default:
00126           return -1;
00127         }
00128     }
00129 
00130   return retval;
00131 }

int TAO_Dynamic_Hash_OpTable::find ( const char *  opname,
TAO_Skeleton skelfunc,
const unsigned int  length = 0 
) [virtual]

Uses opname to look up the skeleton function and pass it back in skelfunc. Returns non-negative integer on success, or -1 on failure.

Implements TAO_Operation_Table.

Definition at line 86 of file Operation_Table_Dynamic_Hash.cpp.

References ACE_FUNCTION_TIMEPROBE, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), and hash_.

00089 {
00090   ACE_FUNCTION_TIMEPROBE (TAO_DYNAMIC_HASH_OPTABLE_FIND_START);
00091   TAO::Operation_Skeletons s;
00092 
00093   int retval =
00094     this->hash_.find ((const char *)opname,
00095                       s);
00096 
00097   if (retval != -1)
00098     {
00099       skel_ptr = s.skel_ptr;
00100     }
00101 
00102   return retval;
00103 }


Member Data Documentation

OP_MAP_MANAGER TAO_Dynamic_Hash_OpTable::hash_ [private]

The hash table data structure.

Definition at line 78 of file Operation_Table_Dynamic_Hash.h.

Referenced by bind(), and find().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:41:29 2010 for TAO_PortableServer by  doxygen 1.4.7