Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / PortableServer / Operation_Table_Dynamic_Hash.cpp
blob95e5d4d8ba3df8234c96188c84f66a6d9248c630
1 #include "tao/PortableServer/Operation_Table_Dynamic_Hash.h"
2 #include "tao/Timeprobe.h"
3 #include "ace/Log_Msg.h"
5 #if defined (ACE_ENABLE_TIMEPROBES)
7 static const char *TAO_Operation_Table_Timeprobe_Description[] =
9 "TAO_Dynamic_Hash_OpTable::find - start",
10 "TAO_Dynamic_Hash_OpTable::find - end",
13 enum
15 // Timeprobe description table start key
16 TAO_DYNAMIC_HASH_OPTABLE_FIND_START = 600,
17 TAO_DYNAMIC_HASH_OPTABLE_FIND_END,
20 // Setup Timeprobes
21 ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_Operation_Table_Timeprobe_Description,
22 TAO_DYNAMIC_HASH_OPTABLE_FIND_START);
24 #endif /* ACE_ENABLE_TIMEPROBES */
26 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
28 // constructor
29 TAO_Dynamic_Hash_OpTable::TAO_Dynamic_Hash_OpTable (
30 TAO_operation_db_entry const * db,
31 CORBA::ULong dbsize,
32 CORBA::ULong hashtblsize,
33 ACE_Allocator *alloc)
34 : hash_ (hashtblsize, alloc)
36 // Iterate thru each entry in the database and bind the operation
37 // name to its corresponding skeleton.
38 for (CORBA::ULong i = 0; i < dbsize; ++i)
40 TAO::Operation_Skeletons s;
41 s.skel_ptr = db[i].skel_ptr;
42 s.thruPOA_skel_ptr = db[i].skel_ptr;
43 s.direct_skel_ptr = db[i].direct_skel_ptr;
45 // @@ (ASG): what happens if bind fails ???
46 if (this->bind (db[i].opname, s) == -1)
47 TAOLIB_ERROR ((LM_ERROR,
48 ACE_TEXT ("(%P|%t) %p\n"),
49 ACE_TEXT ("bind failed")));
53 TAO_Dynamic_Hash_OpTable::~TAO_Dynamic_Hash_OpTable ()
55 // Initialize an iterator. We need to go thru each entry and free
56 // up storage allocated to hold the external ids. In this case,
57 // these are strings.
58 OP_MAP_MANAGER::ITERATOR iterator (this->hash_);
60 for (OP_MAP_MANAGER::ENTRY *entry = 0;
61 iterator.next (entry) != 0;
62 iterator.advance ())
64 // We had allocated memory and stored the string. So we free the
65 // memory.
66 CORBA::string_free ((char *) entry->ext_id_);
67 entry->ext_id_ = 0;
71 int
72 TAO_Dynamic_Hash_OpTable::bind (const char *opname,
73 const TAO::Operation_Skeletons skel_ptr)
75 return this->hash_.bind (CORBA::string_dup (opname), skel_ptr);
78 int
79 TAO_Dynamic_Hash_OpTable::find (const char *opname,
80 TAO_Skeleton& skel_ptr,
81 const unsigned int )
83 ACE_FUNCTION_TIMEPROBE (TAO_DYNAMIC_HASH_OPTABLE_FIND_START);
84 TAO::Operation_Skeletons s;
86 int const retval = this->hash_.find (opname, s);
88 if (retval != -1)
90 skel_ptr = s.skel_ptr;
93 return retval;
96 int
97 TAO_Dynamic_Hash_OpTable::find (const char *opname,
98 TAO_Collocated_Skeleton& skel_ptr,
99 TAO::Collocation_Strategy s,
100 const unsigned int )
102 ACE_FUNCTION_TIMEPROBE (TAO_DYNAMIC_HASH_OPTABLE_FIND_START);
104 TAO::Operation_Skeletons skel;
106 int const retval = this->hash_.find (opname, skel);
108 if (retval != -1)
110 switch (s)
112 case TAO::TAO_CS_DIRECT_STRATEGY:
113 skel_ptr = skel.direct_skel_ptr;
114 break;
115 default:
116 return -1;
120 return retval;
123 TAO_END_VERSIONED_NAMESPACE_DECL