TAO_Notify_ProxyConsumer Class Reference

Base class for all types of ProxyConsumer implementations. More...

#include <ProxyConsumer.h>

Inheritance diagram for TAO_Notify_ProxyConsumer:

Inheritance graph
[legend]
Collaboration diagram for TAO_Notify_ProxyConsumer:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_Notify_Refcountable_Guard_T<
TAO_Notify_ProxyConsumer
Ptr

Public Member Functions

 TAO_Notify_ProxyConsumer (void)
 Constuctor.

virtual ~TAO_Notify_ProxyConsumer ()
 Destructor.

virtual void init (TAO_Notify::Topology_Parent *topology_parent)
 init: overrides Topology_Object method

void connect (TAO_Notify_Supplier *supplier) throw ( CORBA::SystemException , CosEventChannelAdmin::AlreadyConnected )
 Connect.

void disconnect ()
 Disconnect.

virtual int shutdown ()
 Shutdown (TAO_Notify_Container_T method).

virtual void destroy ()
 Destroy this object.

bool is_connected (void) const
 Return 1 if connected.

TAO_Notify_SupplierAdminsupplier_admin (void)
 The SA parent.


Protected Member Functions

TAO_Notify_Suppliersupplier (void)
 Access the Supplier.

void push_i (TAO_Notify_Event *event)
 Accept an event from the Supplier.


Private Member Functions

bool supports_reliable_events () const
 Is this part of a reliable channel.

virtual TAO_Notify_Peerpeer (void)
 Access our Peer.


Private Attributes

TAO_Notify_SupplierAdmin::Ptr supplier_admin_
ACE_Auto_Ptr< TAO_Notify_Suppliersupplier_
 The Supplier that we're connect to.


Detailed Description

Base class for all types of ProxyConsumer implementations.

Definition at line 39 of file ProxyConsumer.h.


Member Typedef Documentation

typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxyConsumer> TAO_Notify_ProxyConsumer::Ptr
 

Reimplemented from TAO_Notify_Proxy.

Definition at line 43 of file ProxyConsumer.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Notify_ProxyConsumer::TAO_Notify_ProxyConsumer void   ) 
 

Constuctor.

Definition at line 32 of file ProxyConsumer.cpp.

00033   : supplier_admin_ (0)
00034 {
00035 }

TAO_Notify_ProxyConsumer::~TAO_Notify_ProxyConsumer  )  [virtual]
 

Destructor.

Definition at line 37 of file ProxyConsumer.cpp.

00038 {
00039 }


Member Function Documentation

void TAO_Notify_ProxyConsumer::connect TAO_Notify_Supplier supplier  )  throw ( CORBA::SystemException , CosEventChannelAdmin::AlreadyConnected )
 

Connect.

Definition at line 65 of file ProxyConsumer.cpp.

References ACE_ASSERT, ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_GUARD_THROW_EX, ACE_THROW, TAO_Singleton< TYPE, ACE_LOCK >::instance(), TAO_Notify_Atomic_Property_Long, TAO_Notify_Property_Long, TAO_SYNCH_MUTEX, and TAO_Notify_PropertyBase_T< TYPE >::value().

00070 {
00071   // Adopt the supplier
00072   ACE_Auto_Ptr< TAO_Notify_Supplier > auto_supplier (supplier);
00073 
00074   TAO_Notify_Atomic_Property_Long& supplier_count = this->admin_properties().suppliers ();
00075   const TAO_Notify_Property_Long& max_suppliers = this->admin_properties().max_suppliers ();
00076 
00077   if (max_suppliers != 0 && supplier_count >= max_suppliers.value ())
00078   {
00079     ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of suppliers connected.
00080   }
00081 
00082   {
00083     ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00084                         CORBA::INTERNAL ());
00085     ACE_CHECK;
00086 
00087     // if supplier is set and reconnect not allowed we get out.
00088     if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false)
00089       {
00090         ACE_THROW (CosEventChannelAdmin::AlreadyConnected ());
00091       }
00092 
00093     // Adopt the supplier
00094     this->supplier_ = auto_supplier;
00095 
00096     this->supplier_admin_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types.
00097     ACE_CHECK;
00098   }
00099 
00100   // Inform QoS values.
00101   ACE_ASSERT (this->supplier_.get() != 0);
00102   this->supplier_->qos_changed (this->qos_properties_);
00103 
00104   TAO_Notify_EventTypeSeq removed;
00105 
00106   this->event_manager().offer_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER);
00107   ACE_CHECK;
00108 
00109   this->event_manager().connect (this ACE_ENV_ARG_PARAMETER);
00110   ACE_CHECK;
00111 
00112   // Increment the global supplier count
00113   ++supplier_count;
00114 }

