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