Operation_Table_Dynamic_Hash.cpp

Go to the documentation of this file.
00001 // $Id: Operation_Table_Dynamic_Hash.cpp 71473 2006-03-10 07:19:20Z jtc $
00002 
00003 #include "tao/PortableServer/Operation_Table_Dynamic_Hash.h"
00004 #include "tao/Timeprobe.h"
00005 #include "ace/Log_Msg.h"
00006 
00007 ACE_RCSID(PortableServer,
00008           Operation_Table_Dynamic_Hash,
00009           "$Id: Operation_Table_Dynamic_Hash.cpp 71473 2006-03-10 07:19:20Z jtc $")
00010 
00011 #if defined (ACE_ENABLE_TIMEPROBES)
00012 
00013 static const char *TAO_Operation_Table_Timeprobe_Description[] =
00014   {
00015     "TAO_Dynamic_Hash_OpTable::find - start",
00016     "TAO_Dynamic_Hash_OpTable::find - end",
00017   };
00018 
00019 enum
00020   {
00021     // Timeprobe description table start key
00022     TAO_DYNAMIC_HASH_OPTABLE_FIND_START = 600,
00023     TAO_DYNAMIC_HASH_OPTABLE_FIND_END,
00024   };
00025 
00026 // Setup Timeprobes
00027 ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_Operation_Table_Timeprobe_Description,
00028                                   TAO_DYNAMIC_HASH_OPTABLE_FIND_START);
00029 
00030 #endif /* ACE_ENABLE_TIMEPROBES */
00031 
00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 // constructor
00035 TAO_Dynamic_Hash_OpTable::TAO_Dynamic_Hash_OpTable (
00036   TAO_operation_db_entry const * db,
00037   CORBA::ULong dbsize,
00038   CORBA::ULong hashtblsize,
00039   ACE_Allocator *alloc)
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 }
00058 
00059 TAO_Dynamic_Hash_OpTable::~TAO_Dynamic_Hash_OpTable (void)
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 }
00076 
00077 int
00078 TAO_Dynamic_Hash_OpTable::bind (const char *opname,
00079                                 const TAO::Operation_Skeletons skel_ptr)
00080 {
00081   return this->hash_.bind (CORBA::string_dup (opname),
00082                            skel_ptr);
00083 }
00084 
00085 int
00086 TAO_Dynamic_Hash_OpTable::find (const char *opname,
00087                                 TAO_Skeleton& skel_ptr,
00088                                 const unsigned int )
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 }
00104 
00105 int
00106 TAO_Dynamic_Hash_OpTable::find (const char *opname,
00107                                 TAO_Collocated_Skeleton& skel_ptr,
00108                                 TAO::Collocation_Strategy s,
00109                                 const unsigned int )
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 }
00132 
00133 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7