Object_Ref_Table.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file     Object_Ref_Table.h
00006  *
00007  *  Object_Ref_Table.h,v 1.19 2006/03/31 21:44:24 schmidt Exp
00008  *
00009  *  @author Ossama Othman <ossama@uci.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_OBJECT_REF_TABLE_H
00015 #define TAO_OBJECT_REF_TABLE_H
00016 
00017 #include /**/ "ace/pre.h"
00018 #include "ace/CORBA_macros.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/CORBA_String.h"
00025 #include "tao/Object.h"
00026 #include "tao/TAO_Export.h"
00027 #include "tao/orbconf.h"
00028 
00029 #include "ace/Array_Map.h"
00030 
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 namespace CORBA
00034 {
00035   class Environment;
00036 }
00037 
00038 /**
00039  * @class TAO_Object_Ref_Table
00040  *
00041  * @brief Keep a table de-stringified object references registered
00042  * with the ORB.
00043  *
00044  * The class is necessary to allow local objects to be accessible via
00045  * the resolve_initial_references() mechanism.  Since local object
00046  * references cannot be stringified, they cannot be placed into the
00047  * initial reference map that maps object key/name to stringified
00048  * object reference.  Hence, another table is needed.
00049  *
00050  * @note
00051  * The stringified reference table is still needed since it is
00052  * sometimes necessary to delay de-stringification of an IOR until it
00053  * is needed.  For example, "corbaname" may return different results
00054  * on each use.
00055  */
00056 class TAO_Export TAO_Object_Ref_Table
00057 {
00058 public:
00059 
00060   typedef ACE_Array_Map<CORBA::String_var,
00061                         CORBA::Object_var,
00062                         TAO::String_Var_Equal_To> Table;
00063 
00064   typedef Table::iterator iterator;
00065 
00066   /// Constructor
00067   TAO_Object_Ref_Table (void);
00068 
00069   /**
00070    * Register an object reference with the table, and map the given
00071    * ID to it.
00072    * @retval 0 Success
00073    * @retval -1 Duplicate id if @c rebind is false
00074    */
00075   int register_initial_reference (const char * id,
00076                                   CORBA::Object_ptr obj,
00077                                   bool rebind = false);
00078 
00079   /// Return the object reference associated with the given ID.
00080   /// A duplicate is returned.
00081   CORBA::Object_ptr resolve_initial_reference (const char * id);
00082 
00083   /// Explicitly destroy the contents of the object reference table.
00084   void destroy (void);
00085 
00086   /**
00087    * @name Forward Iterators
00088    */
00089   //@{
00090   iterator begin (void);
00091   iterator end (void);
00092   //@}
00093 
00094   /// Return the current size of the underlying table.
00095   size_t current_size (void) const;
00096 
00097 private:
00098 
00099   /**
00100    * @name The canonical ACE_Map methods
00101    */
00102   //@{
00103   int bind (const char *orb_id, CORBA::Object_ptr obj);
00104   CORBA::Object_ptr find (const char *orb_id); // Returns a duplicate.
00105   int unbind (const char *orb_id);
00106   //@}
00107 
00108 private:
00109 
00110   // Disallow copying and assignment.
00111   TAO_Object_Ref_Table (const TAO_Object_Ref_Table &);
00112   void operator= (const TAO_Object_Ref_Table &);
00113 
00114 private:
00115 
00116   /// The implementation.
00117   Table table_;
00118 
00119   /// Table synchronization lock.
00120   TAO_SYNCH_MUTEX lock_;
00121 
00122 };
00123 
00124 TAO_END_VERSIONED_NAMESPACE_DECL
00125 
00126 #ifdef __ACE_INLINE__
00127 # include "tao/Object_Ref_Table.inl"
00128 #endif  /* __ACE_INLINE__ */
00129 
00130 #include /**/ "ace/post.h"
00131 
00132 #endif  /* TAO_OBJECT_REF_TABLE_H */

Generated on Thu Nov 9 11:54:16 2006 for TAO by doxygen 1.3.6