Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / Object_Ref_Table.h
blobfb7ca8039ae37d5b2346d29298800671f9c1a57b
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Object_Ref_Table.h
7 * @author Ossama Othman <ossama@uci.edu>
8 */
9 //=============================================================================
12 #ifndef TAO_OBJECT_REF_TABLE_H
13 #define TAO_OBJECT_REF_TABLE_H
15 #include /**/ "ace/pre.h"
17 #include "tao/orbconf.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "tao/CORBA_String.h"
24 #include "tao/Object.h"
25 #include /**/ "tao/TAO_Export.h"
27 #include "ace/Array_Map.h"
29 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
31 /**
32 * @class TAO_Object_Ref_Table
34 * @brief Keep a table de-stringified object references registered
35 * with the ORB.
37 * The class is necessary to allow local objects to be accessible via
38 * the resolve_initial_references() mechanism. Since local object
39 * references cannot be stringified, they cannot be placed into the
40 * initial reference map that maps object key/name to stringified
41 * object reference. Hence, another table is needed.
43 * @note
44 * The stringified reference table is still needed since it is
45 * sometimes necessary to delay de-stringification of an IOR until it
46 * is needed. For example, "corbaname" may return different results
47 * on each use.
49 class TAO_Export TAO_Object_Ref_Table
51 public:
52 typedef ACE_Array_Map<CORBA::String_var,
53 CORBA::Object_var,
54 TAO::String_Var_Equal_To> Table;
56 typedef Table::iterator iterator;
58 /// Constructor
59 TAO_Object_Ref_Table ();
61 /**
62 * Register an object reference with the table, and map the given
63 * ID to it.
64 * @retval 0 Success
65 * @retval -1 Duplicate id if @c rebind is false
67 int register_initial_reference (const char * id,
68 CORBA::Object_ptr obj,
69 bool rebind = false);
71 /**
72 * Unregister an object reference with the table
74 CORBA::Object_ptr unregister_initial_reference (const char * id);
76 /// Return the object reference associated with the given ID.
77 /// A duplicate is returned.
78 CORBA::Object_ptr resolve_initial_reference (const char * id);
80 /// Explicitly destroy the contents of the object reference table.
81 void destroy ();
83 /**
84 * @name Forward Iterators
86 //@{
87 iterator begin ();
88 iterator end ();
89 //@}
91 /// Return the current size of the underlying table.
92 size_t current_size () const;
94 private:
95 /**
96 * @name The canonical ACE_Map methods
98 //@{
99 int bind_i (const char *orb_id, CORBA::Object_ptr obj);
100 CORBA::Object_ptr find_i (const char *orb_id); // Returns a duplicate.
101 int unbind_i (const char *orb_id);
102 //@}
104 private:
105 TAO_Object_Ref_Table (const TAO_Object_Ref_Table &) = delete;
106 void operator= (const TAO_Object_Ref_Table &) = delete;
107 TAO_Object_Ref_Table (TAO_Object_Ref_Table &&) = delete;
108 void operator= (TAO_Object_Ref_Table &&) = delete;
110 private:
111 /// The implementation.
112 Table table_;
114 /// Table synchronization lock.
115 TAO_SYNCH_MUTEX lock_;
118 TAO_END_VERSIONED_NAMESPACE_DECL
120 #ifdef __ACE_INLINE__
121 # include "tao/Object_Ref_Table.inl"
122 #endif /* __ACE_INLINE__ */
124 #include /**/ "ace/post.h"
126 #endif /* TAO_OBJECT_REF_TABLE_H */