summaryrefslogtreecommitdiff
path: root/TAO/tao/Object_Ref_Table.cpp
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2005-07-05 10:13:48 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2005-07-05 10:13:48 +0000
commit02de212956ca93e250ab304515570f3f0d87bab0 (patch)
tree6de6d7b3e9ab1c1d4fb868c2b2ee431c3d874514 /TAO/tao/Object_Ref_Table.cpp
parent4cbabbf0a57651d90663c2303c213fe0b191d2b1 (diff)
downloadATCD-02de212956ca93e250ab304515570f3f0d87bab0.tar.gz
ChangeLogTag:Tue Jul 5 03:07:52 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/tao/Object_Ref_Table.cpp')
-rw-r--r--TAO/tao/Object_Ref_Table.cpp196
1 files changed, 39 insertions, 157 deletions
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 */