summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/ChangeLog42
-rw-r--r--TAO/tao/CORBA_String.h14
-rw-r--r--TAO/tao/CORBA_String.inl20
-rw-r--r--TAO/tao/Makefile.am1
-rw-r--r--TAO/tao/ORB.cpp15
-rw-r--r--TAO/tao/ORB_Core.cpp75
-rw-r--r--TAO/tao/ORB_Core.h15
-rw-r--r--TAO/tao/ORB_Core.i35
-rw-r--r--TAO/tao/ORB_Core_Auto_Ptr.h10
-rw-r--r--TAO/tao/ORB_Table.cpp138
-rw-r--r--TAO/tao/ORB_Table.h78
-rw-r--r--TAO/tao/ORB_Table.inl82
-rw-r--r--TAO/tao/Object_Ref_Table.cpp196
-rw-r--r--TAO/tao/Object_Ref_Table.h36
-rw-r--r--TAO/tao/Object_Ref_Table.inl67
-rw-r--r--TAO/tao/params.cpp66
-rw-r--r--TAO/tao/params.h19
-rw-r--r--TAO/tao/params.i2
18 files changed, 490 insertions, 421 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index a142b214bc1..3e3159365a5 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,45 @@
+Tue Jul 5 03:07:52 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
+
+ * tao/CORBA_String.h:
+ * tao/CORBA_String.inl:
+
+ Added TAO-specific equality operators. Allows
+ CORBA::{W}String_var to be used as map key.
+
+ * tao/ORB.cpp (resolve_initial_references):
+
+ The initial reference map is now an ACE_Array_Map, which
+ implements an STL-like map interface. Updated map iteration
+ accordingly.
+
+ * tao/ORB_Core.cpp:
+ * tao/ORB_Core.h:
+ * tao/ORB_Core.i:
+ * tao/ORB_Table.cpp:
+ * tao/ORB_Table.h:
+ * tao/ORB_Table.inl:
+ * tao/Object_Ref_Table.cpp:
+ * tao/Object_Ref_Table.h:
+ * tao/Object_Ref_Table.inl:
+ * tao/params.cpp:
+ * tao/params.h:
+ * tao/params.i:
+
+ Replaced ACE_Hash_Map_Manager_Ex usage with light weight
+ ACE_Array_Map. Hash map benefits were not worth the larger
+ footprint.
+
+ Inlined a number very small functions. Reduces footprint.
+
+ * tao/ORB_Core_Auto_Ptr.h (TAO_ORB_Core_Auto_Ptr):
+
+ Uncommented "explicit" constructor keyword. Support for it has
+ been required in ACE and TAO for a while now.
+
+ * tao/Makefile.am (nobase_include_HEADERS):
+
+ Added new Object_Ref_Table.inl inline soure file.
+
Mon Jul 4 18:56:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
* orbsvcs/orbsvcs/PortableGroup/MIOP.h:
diff --git a/TAO/tao/CORBA_String.h b/TAO/tao/CORBA_String.h
index 3bdefec28ea..3e193c437b4 100644
--- a/TAO/tao/CORBA_String.h
+++ b/TAO/tao/CORBA_String.h
@@ -289,6 +289,20 @@ namespace CORBA
// assignment from _var disallowed
void operator= (const CORBA::WString_var &);
};
+
+ /**
+ * @name TAO-specific Equality Operators
+ *
+ * These equality operators exist to simplify usage of @c
+ * {W}String_var in containers.
+ */
+ //@{
+ bool operator== (CORBA::String_var const & lhs,
+ CORBA::String_var const & rhs);
+ bool operator== (CORBA::WString_var const & lhs,
+ CORBA::WString_var const & rhs);
+ //@}
+
} // End CORBA namespace.
# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
diff --git a/TAO/tao/CORBA_String.inl b/TAO/tao/CORBA_String.inl
index bdee6f54ac1..083d600ccc2 100644
--- a/TAO/tao/CORBA_String.inl
+++ b/TAO/tao/CORBA_String.inl
@@ -6,6 +6,10 @@
// String_var type
// ----------------------------------------------------------------------
+#include "ace/OS_NS_string.h"
+// #include "ace/OS_NS_wchar.h"
+
+
ACE_INLINE
CORBA::String_var::String_var (void)
: ptr_ (0)
@@ -269,3 +273,19 @@ CORBA::WString_out::ptr (void)
{
return this->ptr_;
}
+
+// ----------------------------------------------------------------------
+
+ACE_INLINE bool
+CORBA::operator== (CORBA::String_var const & lhs,
+ CORBA::String_var const & rhs)
+{
+ return (ACE_OS::strcmp (lhs.in (), rhs.in ()) == 0);
+}
+
+ACE_INLINE bool
+CORBA::operator== (CORBA::WString_var const & lhs,
+ CORBA::WString_var const & rhs)
+{
+ return (ACE_OS::strcmp (lhs.in (), rhs.in ()) == 0);
+}
diff --git a/TAO/tao/Makefile.am b/TAO/tao/Makefile.am
index abfcee6e195..8268a89c48d 100644
--- a/TAO/tao/Makefile.am
+++ b/TAO/tao/Makefile.am
@@ -652,6 +652,7 @@ nobase_include_HEADERS = \
Object_Proxy_Broker.h \
Object_Proxy_Impl.h \
Object_Ref_Table.h \
+ Object_Ref_Table.inl \
Object_T.cpp \
Object_T.h \
Objref_TypeCode.cpp \
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 3f60931e5f3..6347e280241 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -1182,12 +1182,17 @@ CORBA::ORB::resolve_initial_references (const char *name,
// -----------------------------------------------------------------
// Check ORBInitRef options.
- ACE_CString ior;
- ACE_CString object_id (name);
+
+ // @@ There appears to be long standing (i.e. back when the map was
+ // an ACE_Hash_Map_Manager) race condition here since the map
+ // access is not synchronized.
// Is the service name in the IOR Table.
- if (this->orb_core_->init_ref_map ()->find (object_id, ior) == 0)
- return this->string_to_object (ior.c_str ()
+ TAO_ORB_Core::InitRefMap::iterator ior =
+ this->orb_core_->init_ref_map ()->find (ACE_CString (name));
+
+ if (ior != this->orb_core_->init_ref_map ()->end ())
+ return this->string_to_object ((*ior).second.c_str ()
ACE_ENV_ARG_PARAMETER);
// Look for an environment variable called "<name>IOR".
@@ -1573,7 +1578,7 @@ CORBA::ORB_init (int &argc,
// The ORB table increases the reference count on the ORB Core
// so do not release it here. Allow the TAO_ORB_Core_Auto_Ptr
- // do decrease the reference on the ORB Core when it goes out of
+ // to decrease the reference on the ORB Core when it goes out of
// scope.
oc.reset (tmp);
}
diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp
index 8e6f09b5792..2323c81cdd4 100644
--- a/TAO/tao/ORB_Core.cpp
+++ b/TAO/tao/ORB_Core.cpp
@@ -610,10 +610,12 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL)
ACE_CString object_id (ACE_TEXT_ALWAYS_CHAR(current_arg),
pos - current_arg);
ACE_CString IOR (ACE_TEXT_ALWAYS_CHAR(pos + 1));
- if (this->init_ref_map_.bind (object_id, IOR) != 0)
+ if (!this->init_ref_map_.insert (
+ std::make_pair (InitRefMap::key_type (object_id),
+ InitRefMap::data_type (IOR))).second)
{
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Cannot store ORBInitRef ")
+ ACE_TEXT ("Duplicate -ORBInitRef ")
ACE_TEXT ("argument '%s'\n"),
current_arg));
ACE_THROW_RETURN (CORBA::INTERNAL (
@@ -1532,12 +1534,6 @@ TAO_ORB_Core::set_protocols_hooks (const char *protocols_hooks_name)
protocols_hooks_name;
}
-TAO_Protocols_Hooks *
-TAO_ORB_Core::get_protocols_hooks (void)
-{
- return this->protocols_hooks_;
-}
-
int
TAO_ORB_Core::bidirectional_giop_init (ACE_ENV_SINGLE_ARG_DECL)
{
@@ -1805,10 +1801,10 @@ TAO_ORB_Core::create_object (TAO_Stub *stub)
CORBA::Object::_nil ());
TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
- const TAO::ORB_Table::Iterator end = table->end ();
- for (TAO::ORB_Table::Iterator i = table->begin (); i != end; ++i)
+ TAO::ORB_Table::iterator const end = table->end ();
+ for (TAO::ORB_Table::iterator i = table->begin (); i != end; ++i)
{
- TAO_ORB_Core *other_core = (*i).int_id_;
+ TAO_ORB_Core * const other_core = (*i).second.core ();
if (this->is_collocation_enabled (other_core,
mprofile))
@@ -1848,10 +1844,10 @@ TAO_ORB_Core::initialize_object (TAO_Stub *stub,
0));
TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
- TAO::ORB_Table::Iterator const end = table->end ();
- for (TAO::ORB_Table::Iterator i = table->begin (); i != end; ++i)
+ TAO::ORB_Table::iterator const end = table->end ();
+ for (TAO::ORB_Table::iterator i = table->begin (); i != end; ++i)
{
- TAO_ORB_Core * const other_core = (*i).int_id_;
+ TAO_ORB_Core * const other_core = (*i).second.core ();
if (this->is_collocation_enabled (other_core,
mprofile))
@@ -2450,7 +2446,7 @@ TAO_ORB_Core::list_initial_references (ACE_ENV_SINGLE_ARG_DECL)
const size_t total_size =
initial_services_size
- + this->init_ref_map_.current_size ()
+ + this->init_ref_map_.size ()
+ this->object_ref_table_.current_size ();
CORBA::ORB::ObjectIdList *tmp = 0;
@@ -2476,21 +2472,21 @@ TAO_ORB_Core::list_initial_references (ACE_ENV_SINGLE_ARG_DECL)
// References registered via
// ORBInitInfo::register_initial_reference().
- TAO_Object_Ref_Table::Iterator obj_ref_end =
+ TAO_Object_Ref_Table::iterator const obj_ref_end =
this->object_ref_table_.end ();
- for (TAO_Object_Ref_Table::Iterator i = this->object_ref_table_.begin ();
+ for (TAO_Object_Ref_Table::iterator i = this->object_ref_table_.begin ();
i != obj_ref_end;
++i, ++index)
- list[index] = CORBA::string_dup ((*i).ext_id_);
+ list[index] = CORBA::string_dup ((*i).first.in ());
// References registered via INS.
- const InitRefMap::iterator end = this->init_ref_map_.end ();
+ InitRefMap::iterator const end = this->init_ref_map_.end ();
for (InitRefMap::iterator j = this-> init_ref_map_.begin ();
j != end;
++j, ++index)
- list[index] = (*j).ext_id_.c_str ();
+ list[index] = (*j).second.c_str ();
return list._retn ();
}
@@ -3105,33 +3101,6 @@ TAO_ORB_Core::collocation_strategy (CORBA::Object_ptr object
return TAO::TAO_CS_REMOTE_STRATEGY;
}
-TAO_ORB_Core::InitRefMap *
-TAO_ORB_Core::init_ref_map ()
-{
- return &this->init_ref_map_;
-}
-
-void
-TAO_ORB_Core::set_default (const char * orb_id)
-{
- TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
- table->set_default (orb_id);
-}
-
-void
-TAO_ORB_Core::not_default (const char * orb_id)
-{
- TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
- table->not_default (orb_id);
-}
-
-/// Return the valuetype adapter
-TAO_Valuetype_Adapter *&
-TAO_ORB_Core::valuetype_adapter (void)
-{
- return this->valuetype_adapter_;
-}
-
// ****************************************************************
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
@@ -3147,12 +3116,6 @@ template class ACE_Guard<ACE_Reverse_Lock<TAO_SYNCH_MUTEX> >;
template class ACE_TSS<TAO_ORB_Core_TSS_Resources>;
-template class ACE_Hash_Map_Manager_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Entry<ACE_CString, ACE_CString>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-
template class ACE_Array_Base<void *>;
template class ACE_Dynamic_Service<TAO_Server_Strategy_Factory>;
@@ -3171,12 +3134,6 @@ template class ACE_Dynamic_Service<TAO_Client_Strategy_Factory>;
#pragma instantiate ACE_TSS<TAO_ORB_Core_TSS_Resources>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, ACE_CString>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-
#pragma instantiate ACE_Array_Base<void *>
#pragma instantiate ACE_Dynamic_Service<TAO_Server_Strategy_Factory>
diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h
index b20217795fc..9eac2017285 100644
--- a/TAO/tao/ORB_Core.h
+++ b/TAO/tao/ORB_Core.h
@@ -36,6 +36,7 @@
#include "tao/Invocation_Utils.h"
#include "tao/Adapter_Registry.h"
#include "tao/ORB_Core_TSS_Resources.h"
+#include "ace/Array_Map.h"
#if TAO_HAS_INTERCEPTORS == 1
@@ -911,23 +912,17 @@ public:
/// Get Code Set Manager
TAO_Codeset_Manager *codeset_manager (void);
- typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
- ACE_CString,
- ACE_Hash<ACE_CString>,
- ACE_Equal_To<ACE_CString>,
- ACE_Null_Mutex>
- InitRefMap;
+ typedef ACE_Array_Map<ACE_CString, ACE_CString> InitRefMap;
/// Return a pointer to the -ORBInitRef map.
InitRefMap * init_ref_map (void);
/// Set the ORB related to the orb_id as the default ORB and not the
/// ORB that is first binded in the ORB Table
- void set_default (const char *orb_id);
+ void set_default (const char * orb_id);
- /// Set to choose to be not a default ORB when there are more than
- /// one ORB.
- void not_default (const char *orb_id);
+ /// Choose to be not a default ORB when there is more than one ORB.
+ void not_default (const char * orb_id);
protected:
diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i
index 768ddf88b0b..f02c798655c 100644
--- a/TAO/tao/ORB_Core.i
+++ b/TAO/tao/ORB_Core.i
@@ -3,6 +3,8 @@
// $Id$
#include "tao/ORB_Core_TSS_Resources.h"
+#include "tao/ORB_Table.h"
+
ACE_INLINE CORBA::ULong
TAO_ORB_Core::_incr_refcnt (void)
@@ -64,6 +66,12 @@ TAO_ORB_Core::flushing_strategy (void)
return this->flushing_strategy_;
}
+ACE_INLINE TAO_Protocols_Hooks *
+TAO_ORB_Core::get_protocols_hooks (void)
+{
+ return this->protocols_hooks_;
+}
+
ACE_INLINE CORBA::Boolean
TAO_ORB_Core::service_profile_selection (TAO_MProfile &mprofile,
TAO_Profile *&profile)
@@ -185,6 +193,33 @@ TAO_ORB_Core::request_dispatcher (void)
return this->request_dispatcher_;
}
+ACE_INLINE TAO_ORB_Core::InitRefMap *
+TAO_ORB_Core::init_ref_map (void)
+{
+ return &this->init_ref_map_;
+}
+
+ACE_INLINE void
+TAO_ORB_Core::set_default (const char * orb_id)
+{
+ TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
+ table->set_default (orb_id);
+}
+
+ACE_INLINE void
+TAO_ORB_Core::not_default (const char * orb_id)
+{
+ TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
+ table->not_default (orb_id);
+}
+
+/// Return the valuetype adapter
+ACE_INLINE TAO_Valuetype_Adapter *&
+TAO_ORB_Core::valuetype_adapter (void)
+{
+ return this->valuetype_adapter_;
+}
+
ACE_INLINE void
TAO_ORB_Core::optimize_collocation_objects (CORBA::Boolean opt)
{
diff --git a/TAO/tao/ORB_Core_Auto_Ptr.h b/TAO/tao/ORB_Core_Auto_Ptr.h
index 458f8152af5..52aa611502b 100644
--- a/TAO/tao/ORB_Core_Auto_Ptr.h
+++ b/TAO/tao/ORB_Core_Auto_Ptr.h
@@ -26,12 +26,8 @@ class TAO_ORB_Core;
* @brief Define a TAO_ORB_Core auto_ptr class.
*
* This class is used as an aid to make ORB initialization exception
- * safe. It ensures that the ORB core is deallocated if an exception
- * is thrown.
- *
- * @todo
- * TAO_ORB_Core_Auto_Ptr should be renamed to TAO_ORB_Core_var
- * since the ORB Core is reference counted.
+ * safe. It ensures that the ORB core is deallocated through its
+ * reference counting mechanism if an exception is thrown.
*/
class TAO_Export TAO_ORB_Core_Auto_Ptr
{
@@ -39,7 +35,7 @@ public:
/// Initialization and termination methods
//@{
- /* explicit */ TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core *p = 0);
+ explicit TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core *p = 0);
TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core_Auto_Ptr &ap);
TAO_ORB_Core_Auto_Ptr &operator= (TAO_ORB_Core_Auto_Ptr &rhs);
~TAO_ORB_Core_Auto_Ptr (void);
diff --git a/TAO/tao/ORB_Table.cpp b/TAO/tao/ORB_Table.cpp
index a678a26da19..7459859c667 100644
--- a/TAO/tao/ORB_Table.cpp
+++ b/TAO/tao/ORB_Table.cpp
@@ -6,6 +6,7 @@
# include "ORB_Table.inl"
#endif /* ! __ACE_INLINE__ */
+#include "ace/SString.h"
#include "ace/OS_NS_string.h"
@@ -26,40 +27,6 @@ TAO::ORB_Table::ORB_Table (void)
{
}
-TAO::ORB_Table::~ORB_Table (void)
-{
- Iterator const end (this->end ());
- for (Iterator i (this->begin ()); i != end; ++i)
- {
- // Deallocate the ORBid.
- CORBA::string_free (const_cast<char *> ((*i).ext_id_));
-
- // Destroy the ORB_Core
- (void) (*i).int_id_->_decr_refcnt ();
- }
-
- this->table_.close ();
-}
-
-TAO::ORB_Table::Iterator
-TAO::ORB_Table::begin (void)
-{
- return this->table_.begin ();
-}
-
-TAO::ORB_Table::Iterator
-TAO::ORB_Table::end (void)
-{
- return this->table_.end ();
-}
-
-TAO_ORB_Core* const *
-TAO::ORB_Table::get_orbs (size_t& num_orbs)
-{
- num_orbs = this->num_orbs_;
- return this->orbs_;
-}
-
int
TAO::ORB_Table::bind (char const * orb_id,
TAO_ORB_Core * orb_core)
@@ -72,29 +39,26 @@ TAO::ORB_Table::bind (char const * orb_id,
return -1;
};
- CORBA::String_var id (CORBA::string_dup (orb_id));
-
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
guard,
this->lock_,
-1);
- int const result = this->table_.bind (id.in (), orb_core);
+ value_type const value =
+ std::make_pair (key_type (orb_id), data_type (orb_core));
+
+ std::pair<iterator, bool> result = this->table_.insert (value);
- if (result == 0)
+ if (result.second)
{
- // Make sure the ORB table owns the ORB Core by increasing the
- // reference count on it.
- (void) orb_core->_incr_refcnt ();
-
- // This is not the first ORB .. but if the current default
- // ORB decided not to be the default and there is more than
- // one orb then set this orb to be the default ORB.
- if ((this->first_orb_ != 0)
- && (this->first_orb_not_default_))
+ // This is not the first ORB, but if the current default ORB
+ // decided not to be the default and there is more than one ORB
+ // then set this ORB to be the default.
+ if (this->first_orb_ != 0
+ && this->first_orb_not_default_)
{
this->first_orb_ = orb_core;
- this->first_orb_not_default_ = 0;
+ this->first_orb_not_default_ = false;
}
// Set the "first_orb_" member for the first given ORB Core
@@ -103,88 +67,77 @@ TAO::ORB_Table::bind (char const * orb_id,
{
this->first_orb_ = orb_core;
}
-
- (void) id._retn (); // ORB Table now owns the id.
}
- return result;
+ return (result.second ? 0 : 1);
}
TAO_ORB_Core *
TAO::ORB_Table::find (char const * orb_id)
{
- TAO_ORB_Core * found = 0;
+ TAO_ORB_Core * orb_core = 0;
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
guard,
this->lock_,
0);
- this->table_.find (orb_id, found);
+ iterator const i = this->table_.find (Table::key_type (orb_id));
// Maintain ownership of the ORB_Core.
- if (found != 0)
- (void) found->_incr_refcnt ();
+ if (i != this->end ())
+ {
+ orb_core = (*i).second.core ();
+ (void) orb_core->_incr_refcnt ();
+ }
- return found;
+ return orb_core;
}
int
TAO::ORB_Table::unbind (const char *orb_id)
{
- Table::ENTRY * entry = 0;
-
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
guard,
this->lock_,
-1);
- int result = this->table_.find (orb_id, entry);
+ iterator const result = this->table_.find (key_type (orb_id));
- if (result == 0)
+ if (result != this->end ())
{
- // Deallocate the external ID and obtain the ORB core pointer
- // before unbinding the entry since the entry is deallocated
- // during the call to unbind().
- CORBA::string_free (const_cast<char *> (entry->ext_id_));
- TAO_ORB_Core * const orb_core = entry->int_id_;
-
- result = this->table_.unbind (entry);
+ TAO::ORB_Core_Ref_Counter oc ((*result).second);
- if (result != 0)
- {
- return result;
- }
+ if (this->table_.erase (key_type (orb_id)) == 0)
+ return -1;
- if (orb_core == this->first_orb_)
+ if (oc.core () == this->first_orb_)
{
- Iterator const begin (this->begin ());
- Iterator const end (this->end ());
-
- if (begin != end)
+ if (!this->table_.empty ())
{
- this->first_orb_ = (*begin).int_id_;
+ this->first_orb_ = (*this->begin ()).second.core ();
}
else
{
this->first_orb_ = 0;
}
}
-
- orb_core->_decr_refcnt ();
}
- return result;
+ return 0;
}
void
-TAO::ORB_Table::set_default (char const * orb_id)
+TAO::ORB_Table::set_default (char const * orb_id)
{
ACE_GUARD (TAO_SYNCH_MUTEX,
guard,
this->lock_);
- this->table_.find (orb_id, this->first_orb_);
+ iterator const i = this->table_.find (key_type (orb_id));
+
+ if (i != this->end ())
+ this->first_orb_ = (*i).second.core ();
}
void
@@ -219,13 +172,6 @@ TAO::ORB_Table::not_default (char const * orb_id)
}
}
-/// Accessor to the underlying table_
-TAO::ORB_Table::Table *
-TAO::ORB_Table::table (void)
-{
- return &this->table_;
-}
-
TAO::ORB_Table *
TAO::ORB_Table::instance (void)
{
@@ -237,21 +183,9 @@ TAO::ORB_Table::instance (void)
template class TAO_Singleton<TAO::ORB_Table,TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Entry<const char *, TAO_ORB_Core *>;
-template class ACE_Hash_Map_Manager_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Base_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
-
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate TAO_Singleton<TAO::ORB_Table,TAO_SYNCH_MUTEX>
-
-#pragma instantiate ACE_Hash_Map_Entry<const char *, TAO_ORB_Core *>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+# pragma instantiate TAO_Singleton<TAO::ORB_Table,TAO_SYNCH_MUTEX>
#elif defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
diff --git a/TAO/tao/ORB_Table.h b/TAO/tao/ORB_Table.h
index 30eca509c82..46c0f96cac6 100644
--- a/TAO/tao/ORB_Table.h
+++ b/TAO/tao/ORB_Table.h
@@ -6,8 +6,8 @@
*
* $Id$
*
- * @author Ossama Othman <ossama@uci.edu>
- * @author Carlos O'Ryan <coryan@uci.edu>
+ * @author Ossama Othman
+ * @author Carlos O'Ryan
*/
//=============================================================================
@@ -24,10 +24,10 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/orbconf.h"
+#include "tao/CORBA_String.h"
-#include "ace/Hash_Map_Manager_T.h"
+#include "ace/Array_Map.h"
#include "ace/Thread_Mutex.h"
-#include "ace/Null_Mutex.h"
// Forward declarations.
@@ -35,6 +35,8 @@ class TAO_ORB_Core;
namespace TAO
{
+ class ORB_Core_Ref_Counter;
+
/**
* @class ORB_Table
*
@@ -67,18 +69,21 @@ namespace TAO
*/
ORB_Table (void);
- /// destructor
- ~ORB_Table (void);
-
- typedef ACE_Hash_Map_Manager_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> Table;
- typedef Table::iterator Iterator;
+ typedef ACE_Array_Map<CORBA::String_var, ORB_Core_Ref_Counter> Table;
+ typedef Table::key_type key_type;
+ typedef Table::data_type data_type;
+ typedef Table::value_type value_type;
+ typedef Table::size_type size_type;
+ typedef Table::iterator iterator;
/// The canonical ACE_Map methods.
//@{
- Iterator begin (void);
- Iterator end (void);
+ iterator begin (void);
+ iterator end (void);
int bind (const char *orb_id, TAO_ORB_Core *orb_core);
+ /// Return @c TAO_ORB_Core corresponding to ORB with given @a
+ /// orb_id.
/**
* @note The caller must decrease the reference count on the
* returned ORB_Core, i.e. the callers "owns" it.
@@ -114,7 +119,14 @@ namespace TAO
ORB_Table (const ORB_Table &);
void operator= (const ORB_Table &);
+ /// Return @c TAO_ORB_Core corresponding to ORB with given @a
+ /// orb_id. (underlying unlocked implementation).
+ TAO_ORB_Core * find_i (char const * orb_id);
+
/// Update our list of orbs
+ /**
+ * @todo Where the implementation for ORB_Table::update_orbs?
+ */
void update_orbs (void);
private:
@@ -133,12 +145,56 @@ namespace TAO
TAO_ORB_Core * first_orb_;
/// List of orbs for get_orbs call
+ /**
+ * @todo ORB_Table::orbs_ appears to be unused. Remove it?
+ */
TAO_ORB_Core ** orbs_;
/// Number of ORBs in the table.
size_t num_orbs_;
};
+
+ // -----------------------------------------------
+
+ /**
+ * @class ORB_Table_Ref_Counter
+ *
+ * @brief Class contained by ORB_Table's Unbounded_Set.
+ *
+ * Class contained by ORB_Table's Unbounded_Set.
+ */
+ class ORB_Core_Ref_Counter
+ {
+ public:
+
+ /// Constructor.
+ ORB_Core_Ref_Counter (void);
+
+ /// Constructor.
+ ORB_Core_Ref_Counter (TAO_ORB_Core * core);
+
+ /// Destructor.
+ ~ORB_Core_Ref_Counter (void);
+
+ /// Copy constructor.
+ ORB_Core_Ref_Counter (ORB_Core_Ref_Counter const & rhs);
+
+ /// Assignment operator.
+ void operator= (ORB_Core_Ref_Counter const & rhs);
+
+ /// Equality operator.
+ bool operator== (ORB_Core_Ref_Counter const & rhs);
+
+ /// ORB_Core pointer accessor.
+ TAO_ORB_Core * core (void) const { return this->core_; }
+
+ private:
+
+ TAO_ORB_Core * core_;
+
+ };
+
}
#if defined (__ACE_INLINE__)
diff --git a/TAO/tao/ORB_Table.inl b/TAO/tao/ORB_Table.inl
index f8f1f2d9937..fdde8c5a4d7 100644
--- a/TAO/tao/ORB_Table.inl
+++ b/TAO/tao/ORB_Table.inl
@@ -2,8 +2,90 @@
//
// $Id$
+#include "tao/ORB_Core.h"
+
+
ACE_INLINE TAO_ORB_Core *
TAO::ORB_Table::first_orb (void)
{
return this->first_orb_;
}
+
+ACE_INLINE TAO::ORB_Table::iterator
+TAO::ORB_Table::begin (void)
+{
+ return this->table_.begin ();
+}
+
+ACE_INLINE TAO::ORB_Table::iterator
+TAO::ORB_Table::end (void)
+{
+ return this->table_.end ();
+}
+
+ACE_INLINE TAO_ORB_Core* const *
+TAO::ORB_Table::get_orbs (size_t& num_orbs)
+{
+ num_orbs = this->num_orbs_;
+ return this->orbs_;
+}
+
+/// Accessor to the underlying table_
+ACE_INLINE TAO::ORB_Table::Table *
+TAO::ORB_Table::table (void)
+{
+ return &this->table_;
+}
+
+// ****************************************************************
+
+ACE_INLINE
+TAO::ORB_Core_Ref_Counter::ORB_Core_Ref_Counter (void)
+ : core_ (0)
+{
+}
+
+ACE_INLINE
+TAO::ORB_Core_Ref_Counter::ORB_Core_Ref_Counter (TAO_ORB_Core * core)
+ : core_ (core)
+{
+ ACE_ASSERT (core != 0);
+
+ // Claim ownership.
+ (void) this->core_->_incr_refcnt ();
+}
+
+ACE_INLINE
+TAO::ORB_Core_Ref_Counter::~ORB_Core_Ref_Counter (void)
+{
+ if (this->core_)
+ (void) this->core_->_decr_refcnt (); // Should never throw.
+}
+
+ACE_INLINE
+TAO::ORB_Core_Ref_Counter::ORB_Core_Ref_Counter (
+ TAO::ORB_Core_Ref_Counter const & rhs)
+ : core_ (rhs.core_)
+{
+ ACE_ASSERT (rhs.core_ != 0);
+
+ (void) this->core_->_incr_refcnt ();
+}
+
+ACE_INLINE
+void
+TAO::ORB_Core_Ref_Counter::operator= (TAO::ORB_Core_Ref_Counter const & rhs)
+{
+ // Strongly exception safe. May not be strictly necessary, but
+ // let's do things the right way, regardless.
+ TAO::ORB_Core_Ref_Counter tmp (rhs);
+ std::swap (this->core_, tmp.core_);
+}
+
+ACE_INLINE
+bool
+TAO::ORB_Core_Ref_Counter::operator== (TAO::ORB_Core_Ref_Counter const & rhs)
+{
+ return (ACE_OS::strcmp (this->core_->orbid (),
+ rhs.core_->orbid ()) == 0);
+}
diff --git a/TAO/tao/Object_Ref_Table.cpp b/TAO/tao/Object_Ref_Table.cpp
index af00050eba3..169861cd4b7 100644
--- a/TAO/tao/Object_Ref_Table.cpp
+++ b/TAO/tao/Object_Ref_Table.cpp
@@ -1,11 +1,13 @@
+// $Id$
+
#include "Object_Ref_Table.h"
#include "ORB.h"
#include "Environment.h"
#include "debug.h"
#include "ORB_Constants.h"
#include "SystemException.h"
-#include "Object.h"
#include "ace/OS_NS_string.h"
+#include "ace/Log_Msg.h"
ACE_RCSID (tao,
@@ -13,107 +15,12 @@ ACE_RCSID (tao,
"$Id$")
-// ****************************************************************
-
-TAO_Object_Ref_Table::TAO_Object_Ref_Table (void)
- : table_ (TAO_DEFAULT_OBJECT_REF_TABLE_SIZE)
-{
-}
-
-TAO_Object_Ref_Table::~TAO_Object_Ref_Table (void)
-{
- // Must explicitly call destroy() in the destructor since not all
- // applications will invoke ORB::shutdown() or ORB::destroy().
- this->destroy ();
-}
-
-void
-TAO_Object_Ref_Table::register_initial_reference (
- const char *id,
- CORBA::Object_ptr obj
- ACE_ENV_ARG_DECL)
-{
- if (id == 0 || ACE_OS::strlen (id) == 0)
- {
- ACE_THROW (CORBA::ORB::InvalidName ());
- }
- else if (CORBA::is_nil (obj))
- {
- ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 27,
- CORBA::COMPLETED_NO));
- }
+#ifndef __ACE_INLINE__
+# include "tao/Object_Ref_Table.inl"
+#endif /* __ACE_INLINE__ */
- int result = this->bind (id, obj);
- if (result == 1)
- {
- if (TAO_debug_level > 1)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Object_Ref_Table::register_initial_reference:")
- ACE_TEXT (" Could not register duplicate object <%s> ")
- ACE_TEXT ("with the ORB\n"),
- ACE_TEXT_CHAR_TO_TCHAR (id)));
- }
-
- ACE_THROW (CORBA::ORB::InvalidName ());
- }
-
- if (result == -1)
- {
- if (TAO_debug_level > 1)
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Object_Ref_Table::register_initial_reference:")
- ACE_TEXT (" Could not register object <%s> with ")
- ACE_TEXT ("the ORB\n"),
- ACE_TEXT_CHAR_TO_TCHAR (id)));
-
- ACE_THROW (CORBA::INTERNAL ());
- }
-}
-
-CORBA::Object_ptr
-TAO_Object_Ref_Table::resolve_initial_references (
- const char *id
- ACE_ENV_ARG_DECL_NOT_USED)
-{
- return this->find (id); // Returns a duplicate.
-}
-
-void
-TAO_Object_Ref_Table::destroy (void)
-{
- for (Iterator i = this->begin ();
- i != this->end ();
- ++i)
- {
- // Deallocate the id.
- CORBA::string_free (const_cast<char *> ((*i).ext_id_));
-
- // Release the Object.
- CORBA::release ((*i).int_id_);
- }
-
- this->table_.unbind_all ();
-}
-
-TAO_Object_Ref_Table::Iterator
-TAO_Object_Ref_Table::begin (void)
-{
- return this->table_.begin ();
-}
-
-TAO_Object_Ref_Table::Iterator
-TAO_Object_Ref_Table::end (void)
-{
- return this->table_.end ();
-}
-
-size_t
-TAO_Object_Ref_Table::current_size (void) const
-{
- return this->table_.current_size ();
-}
+// ****************************************************************
int
TAO_Object_Ref_Table::bind (const char *id,
@@ -121,79 +28,54 @@ TAO_Object_Ref_Table::bind (const char *id,
{
// Make sure that the supplied Object reference is valid,
// i.e. not nil.
- if (id == 0 || CORBA::is_nil (obj))
+ if (id == 0
+ || ACE_OS::strlen (id) == 0
+ || CORBA::is_nil (obj))
{
errno = EINVAL;
return -1;
};
- CORBA::String_var name = CORBA::string_dup (id);
- CORBA::Object_var object = CORBA::Object::_duplicate (obj);
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_,
+ -1);
- int result = this->table_.bind (name.in (),
- object.in ());
+ std::pair<iterator, bool> const result =
+ this->table_.insert (std::make_pair (CORBA::String_var (id),
+ CORBA::Object_var (obj)));
- if (result == 0)
+ if (!result.second)
{
- // Transfer ownership to the Object Table.
- (void) name._retn ();
- (void) object._retn ();
+ if (TAO_debug_level > 1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Object_Ref_Table::")
+ ACE_TEXT ("bind:")
+ ACE_TEXT (" Could not register duplicate object <%s> ")
+ ACE_TEXT ("with the ORB\n"),
+ ACE_TEXT_CHAR_TO_TCHAR (id)));
+ }
+
+ return -1;
}
- return result;
+ return 0;
}
CORBA::Object_ptr
TAO_Object_Ref_Table::find (const char *id)
{
- CORBA::Object_ptr found = CORBA::Object::_nil ();
-
- this->table_.find (id, found);
-
- return CORBA::Object::_duplicate (found);
-}
-
-int
-TAO_Object_Ref_Table::unbind (const char *id)
-{
- Table::ENTRY *entry = 0;
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_,
+ CORBA::Object::_nil ());
- int result = this->table_.find (id, entry);
-
- if (result == 0)
- {
- // Deallocate the external ID and obtain the ORB core pointer
- // before unbinding the entry since the entry is deallocated
- // during the call to unbind().
- CORBA::string_free (const_cast<char *> (entry->ext_id_));
- CORBA::Object_ptr obj = entry->int_id_;
+ iterator const found =
+ this->table_.find (CORBA::String_var (id));
- result = this->table_.unbind (entry);
+ if (found == this->table_.end ())
+ return CORBA::Object::_nil ();
- if (result != 0)
- return result;
-
- CORBA::release (obj);
- }
-
- return result;
+ return CORBA::Object::_duplicate ((*found).second.in ());
}
-
-
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-
-template class ACE_Hash_Map_Entry<const char *, CORBA::Object_ptr>;
-template class ACE_Hash_Map_Manager_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Base_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-
-#pragma instantiate ACE_Hash_Map_Entry<const char *, CORBA::Object_ptr>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-
-#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/tao/Object_Ref_Table.h b/TAO/tao/Object_Ref_Table.h
index 0d94eff9c19..c2e7e2b2329 100644
--- a/TAO/tao/Object_Ref_Table.h
+++ b/TAO/tao/Object_Ref_Table.h
@@ -21,17 +21,15 @@
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
-#include "ace/Thread_Mutex.h"
-#include "ace/Hash_Map_Manager_T.h"
-
+#include "tao/CORBA_String.h"
+#include "tao/Object.h"
#include "tao/TAO_Export.h"
#include "tao/orbconf.h"
+#include "ace/Array_Map.h"
+
namespace CORBA
{
- class Object;
- typedef Object *Object_ptr;
-
class Environment;
}
@@ -53,25 +51,17 @@ namespace CORBA
* is needed. For example, "corbaname" may return different results
* on each use.
*/
-class TAO_Export TAO_Object_Ref_Table
+class TAO_Object_Ref_Table
{
public:
- typedef ACE_Hash_Map_Manager_Ex<const char *,
- CORBA::Object_ptr,
- ACE_Hash<const char *>,
- ACE_Equal_To<const char *>,
- TAO_SYNCH_MUTEX>
- Table;
+ typedef ACE_Array_Map<CORBA::String_var, CORBA::Object_var> Table;
- typedef Table::iterator Iterator;
+ typedef Table::iterator iterator;
/// Constructor
TAO_Object_Ref_Table (void);
- /// Destructor
- ~TAO_Object_Ref_Table (void);
-
/// Register an object reference with the table, and map the given
/// ID to it.
void register_initial_reference (const char * id,
@@ -91,8 +81,8 @@ public:
* @name Forward Iterators
*/
//@{
- Iterator begin (void);
- Iterator end (void);
+ iterator begin (void);
+ iterator end (void);
//@}
/// Return the current size of the underlying table.
@@ -120,8 +110,16 @@ private:
/// The implementation.
Table table_;
+ /// Table synchronization lock.
+ TAO_SYNCH_MUTEX lock_;
+
};
+
+#ifdef __ACE_INLINE__
+# include "tao/Object_Ref_Table.inl"
+#endif /* __ACE_INLINE__ */
+
#include /**/ "ace/post.h"
#endif /* TAO_OBJECT_REF_TABLE_H */
diff --git a/TAO/tao/Object_Ref_Table.inl b/TAO/tao/Object_Ref_Table.inl
new file mode 100644
index 00000000000..e84bfc38a3b
--- /dev/null
+++ b/TAO/tao/Object_Ref_Table.inl
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+//
+// $Id$
+
+ACE_INLINE
+TAO_Object_Ref_Table::TAO_Object_Ref_Table (void)
+ : table_ (TAO_DEFAULT_OBJECT_REF_TABLE_SIZE)
+ , lock_ ()
+{
+}
+
+ACE_INLINE void
+TAO_Object_Ref_Table::register_initial_reference (
+ const char *id,
+ CORBA::Object_ptr obj
+ ACE_ENV_ARG_DECL)
+{
+ if (this->bind (id, obj) != 0)
+ {
+ ACE_THROW (CORBA::ORB::InvalidName ());
+ }
+}
+
+ACE_INLINE CORBA::Object_ptr
+TAO_Object_Ref_Table::resolve_initial_references (
+ const char * id
+ ACE_ENV_ARG_DECL_NOT_USED)
+{
+ return this->find (id); // Returns a duplicate.
+}
+
+ACE_INLINE void
+TAO_Object_Ref_Table::destroy (void)
+{
+ Table tmp;
+
+ ACE_GUARD (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_);
+
+ this->table_.swap (tmp); // Force release of memory held by our table.
+}
+
+ACE_INLINE TAO_Object_Ref_Table::iterator
+TAO_Object_Ref_Table::begin (void)
+{
+ return this->table_.begin ();
+}
+
+ACE_INLINE TAO_Object_Ref_Table::iterator
+TAO_Object_Ref_Table::end (void)
+{
+ return this->table_.end ();
+}
+
+ACE_INLINE size_t
+TAO_Object_Ref_Table::current_size (void) const
+{
+ return this->table_.size ();
+}
+
+ACE_INLINE int
+TAO_Object_Ref_Table::unbind (const char *id)
+{
+ return
+ (this->table_.erase (CORBA::String_var (id)) == 0 ? -1 : 0);
+}
diff --git a/TAO/tao/params.cpp b/TAO/tao/params.cpp
index c0add695c95..73a0e819b42 100644
--- a/TAO/tao/params.cpp
+++ b/TAO/tao/params.cpp
@@ -1,3 +1,4 @@
+// $Id$
#include "tao/params.h"
#include "tao/orbconf.h"
@@ -41,30 +42,26 @@ TAO_ORB_Parameters::TAO_ORB_Parameters (void)
}
}
-TAO_ORB_Parameters::~TAO_ORB_Parameters (void)
-{
-}
-
void
TAO_ORB_Parameters::get_endpoint_set (const ACE_CString &lane,
TAO_EndpointSet &endpoint_set)
{
- ACE_CString endpoints;
-
// Look for the lane in the endpoints map.
- int result =
- this->endpoints_map_.find (lane, endpoints);
+ endpoints_map_type::iterator const endpoints =
+ this->endpoints_map_.find (lane);
// If lane is not in the map, <endpoint_set> remains empty
- if (result != 0)
+ if (endpoints == this->endpoints_map_.end ())
return;
// At this point, the parsing should not fail since they have been
// parsed successfully before.
- result =
- this->parse_and_add_endpoints (endpoints,
+ int const result =
+ this->parse_and_add_endpoints ((*endpoints).second,
endpoint_set);
+
ACE_ASSERT (result == 0);
+ ACE_UNUSED_ARG (result);
}
int
@@ -83,27 +80,19 @@ TAO_ORB_Parameters::add_endpoints (const ACE_CString &lane,
return result;
// Look for the lane in the endpoints map.
- ACE_CString existing_endpoints;
- result =
- this->endpoints_map_.find (lane, existing_endpoints);
-
- // Create the resultant endpoints string.
- ACE_CString new_endpoints;
- if (result == 0)
- new_endpoints =
- existing_endpoints +
- ";" +
- additional_endpoints;
- else
- new_endpoints =
- additional_endpoints;
+ //
+ // Return reference to endpoints string corresponding to lane
+ // string. If none, a default constructed string is inserted into
+ // the map and returned.
+ ACE_CString & existing_endpoints = this->endpoints_map_[lane];
- result =
- this->endpoints_map_.rebind (lane,
- new_endpoints);
+ // Create the resulting endpoints string.
+ if (existing_endpoints.length () != 0)
+ {
+ existing_endpoints += ";";
+ }
- if (result == -1)
- return result;
+ existing_endpoints += additional_endpoints;
return 0;
}
@@ -119,12 +108,9 @@ TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
//
// A single endpoint, instead of several, can be added just as well.
- int status = 0;
- // Return code: 0 = success, -1 = failure
+ static char const endpoints_delimiter = ';';
- const char endpoints_delimiter = ';';
-
- size_t length = endpoints.length ();
+ size_t const length = endpoints.length ();
if (endpoints[0] == endpoints_delimiter ||
endpoints[length - 1] == endpoints_delimiter)
@@ -135,6 +121,9 @@ TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
// (e.g. ";uiop://foo;iiop://1.3@bar")
}
+ int status = 0;
+ // Return code: 0 = success, -1 = failure
+
if (length > 0)
{
int endpoints_count = 1;
@@ -143,7 +132,7 @@ TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
{
if (endpoints[j] == endpoints_delimiter)
{
- endpoints_count++;
+ ++endpoints_count;
}
}
@@ -162,13 +151,14 @@ TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
continue;
}
- ACE_CString endpt = endpoints.substring (begin, end - begin);
+ ACE_CString const endpt =
+ endpoints.substring (begin, end - begin);
// The substring call will work even if `end' is equal to
// ACE_CString::npos since that will just extract the substring
// from the offset `begin' to the end of the string.
// Check for a valid URL style endpoint set
- int check_offset = endpt.find ("://");
+ int const check_offset = endpt.find ("://");
if (check_offset > 0 &&
check_offset != endpt.npos)
diff --git a/TAO/tao/params.h b/TAO/tao/params.h
index f17c14c5228..274a1421a63 100644
--- a/TAO/tao/params.h
+++ b/TAO/tao/params.h
@@ -1,5 +1,4 @@
-/* -*- C++ -*- */
-
+// -*- C++ -*-
//=============================================================================
/**
@@ -16,7 +15,7 @@
#include /**/ "ace/pre.h"
#include "ace/Unbounded_Queue.h"
-#include "ace/Hash_Map_Manager.h"
+#include "ace/Array_Map.h"
#include "ace/Synch.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
@@ -38,12 +37,6 @@
// footprint by using this container.
typedef ACE_Unbounded_Queue<ACE_CString> TAO_EndpointSet;
typedef ACE_Unbounded_Queue_Const_Iterator<ACE_CString> TAO_EndpointSetIterator;
-typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
- ACE_CString,
- ACE_Hash<ACE_CString>,
- ACE_Equal_To<ACE_CString>,
- ACE_Null_Mutex>
- TAO_EndpointMap;
// -------------------------------------------------------------------
@@ -64,12 +57,12 @@ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
class TAO_Export TAO_ORB_Parameters
{
public:
+
+ typedef ACE_Array_Map<ACE_CString, ACE_CString> endpoints_map_type;
+
/// Constructor.
TAO_ORB_Parameters (void);
- /// Destructor.
- ~TAO_ORB_Parameters (void);
-
/// Specifies the endpoints on which this server is willing to
/// listen for requests.
int add_endpoints (const ACE_CString &lane,
@@ -205,7 +198,7 @@ private:
// TAO_EndpointSet preconnects_list_;
/// Map of endpoints this server is willing to accept requests on.
- TAO_EndpointMap endpoints_map_;
+ endpoints_map_type endpoints_map_;
/// Port numbers of the configured services.
CORBA::UShort service_port_[TAO_NO_OF_MCAST_SERVICES];
diff --git a/TAO/tao/params.i b/TAO/tao/params.i
index 4e87dc2e189..9e37a3a5eea 100644
--- a/TAO/tao/params.i
+++ b/TAO/tao/params.i
@@ -1,5 +1,7 @@
// -*- C++ -*-
+//
// $Id$
+
ACE_INLINE int
TAO_ORB_Parameters::sock_rcvbuf_size (void) const
{