#include <Bindings_Iterator_T.h>
Collaboration diagram for TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >:
Public Member Functions | |
TAO_Bindings_Iterator (TAO_Hash_Naming_Context *context, ITERATOR *hash_iter, PortableServer::POA_ptr poa, TAO_SYNCH_RECURSIVE_MUTEX &lock) | |
~TAO_Bindings_Iterator (void) | |
Destructor. | |
virtual PortableServer::POA_ptr | _default_POA (void) |
Returns the Default POA of this Servant object. | |
CORBA::Boolean | next_one (CosNaming::Binding_out b) |
CORBA::Boolean | next_n (CORBA::ULong how_many, CosNaming::BindingList_out bl) |
void | destroy (void) |
This operation destroys the iterator. | |
Static Public Member Functions | |
int | populate_binding (TABLE_ENTRY *hash_entry, CosNaming::Binding &b) |
Private Attributes | |
bool | destroyed_ |
TAO_Hash_Naming_Context * | context_ |
ITERATOR * | hash_iter_ |
A pointer to the hash map iterator. | |
TAO_SYNCH_RECURSIVE_MUTEX & | lock_ |
PortableServer::POA_var | poa_ |
Implement a different _default_POA(). |
This class is templatized by the types of the underlying hash table iterator and hash table entry, so that it can be used for both TAO_Transient_Naming_Context and TAO_Persistent_Naming_Context (and any other classes with underlying data structures supporting ACE_Hash_Map_Manager/Iterator - like interfaces).
Instances of s affect reference counts of corresponding Naming Contexts. Reference count on a Naming Context is incremented by one for a lifetime of each instance of created for that context, i.e., a Naming Context cannot be cleaned up (but, of course, it can be invalidated) before all of its iterators have been cleaned up. When method is invoked on a Naming Context, all of its iterators are destroyed in a "lazy evaluation" fashion, i.e., whenever a next operation is invoked on an iterator, and it can detect that the corresponding Naming Context has been invalidated, the iterator is destroyed.
Definition at line 51 of file Bindings_Iterator_T.h.
|
Constructor expects a pointer to a dynamically allocated hash map iterator (destructor deallocates hash map iterator). Definition at line 15 of file Bindings_Iterator_T.cpp.
00020 : destroyed_ (false), 00021 context_ (context), 00022 hash_iter_ (hash_iter), 00023 lock_ (lock), 00024 poa_ (PortableServer::POA::_duplicate (poa)) 00025 00026 { 00027 } |
|
Destructor.
Definition at line 30 of file Bindings_Iterator_T.cpp. References TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::hash_iter_, and TAO_Hash_Naming_Context::interface().
00031 { 00032 delete hash_iter_; 00033 00034 // Since we are going away, decrement the reference count on the 00035 // Naming Context we were iterating over. 00036 context_->interface ()->_remove_ref (); 00037 } |
|
Returns the Default POA of this Servant object.
Definition at line 41 of file Bindings_Iterator_T.cpp.
00042 {
00043 return PortableServer::POA::_duplicate (this->poa_.in ());
00044 }
|
|
This operation destroys the iterator.
Definition at line 164 of file Bindings_Iterator_T.cpp. References ACE_GUARD_THROW_EX, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroyed_, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::poa_, and TAO_SYNCH_RECURSIVE_MUTEX. Referenced by TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_n(), and TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_one().
00165 { 00166 ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, 00167 ace_mon, 00168 this->lock_, 00169 CORBA::INTERNAL ()); 00170 00171 // Check to make sure this object is still valid. 00172 if (this->destroyed_) 00173 throw CORBA::OBJECT_NOT_EXIST (); 00174 00175 // Mark the object invalid. 00176 this->destroyed_ = true; 00177 00178 PortableServer::ObjectId_var id = 00179 poa_->servant_to_id (this); 00180 00181 poa_->deactivate_object (id.in ()); 00182 } |
|
This operation passes back at most unseen bindings. True is returned if bindings were passed back, and false is returned if no bindings were passed back. Definition at line 100 of file Bindings_Iterator_T.cpp. References ACE_GUARD_THROW_EX, ACE_NEW_THROW_EX, CosNaming::BindingList, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroy(), TAO_Hash_Naming_Context::destroyed(), TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroyed_, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::hash_iter_, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::populate_binding(), and TAO_SYNCH_RECURSIVE_MUTEX.
00103 { 00104 // We perform an allocation before obtaining the lock so that an out 00105 // parameter is allocated in case we fail to obtain the lock. 00106 ACE_NEW_THROW_EX (bl, 00107 CosNaming::BindingList (0), 00108 CORBA::NO_MEMORY ()); 00109 // Obtain the lock. 00110 ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, 00111 ace_mon, 00112 this->lock_, 00113 CORBA::INTERNAL ()); 00114 00115 // Check to make sure this object is still valid. 00116 if (this->destroyed_) 00117 throw CORBA::OBJECT_NOT_EXIST (); 00118 00119 // If the context we are iterating over has been destroyed, 00120 // self-destruct. 00121 if (context_->destroyed ()) 00122 { 00123 destroy (); 00124 00125 throw CORBA::OBJECT_NOT_EXIST (); 00126 } 00127 00128 // Check for illegal parameter values. 00129 if (how_many == 0) 00130 throw CORBA::BAD_PARAM (); 00131 00132 // If there are no more bindings... 00133 if (hash_iter_->done ()) 00134 return 0; 00135 else 00136 { 00137 // Initially assume that the iterator has the requested number of 00138 // bindings. 00139 bl->length (how_many); 00140 00141 TABLE_ENTRY *hash_entry = 0; 00142 00143 // Iterate and populate the BindingList. 00144 for (CORBA::ULong i = 0; i < how_many; i++) 00145 { 00146 hash_iter_->next (hash_entry); 00147 00148 if (populate_binding (hash_entry, bl[i]) == 0) 00149 throw CORBA::NO_MEMORY (); 00150 00151 if (hash_iter_->advance () == 0) 00152 { 00153 // If no more bindings are left, reset length to the actual 00154 // number of bindings populated, and get out of the loop. 00155 bl->length (i + 1); 00156 break; 00157 } 00158 } 00159 return 1; 00160 } 00161 } |
|
This operation passes back the next unseen binding. True is returned if a binding is passed back, and false is returned otherwise. Definition at line 47 of file Bindings_Iterator_T.cpp. References ACE_GUARD_THROW_EX, ACE_NEW_THROW_EX, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroy(), TAO_Hash_Naming_Context::destroyed(), TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroyed_, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::hash_iter_, TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::populate_binding(), and TAO_SYNCH_RECURSIVE_MUTEX.
00049 { 00050 CosNaming::Binding *binding = 0; 00051 00052 // Allocate a binding to be returned (even if there no more 00053 // bindings, we need to allocate an out parameter.) 00054 ACE_NEW_THROW_EX (binding, 00055 CosNaming::Binding, 00056 CORBA::NO_MEMORY ()); 00057 00058 b = binding; 00059 00060 ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, 00061 ace_mon, 00062 this->lock_, 00063 CORBA::INTERNAL ()); 00064 00065 // Check to make sure this object is still valid. 00066 if (this->destroyed_) 00067 throw CORBA::OBJECT_NOT_EXIST (); 00068 00069 // If the context we are iterating over has been destroyed, 00070 // self-destruct. 00071 if (context_->destroyed ()) 00072 { 00073 destroy (); 00074 00075 throw CORBA::OBJECT_NOT_EXIST (); 00076 } 00077 00078 // If there are no more bindings. 00079 if (hash_iter_->done ()) 00080 { 00081 b->binding_type = CosNaming::nobject; 00082 b->binding_name.length (0); 00083 return 0; 00084 } 00085 else 00086 { 00087 // Return a binding. 00088 TABLE_ENTRY *hash_entry = 0; 00089 hash_iter_->next (hash_entry); 00090 00091 if (populate_binding (hash_entry, *binding) == 0) 00092 throw CORBA::NO_MEMORY (); 00093 00094 hash_iter_->advance (); 00095 return 1; 00096 } 00097 } |
|
Helper function used by TAO_*_Naming_Context and TAO_BindingIterator: populate a binding with info contained in . Return 1 if everything went smoothly, 0 if an allocation failed. Definition at line 185 of file Bindings_Iterator_T.cpp. References CosNaming::Binding::binding_name, and CosNaming::Binding::binding_type. Referenced by TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_n(), and TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_one().
00188 { 00189 b.binding_type = hash_entry->int_id_.type_; 00190 b.binding_name.length (1); 00191 00192 // Here we perform a check before assignment to make sure 00193 // CORBA::string_dup is not called on 0 pointer, since the spec does 00194 // not say what should happen in that case. 00195 if (hash_entry->ext_id_.id () != 0) 00196 { 00197 b.binding_name[0].id = 00198 hash_entry->ext_id_.id (); 00199 if (b.binding_name[0].id.in () == 0) 00200 return 0; 00201 } 00202 if (hash_entry->ext_id_.kind () != 0) 00203 { 00204 b.binding_name[0].kind = 00205 hash_entry->ext_id_.kind (); 00206 if (b.binding_name[0].kind.in () == 0) 00207 return 0; 00208 } 00209 return 1; 00210 } |
|
Pointer to the Naming Context we are iterating over. We need this pointer to make sure the context is still valid before each iteration, and to decrement its reference count once we are . Definition at line 115 of file Bindings_Iterator_T.h. |
|
Flag indicating whether this iterator is still valid. (The iterator becomes invalid when method has been invoked on it, or when method has been invoked on the corresponding Naming Context.) This flag is necessary because immediate destruction of this servant might not be possible due to pending requests in the POA. Definition at line 108 of file Bindings_Iterator_T.h. Referenced by TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroy(), TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_n(), and TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_one(). |
|
A pointer to the hash map iterator.
Definition at line 118 of file Bindings_Iterator_T.h. Referenced by TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_n(), TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::next_one(), and TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::~TAO_Bindings_Iterator(). |
|
Lock passed on from Naming Context to serialize access to the internal data structure. Definition at line 122 of file Bindings_Iterator_T.h. |
|
Implement a different _default_POA().
Definition at line 125 of file Bindings_Iterator_T.h. Referenced by TAO_Bindings_Iterator< ITERATOR, TABLE_ENTRY >::destroy(). |