#include <EC_ObserverStrategy.h>
Inheritance diagram for TAO_EC_Basic_ObserverStrategy:
Public Types | |
typedef ACE_Map_Manager< RtecEventChannelAdmin::Observer_Handle, Observer_Entry, ACE_Null_Mutex > | Observer_Map |
typedef ACE_Map_Iterator< RtecEventChannelAdmin::Observer_Handle, Observer_Entry, ACE_Null_Mutex > | Observer_Map_Iterator |
typedef ACE_RB_Tree< RtecEventComm::EventHeader, int, Header_Compare, ACE_Null_Mutex > | Headers |
typedef ACE_RB_Tree_Iterator< RtecEventComm::EventHeader, int, Header_Compare, ACE_Null_Mutex > | HeadersIterator |
Public Member Functions | |
TAO_EC_Basic_ObserverStrategy (TAO_EC_Event_Channel_Base *ec, ACE_Lock *lock) | |
Constructor. | |
virtual | ~TAO_EC_Basic_ObserverStrategy (void) |
Destructor. | |
virtual RtecEventChannelAdmin::Observer_Handle | append_observer (RtecEventChannelAdmin::Observer_ptr) throw ( CORBA::SystemException, RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR, RtecEventChannelAdmin::EventChannel::CANT_APPEND_OBSERVER) |
The basic methods to support the EC strategies. | |
virtual void | remove_observer (RtecEventChannelAdmin::Observer_Handle) throw ( CORBA::SystemException, RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR, RtecEventChannelAdmin::EventChannel::CANT_REMOVE_OBSERVER) |
virtual void | connected (TAO_EC_ProxyPushConsumer *) |
virtual void | disconnected (TAO_EC_ProxyPushConsumer *) |
virtual void | connected (TAO_EC_ProxyPushSupplier *) |
virtual void | disconnected (TAO_EC_ProxyPushSupplier *) |
Protected Member Functions | |
virtual void | consumer_qos_update (TAO_EC_ProxyPushSupplier *supplier) |
Recompute EC consumer subscriptions and send them out to all observers. | |
virtual void | supplier_qos_update (TAO_EC_ProxyPushConsumer *consumer) |
Recompute EC supplier publications and send them out to all observers. | |
void | fill_qos (RtecEventChannelAdmin::ConsumerQOS &qos) |
Compute consumer QOS. | |
void | fill_qos (RtecEventChannelAdmin::SupplierQOS &qos) |
Compute supplier QOS. | |
int | create_observer_list (RtecEventChannelAdmin::Observer_var *&lst) |
Protected Attributes | |
TAO_EC_Event_Channel_Base * | event_channel_ |
The event channel. | |
ACE_Lock * | lock_ |
The lock. | |
RtecEventChannelAdmin::Observer_Handle | handle_generator_ |
Observer_Map | observers_ |
Keep the set of Observers. |
This class simply keeps the information about the current list of observers, whenever the list of consumers and/or suppliers changes in queries the EC, computes the global subscription and/or publication list and sends the update message to all the observers.
It assumes ownership of the lock, but not of the Event_Channel.
Definition at line 156 of file EC_ObserverStrategy.h.
|
Definition at line 226 of file EC_ObserverStrategy.h. Referenced by fill_qos(), TAO_EC_Accumulate_Consumer_Headers::TAO_EC_Accumulate_Consumer_Headers(), and TAO_EC_Accumulate_Supplier_Headers::TAO_EC_Accumulate_Supplier_Headers(). |
|
Definition at line 227 of file EC_ObserverStrategy.h. Referenced by fill_qos(). |
|
Definition at line 222 of file EC_ObserverStrategy.h. |
|
Definition at line 223 of file EC_ObserverStrategy.h. Referenced by create_observer_list(). |
|
Constructor.
Definition at line 45 of file EC_ObserverStrategy.i. References handle_generator_.
00047 : event_channel_ (ec), 00048 lock_ (lock), 00049 handle_generator_ (1) 00050 { 00051 } |
|
Destructor.
Definition at line 78 of file EC_ObserverStrategy.cpp.
|
|
The basic methods to support the EC strategies.
Implements TAO_EC_ObserverStrategy. Definition at line 85 of file EC_ObserverStrategy.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_GUARD_THROW_EX, ACE_THROW_RETURN, and TAO_EC_Basic_ObserverStrategy::Observer_Entry::handle.
00092 { 00093 { 00094 ACE_GUARD_THROW_EX ( 00095 ACE_Lock, ace_mon, *this->lock_, 00096 RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR()); 00097 ACE_CHECK_RETURN (0); 00098 00099 this->handle_generator_++; 00100 Observer_Entry entry (this->handle_generator_, 00101 RtecEventChannelAdmin::Observer::_duplicate (obs)); 00102 00103 if (this->observers_.bind (entry.handle, entry) == -1) 00104 ACE_THROW_RETURN ( 00105 RtecEventChannelAdmin::EventChannel::CANT_APPEND_OBSERVER(), 00106 0); 00107 } 00108 00109 RtecEventChannelAdmin::ConsumerQOS c_qos; 00110 this->fill_qos (c_qos ACE_ENV_ARG_PARAMETER); 00111 ACE_CHECK_RETURN (0); 00112 obs->update_consumer (c_qos ACE_ENV_ARG_PARAMETER); 00113 ACE_CHECK_RETURN (0); 00114 00115 RtecEventChannelAdmin::SupplierQOS s_qos; 00116 this->fill_qos (s_qos ACE_ENV_ARG_PARAMETER); 00117 ACE_CHECK_RETURN (0); 00118 obs->update_supplier (s_qos ACE_ENV_ARG_PARAMETER); 00119 ACE_CHECK_RETURN (0); 00120 00121 return this->handle_generator_; 00122 } |
|
Used by the EC to inform the ObserverStrategy that a Supplier has connected or disconnected from it. Implements TAO_EC_ObserverStrategy. Definition at line 226 of file EC_ObserverStrategy.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and consumer_qos_update().
00229 { 00230 this->consumer_qos_update (supplier ACE_ENV_ARG_PARAMETER); 00231 ACE_CHECK; 00232 } |
|
Used by the EC to inform the ObserverStrategy that a Consumer has connected or disconnected from it. Implements TAO_EC_ObserverStrategy. Definition at line 175 of file EC_ObserverStrategy.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and supplier_qos_update().
00178 { 00179 this->supplier_qos_update (consumer ACE_ENV_ARG_PARAMETER); 00180 ACE_CHECK; 00181 } |
|
Recompute EC consumer subscriptions and send them out to all observers.
Reimplemented in TAO_EC_Reactive_ObserverStrategy. Definition at line 244 of file EC_ObserverStrategy.cpp. References ACE_CATCHANY, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_TRY, ACE_TRY_CHECK, create_observer_list(), and fill_qos(). Referenced by connected(), and disconnected().
00247 { 00248 if (supplier->subscriptions ().is_gateway) 00249 return; 00250 00251 RtecEventChannelAdmin::ConsumerQOS c_qos; 00252 this->fill_qos (c_qos ACE_ENV_ARG_PARAMETER); 00253 ACE_CHECK; 00254 00255 RtecEventChannelAdmin::Observer_var *tmp = 0; 00256 int size = this->create_observer_list (tmp ACE_ENV_ARG_PARAMETER); 00257 ACE_CHECK; 00258 ACE_Auto_Basic_Array_Ptr<RtecEventChannelAdmin::Observer_var> copy (tmp); 00259 00260 for (int i = 0; i != size; ++i) 00261 { 00262 ACE_TRY 00263 { 00264 copy[i]->update_consumer (c_qos ACE_ENV_ARG_PARAMETER); 00265 ACE_TRY_CHECK; 00266 } 00267 ACE_CATCHANY 00268 { 00269 // Ignore exceptions, we must isolate other observers from 00270 // failures on this one. 00271 } 00272 ACE_ENDTRY; 00273 } 00274 } |
|
Copies all current observers into an array and passes it back to the caller through lst. Returns the size of the array. Definition at line 144 of file EC_ObserverStrategy.cpp. References ACE_CHECK_RETURN, ACE_GUARD_THROW_EX, ACE_NEW_RETURN, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::begin(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::current_size(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::end(), TAO_EC_Basic_ObserverStrategy::Observer_Entry::observer, Observer_Map_Iterator, observers_, and ACE_Auto_Basic_Array_Ptr< X >::release(). Referenced by consumer_qos_update(), and supplier_qos_update().
00147 { 00148 ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, 00149 RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR()); 00150 ACE_CHECK_RETURN (0); 00151 00152 int size = static_cast<int> (this->observers_.current_size ()); 00153 RtecEventChannelAdmin::Observer_var *tmp; 00154 ACE_NEW_RETURN (tmp, 00155 RtecEventChannelAdmin::Observer_var[size], 00156 0); 00157 ACE_Auto_Basic_Array_Ptr<RtecEventChannelAdmin::Observer_var> copy (tmp); 00158 00159 Observer_Map_Iterator end = this->observers_.end (); 00160 int j = 0; 00161 for (Observer_Map_Iterator i = this->observers_.begin (); 00162 i != end; 00163 ++i) 00164 { 00165 Observer_Entry& entry = (*i).int_id_; 00166 copy[j++] = 00167 RtecEventChannelAdmin::Observer::_duplicate (entry.observer.in ()); 00168 } 00169 00170 lst = copy.release (); 00171 return size; 00172 } |
|
Implements TAO_EC_ObserverStrategy. Definition at line 235 of file EC_ObserverStrategy.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and consumer_qos_update().
00238 { 00239 this->consumer_qos_update (supplier ACE_ENV_ARG_PARAMETER); 00240 ACE_CHECK; 00241 } |
|
Implements TAO_EC_ObserverStrategy. Definition at line 184 of file EC_ObserverStrategy.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and supplier_qos_update().
00187 { 00188 this->supplier_qos_update (consumer ACE_ENV_ARG_PARAMETER); 00189 ACE_CHECK; 00190 } |
|
Compute supplier QOS.
Definition at line 305 of file EC_ObserverStrategy.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::begin(), ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::current_size(), ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::end(), TAO_EC_Event_Channel_Base::for_each_supplier(), Headers, HeadersIterator, and ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::key().
00308 { 00309 Headers headers; 00310 00311 TAO_EC_Accumulate_Consumer_Headers worker (headers); 00312 this->event_channel_->for_each_supplier (&worker 00313 ACE_ENV_ARG_PARAMETER); 00314 ACE_CHECK; 00315 00316 qos.publications.length (static_cast<CORBA::ULong> (headers.current_size ())); 00317 00318 CORBA::ULong count = 0; 00319 for (HeadersIterator i = headers.begin (); i != headers.end (); ++i) 00320 { 00321 qos.publications[count++].event.header = (*i).key (); 00322 } 00323 } |
|
|
Implements TAO_EC_ObserverStrategy. Definition at line 126 of file EC_ObserverStrategy.cpp. References ACE_CHECK, ACE_GUARD_THROW_EX, ACE_THROW, and RtecEventChannelAdmin::Observer_Handle. Referenced by TAO_EC_Reactive_ObserverStrategy::observer_not_exists().
00133 { 00134 ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, 00135 RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR()); 00136 ACE_CHECK; 00137 00138 if (this->observers_.unbind (handle) == -1) 00139 ACE_THROW ( 00140 RtecEventChannelAdmin::EventChannel::CANT_REMOVE_OBSERVER()); 00141 } |
|
Recompute EC supplier publications and send them out to all observers.
Reimplemented in TAO_EC_Reactive_ObserverStrategy. Definition at line 193 of file EC_ObserverStrategy.cpp. References ACE_CATCHANY, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_TRY, ACE_TRY_CHECK, create_observer_list(), and fill_qos(). Referenced by connected(), and disconnected().
00196 { 00197 if (consumer->publications ().is_gateway) 00198 return; 00199 00200 RtecEventChannelAdmin::SupplierQOS s_qos; 00201 this->fill_qos (s_qos ACE_ENV_ARG_PARAMETER); 00202 ACE_CHECK; 00203 00204 RtecEventChannelAdmin::Observer_var *tmp = 0; 00205 int size = this->create_observer_list (tmp ACE_ENV_ARG_PARAMETER); 00206 ACE_CHECK; 00207 ACE_Auto_Basic_Array_Ptr<RtecEventChannelAdmin::Observer_var> copy (tmp); 00208 00209 for (int i = 0; i != size; ++i) 00210 { 00211 ACE_TRY 00212 { 00213 copy[i]->update_supplier (s_qos ACE_ENV_ARG_PARAMETER); 00214 ACE_TRY_CHECK; 00215 } 00216 ACE_CATCHANY 00217 { 00218 // Ignore exceptions, we must isolate other observers from 00219 // failures on this one. 00220 } 00221 ACE_ENDTRY; 00222 } 00223 } |
|
The event channel.
Definition at line 255 of file EC_ObserverStrategy.h. |
|
The handles are generated in sequential order, but are opaque to the client. Definition at line 262 of file EC_ObserverStrategy.h. Referenced by TAO_EC_Basic_ObserverStrategy(). |
|
The lock.
Definition at line 258 of file EC_ObserverStrategy.h. |
|
Keep the set of Observers.
Definition at line 265 of file EC_ObserverStrategy.h. Referenced by create_observer_list(). |