void TAO_Notify_ProxyConsumer::destroy  )  [virtual]
 

Destroy this object.

Implements TAO_Notify_Proxy.

Definition at line 190 of file ProxyConsumer.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, and shutdown().

00191 {
00192   int result = this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
00193   ACE_CHECK;
00194   if ( result == 1)
00195     return;
00196 
00197   this->supplier_admin_->remove (this ACE_ENV_ARG_PARAMETER);
00198   ACE_CHECK;
00199 
00200   // Do not reset this->supplier_.
00201   // It is not safe to delete the non-refcounted supplier here.
00202 }

void TAO_Notify_ProxyConsumer::disconnect  ) 
 

Disconnect.

Definition at line 156 of file ProxyConsumer.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, TAO_Notify_Object::admin_properties(), TAO_Notify_Event_Manager::disconnect(), TAO_Notify_Object::event_manager(), TAO_Notify_Event_Manager::offer_change(), and TAO_Notify_AdminProperties::suppliers().

Referenced by shutdown().

00157 {
00158   TAO_Notify_EventTypeSeq added;
00159 
00160   event_manager().offer_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER);
00161   ACE_CHECK;
00162 
00163   this->event_manager().disconnect (this ACE_ENV_ARG_PARAMETER);
00164   ACE_CHECK;
00165 
00166   // Decrement the global supplier count
00167   this->admin_properties().suppliers ()--;
00168 }

void TAO_Notify_ProxyConsumer::init TAO_Notify::Topology_Parent topology_parent  )  [virtual]
 

init: overrides Topology_Object method

Definition at line 48 of file ProxyConsumer.cpp.

References ACE_ASSERT, ACE_CHECK, ACE_ENV_ARG_PARAMETER, TAO_Notify::Topology_Object::initialize(), TAO_Singleton< TYPE, ACE_LOCK >::instance(), CosNotification::QoSProperties, and TAO_Notify_Object::set_qos().

00049 {
00050   ACE_ASSERT( this->supplier_admin_.get() == 0 );
00051 
00052   TAO_Notify_Proxy::initialize (topology_parent ACE_ENV_ARG_PARAMETER);
00053   ACE_CHECK;
00054 
00055   this->supplier_admin_.reset (dynamic_cast<TAO_Notify_SupplierAdmin *>(topology_parent));
00056   ACE_ASSERT (this->supplier_admin_.get() != 0);
00057 
00058   const CosNotification::QoSProperties &default_ps_qos =
00059     TAO_Notify_PROPERTIES::instance ()->default_proxy_consumer_qos_properties ();
00060 
00061   this->set_qos (default_ps_qos ACE_ENV_ARG_PARAMETER);
00062 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE bool TAO_Notify_ProxyConsumer::is_connected void   )  const
 

Return 1 if connected.

Definition at line 8 of file ProxyConsumer.inl.

References ACE_Auto_Basic_Ptr< X >::get().

00009 {
00010   return (this->supplier_.get() != 0);
00011 }

TAO_Notify_Peer * TAO_Notify_ProxyConsumer::peer void   )  [private, virtual]
 

Access our Peer.

Implements TAO_Notify_Proxy.

Definition at line 42 of file ProxyConsumer.cpp.

References supplier().

00043 {
00044   return this->supplier ();
00045 }

void TAO_Notify_ProxyConsumer::push_i TAO_Notify_Event event  )  [protected]
 

Accept an event from the Supplier.

Definition at line 116 of file ProxyConsumer.cpp.

