00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Object_Ref_Table.h 00006 * 00007 * $Id: Object_Ref_Table.h 83527 2008-11-03 11:25:24Z 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 /** 00075 * Unregister an object reference with the table 00076 */ 00077 CORBA::Object_ptr unregister_initial_reference (const char * id); 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_i (const char *orb_id, CORBA::Object_ptr obj); 00104 CORBA::Object_ptr find_i (const char *orb_id); // Returns a duplicate. 00105 int unbind_i (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 */