diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-07-05 10:13:48 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-07-05 10:13:48 +0000 |
commit | 01ec2af8ef79521b4279ee7689bd5816939c5b69 (patch) | |
tree | 6de6d7b3e9ab1c1d4fb868c2b2ee431c3d874514 /TAO/tao/ORB_Table.cpp | |
parent | 6d36e2d6459e580c42dcc026a10ce55e19b55398 (diff) | |
download | ATCD-01ec2af8ef79521b4279ee7689bd5816939c5b69.tar.gz |
ChangeLogTag:Tue Jul 5 03:07:52 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/tao/ORB_Table.cpp')
-rw-r--r-- | TAO/tao/ORB_Table.cpp | 138 |
1 files changed, 36 insertions, 102 deletions
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) |