References ACE_CHECK, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_TEXT(), TAO_Notify::Routing_Slip::create(), DEBUG_LEVEL, TAO_Notify_Object::execute_task(), LM_DEBUG, TAO_Notify::Routing_Slip_Ptr, and supports_reliable_events().

00117 {
00118   if (this->supports_reliable_events ())
00119     {
00120       TAO_Notify_Event::Ptr pevent(event->queueable_copy(ACE_ENV_SINGLE_ARG_PARAMETER));
00121       ACE_CHECK;
00122       TAO_Notify::Routing_Slip_Ptr routing_slip =
00123         TAO_Notify::Routing_Slip::create (pevent ACE_ENV_ARG_PARAMETER);
00124       ACE_CHECK;
00125       if (DEBUG_LEVEL > 0)
00126         ACE_DEBUG((LM_DEBUG, ACE_TEXT ("ProxyConsumer routing event.\n")));
00127       routing_slip->route (this, true ACE_ENV_ARG_PARAMETER);
00128       ACE_CHECK;
00129       routing_slip->wait_persist ();
00130     }
00131   else
00132     {
00133       TAO_Notify_Method_Request_Lookup_No_Copy request (event, this);
00134       this->execute_task (request ACE_ENV_ARG_PARAMETER);
00135       ACE_CHECK;
00136     }
00137 }

int TAO_Notify_ProxyConsumer::shutdown  )  [virtual]
 

Shutdown (TAO_Notify_Container_T method).

Reimplemented from TAO_Notify_Object.

Definition at line 171 of file ProxyConsumer.cpp.

References ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_PARAMETER, disconnect(), ACE_Auto_Basic_Ptr< X >::get(), and TAO_Notify_Object::shutdown().

Referenced by destroy().

00172 {
00173   if (this->TAO_Notify_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1)
00174     return 1;
00175 
00176   ACE_CHECK_RETURN (1);
00177 
00178   this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER);
00179   ACE_CHECK_RETURN (1);
00180 
00181   if (this->supplier_.get() != 0)
00182   {
00183     this->supplier_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
00184     ACE_CHECK_RETURN (1);
00185   }
00186   return 0;
00187 }

ACE_INLINE TAO_Notify_Supplier * TAO_Notify_ProxyConsumer::supplier void   )  [protected]
 

Access the Supplier.

Definition at line 14 of file ProxyConsumer.inl.

References ACE_Auto_Basic_Ptr< X >::get().

Referenced by peer().

00015 {
00016   return this->supplier_.get();
00017 }

ACE_INLINE TAO_Notify_SupplierAdmin & TAO_Notify_ProxyConsumer::supplier_admin void   ) 
 

The SA parent.

Definition at line 20 of file ProxyConsumer.inl.

References ACE_ASSERT.

Referenced by TAO_Notify_Method_Request_Lookup::execute_i().

00021 {
00022   ACE_ASSERT( this->supplier_admin_.get() != 0 );
00023   return *this->supplier_admin_;
00024 }

bool TAO_Notify_ProxyConsumer::supports_reliable_events  )  const [private]
 

Is this part of a reliable channel.

Definition at line 140 of file ProxyConsumer.cpp.

References TAO_Notify_Object::find_qos_property_value(), and CosNotification::PropertyValue.

Referenced by push_i().

00141 {
00142   bool reliable = false;
00143   CosNotification::PropertyValue value;
00144     if (this->find_qos_property_value (CosNotification::EventReliability, value))
00145     {
00146       CORBA::Long setting;
00147       if (value >>= setting)
00148       {
00149         reliable = (setting == CosNotification::Persistent);
00150       }
00151     }
00152   return reliable;
00153 }


Member Data Documentation

ACE_Auto_Ptr<TAO_Notify_Supplier> TAO_Notify_ProxyConsumer::supplier_ [private]
 

The Supplier that we're connect to.

Definition at line 92 of file ProxyConsumer.h.

TAO_Notify_SupplierAdmin::Ptr TAO_Notify_ProxyConsumer::supplier_admin_ [private]
 

= Data Members. The SA parent.

Definition at line 89 of file ProxyConsumer.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:32:43 2006 for TAO_CosNotification by doxygen 1.3.6