Updated logging to include the class/method so that it is more obvious where these...
[ACE_TAO.git] / TAO / tao / ORB_Table.h
blob8841c8d34a3045051e4bf09cd036eceebf6eec69
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file ORB_Table.h
7 * @author Ossama Othman
8 * @author Carlos O'Ryan
9 */
10 //=============================================================================
13 #ifndef TAO_ORB_TABLE_H
14 #define TAO_ORB_TABLE_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "tao/TAO_Export.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "tao/orbconf.h"
25 #include "tao/CORBA_String.h"
27 #include "ace/Array_Map.h"
28 #include "ace/Thread_Mutex.h"
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 // Forward declarations.
34 class TAO_ORB_Core;
36 namespace TAO
38 class ORB_Core_Ref_Counter;
40 /**
41 * @class ORB_Table
43 * @brief Keep a table with all the ORBs in the system.
45 * CORBA::ORB_init() is supposed to return the same ORB if the
46 * user specifies the same ORBid, either in the ORB_init()
47 * parameter or in the -ORBid option.
48 * This class is used to implement that feature.
49 * It is also useful when trying to determine if an object
50 * reference is collocated or not.
52 * @note This class should be instantiated via its instance()
53 * method. Normally this would be enforced by making the
54 * constructor protected but that forces a friend declaration
55 * containing a template type (TAO_Singleton) with a static
56 * member to be introduced. In turn, this potentially
57 * introduces problems in MS Windows DLL environments due to
58 * the occurrence of multiple singleton instances. There
59 * should only be one!
61 class TAO_Export ORB_Table
63 public:
65 /// Constructor
66 /**
67 * @note See the note in the class description for an explanation
68 * of why this constructor is not protected.
70 ORB_Table ();
72 typedef ACE_Array_Map<CORBA::String_var,
73 ORB_Core_Ref_Counter,
74 TAO::String_Var_Equal_To> Table;
75 typedef Table::key_type key_type;
76 typedef Table::data_type data_type;
77 typedef Table::value_type value_type;
78 typedef Table::size_type size_type;
79 typedef Table::iterator iterator;
81 /**
82 * @name The canonical ACE_Map methods.
84 //@{
85 iterator begin ();
86 iterator end ();
87 int bind (const char *orb_id, ::TAO_ORB_Core *orb_core);
89 /// Return @c TAO_ORB_Core corresponding to ORB with given @a
90 /// orb_id.
91 /**
92 * @note The caller must decrease the reference count on the
93 * returned ORB_Core, i.e. the callers "owns" it.
95 ::TAO_ORB_Core* find (const char *orb_id);
97 int unbind (const char *orb_id);
98 //@}
100 /// Obtain the first ORB for the @c ORB_Core_instance()
101 /// implementation.
102 ::TAO_ORB_Core * first_orb ();
104 /// Return a unique instance
105 static ORB_Table * instance ();
107 /// Set the ORB related to the orb_id as the default ORB and not the
108 /// ORB that is first binded.
109 void set_default (char const * orb_id);
111 /// Method the ORB invokes to specify that it doesnt want to be the
112 /// default ORB if there are more than one ORB registered.
113 void not_default (char const * orb_id);
115 /// Accessor to the underlying table_
116 Table * table ();
118 /// Return reference to underlying lock.
119 TAO_SYNCH_MUTEX & lock ();
121 private:
123 // Prevent copying
124 ORB_Table (const ORB_Table &);
125 void operator= (const ORB_Table &);
127 /// Return @c TAO_ORB_Core corresponding to ORB with given @a
128 /// orb_id. (underlying unlocked implementation).
129 ::TAO_ORB_Core * find_i (char const * orb_id);
131 private:
133 /// Lock used to synchronize access to the internal state.
134 ::TAO_SYNCH_MUTEX lock_;
136 /// Variable to check if the first ORB decides not to be the
137 /// default.
138 bool first_orb_not_default_;
140 /// The underlying table.
141 Table table_;
143 /// The first ORB created by the user
144 ::TAO_ORB_Core * first_orb_;
147 // -----------------------------------------------
150 * @class ORB_Table_Ref_Counter
152 * @brief Class contained by ORB_Table's Unbounded_Set.
154 * Class contained by ORB_Table's Unbounded_Set.
156 class ORB_Core_Ref_Counter
158 public:
160 /// Constructor.
161 ORB_Core_Ref_Counter ();
163 /// Constructor.
164 ORB_Core_Ref_Counter (::TAO_ORB_Core * core);
166 /// Destructor.
167 ~ORB_Core_Ref_Counter ();
169 /// Copy constructor.
170 ORB_Core_Ref_Counter (ORB_Core_Ref_Counter const & rhs);
172 /// Assignment operator.
173 void operator= (ORB_Core_Ref_Counter const & rhs);
175 /// ORB_Core pointer accessor.
176 ::TAO_ORB_Core * core () const { return this->core_; }
178 private:
179 ::TAO_ORB_Core * core_;
184 TAO_END_VERSIONED_NAMESPACE_DECL
186 #if defined (__ACE_INLINE__)
187 # include "tao/ORB_Table.inl"
188 #endif /* __ACE_INLINE__ */
190 #include /**/ "ace/post.h"
192 #endif /* TAO_ORB_TABLE_H */