summaryrefslogtreecommitdiff
path: root/TAO/tao/Object_Ref_Table.h
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
commit3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch)
tree197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tao/Object_Ref_Table.h
parent6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff)
downloadATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz
Repo restructuring
Diffstat (limited to 'TAO/tao/Object_Ref_Table.h')
-rw-r--r--TAO/tao/Object_Ref_Table.h132
1 files changed, 132 insertions, 0 deletions
diff --git a/TAO/tao/Object_Ref_Table.h b/TAO/tao/Object_Ref_Table.h
new file mode 100644
index 00000000000..ac4d6adcda8
--- /dev/null
+++ b/TAO/tao/Object_Ref_Table.h
@@ -0,0 +1,132 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Object_Ref_Table.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@uci.edu>
+ */
+//=============================================================================
+
+
+#ifndef TAO_OBJECT_REF_TABLE_H
+#define TAO_OBJECT_REF_TABLE_H
+
+#include /**/ "ace/pre.h"
+#include "ace/CORBA_macros.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/CORBA_String.h"
+#include "tao/Object.h"
+#include "tao/TAO_Export.h"
+#include "tao/orbconf.h"
+
+#include "ace/Array_Map.h"
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace CORBA
+{
+ class Environment;
+}
+
+/**
+ * @class TAO_Object_Ref_Table
+ *
+ * @brief Keep a table de-stringified object references registered
+ * with the ORB.
+ *
+ * The class is necessary to allow local objects to be accessible via
+ * the resolve_initial_references() mechanism. Since local object
+ * references cannot be stringified, they cannot be placed into the
+ * initial reference map that maps object key/name to stringified
+ * object reference. Hence, another table is needed.
+ *
+ * @note
+ * The stringified reference table is still needed since it is
+ * sometimes necessary to delay de-stringification of an IOR until it
+ * is needed. For example, "corbaname" may return different results
+ * on each use.
+ */
+class TAO_Export TAO_Object_Ref_Table
+{
+public:
+
+ typedef ACE_Array_Map<CORBA::String_var,
+ CORBA::Object_var,
+ TAO::String_Var_Equal_To> Table;
+
+ typedef Table::iterator iterator;
+
+ /// Constructor
+ TAO_Object_Ref_Table (void);
+
+ /**
+ * Register an object reference with the table, and map the given
+ * ID to it.
+ * @retval 0 Success
+ * @retval -1 Duplicate id if @c rebind is false
+ */
+ int register_initial_reference (const char * id,
+ CORBA::Object_ptr obj,
+ bool rebind = false);
+
+ /// Return the object reference associated with the given ID.
+ /// A duplicate is returned.
+ CORBA::Object_ptr resolve_initial_reference (const char * id);
+
+ /// Explicitly destroy the contents of the object reference table.
+ void destroy (void);
+
+ /**
+ * @name Forward Iterators
+ */
+ //@{
+ iterator begin (void);
+ iterator end (void);
+ //@}
+
+ /// Return the current size of the underlying table.
+ size_t current_size (void) const;
+
+private:
+
+ /**
+ * @name The canonical ACE_Map methods
+ */
+ //@{
+ int bind (const char *orb_id, CORBA::Object_ptr obj);
+ CORBA::Object_ptr find (const char *orb_id); // Returns a duplicate.
+ int unbind (const char *orb_id);
+ //@}
+
+private:
+
+ // Disallow copying and assignment.
+ TAO_Object_Ref_Table (const TAO_Object_Ref_Table &);
+ void operator= (const TAO_Object_Ref_Table &);
+
+private:
+
+ /// The implementation.
+ Table table_;
+
+ /// Table synchronization lock.
+ TAO_SYNCH_MUTEX lock_;
+
+};
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+#ifdef __ACE_INLINE__
+# include "tao/Object_Ref_Table.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_OBJECT_REF_TABLE_H */