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)
 Constructor.
virtual ~TAO_Notify_ProxyConsumer (void)
 Destructor.
virtual void init (TAO_Notify::Topology_Parent *topology_parent)
 init: overrides Topology_Object method
void connect (TAO_Notify_Supplier *supplier)
 Connect.
void disconnect (void)
 Disconnect.
virtual int shutdown (void)
 Shutdown (TAO_Notify_Container_T method).
virtual void destroy (void)
 Destroy this object.
bool is_connected (void) const
 Return true 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   ) 

Constructor.

Definition at line 32 of file ProxyConsumer.cpp.

00033   : supplier_admin_ (0)
00034 {
00035 }

TAO_Notify_ProxyConsumer::~TAO_Notify_ProxyConsumer ( void   )  [virtual]

Destructor.

Definition at line 37 of file ProxyConsumer.cpp.

00038 {
00039 }


Member Function Documentation

void TAO_Notify_ProxyConsumer::connect ( TAO_Notify_Supplier supplier  ) 

Connect.

Definition at line 68 of file ProxyConsumer.cpp.

References ACE_ASSERT, ACE_GUARD_THROW_EX, TAO_Notify_Object::admin_properties(), TAO_Notify_Properties::allow_reconnect(), TAO_Notify_Event_Manager::connect(), TAO_Notify_Object::event_manager(), TAO_Notify_Properties::instance(), TAO_Notify_AdminProperties::max_suppliers(), TAO_Notify_Event_Manager::offer_change(), supplier(), supplier_, supplier_admin_, TAO_Notify_AdminProperties::suppliers(), TAO_SYNCH_MUTEX, and TAO_Notify_PropertyBase_T< TYPE >::value().

Referenced by TAO_Notify_ProxyPushConsumer::connect_any_push_supplier(), TAO_Notify_CosEC_ProxyPushConsumer::connect_push_supplier(), TAO_Notify_SequenceProxyPushConsumer::connect_sequence_push_supplier(), and TAO_Notify_StructuredProxyPushConsumer::connect_structured_push_supplier().

00069 {
00070   // Adopt the supplier
00071   ACE_Auto_Ptr< TAO_Notify_Supplier > auto_supplier (supplier);
00072 
00073   TAO_Notify_Atomic_Property_Long& supplier_count = this->admin_properties().suppliers ();
00074   const TAO_Notify_Property_Long& max_suppliers = this->admin_properties().max_suppliers ();
00075 
00076   if (max_suppliers != 0 && supplier_count >= max_suppliers.value ())
00077   {
00078     throw CORBA::IMP_LIMIT (
00079       ); // 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 
00086     // if supplier is set and reconnect not allowed we get out.
00087     if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false)
00088       {
00089         throw CosEventChannelAdmin::AlreadyConnected ();
00090       }
00091 
00092     // Adopt the supplier
00093     this->supplier_ = auto_supplier;
00094 
00095     this->supplier_admin_->subscribed_types (this->subscribed_types_); // get the parents subscribed types.
00096   }
00097 
00098   // Inform QoS values.
00099   ACE_ASSERT (this->supplier_.get() != 0);
00100   this->supplier_->qos_changed (this->qos_properties_);
00101 
00102   TAO_Notify_EventTypeSeq removed;
00103 
00104   this->event_manager().offer_change (this, this->subscribed_types_, removed);
00105 
00106   this->event_manager().connect (this);
00107 
00108   // Increment the global supplier count
00109   ++supplier_count;
00110 }

void TAO_Notify_ProxyConsumer::destroy ( void   )  [virtual]

Destroy this object.

Implements TAO_Notify_Proxy.

Definition at line 177 of file ProxyConsumer.cpp.

References shutdown(), and supplier_admin_.

Referenced by TAO_Notify_ProxyPushConsumer::disconnect_push_consumer(), TAO_Notify_CosEC_ProxyPushConsumer::disconnect_push_consumer(), TAO_Notify_SequenceProxyPushConsumer::disconnect_sequence_push_consumer(), and TAO_Notify_StructuredProxyPushConsumer::disconnect_structured_push_consumer().

00178 {
00179   this->shutdown ();
00180   this->supplier_admin_->cleanup_proxy (this, false);
00181 
00182   // Do not reset this->supplier_.
00183   // It is not safe to delete the non-refcounted supplier here.
00184 }

void TAO_Notify_ProxyConsumer::disconnect ( void   ) 

Disconnect.

Definition at line 148 of file ProxyConsumer.cpp.

References 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().

00149 {
00150   TAO_Notify_EventTypeSeq added;
00151 
00152   event_manager().offer_change (this, added, this->subscribed_types_);
00153 
00154   this->event_manager().disconnect (this);
00155 
00156   // Decrement the global supplier count
00157   this->admin_properties().suppliers ()--;
00158 }

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_GUARD_THROW_EX, TAO_Notify_Properties::default_proxy_consumer_qos_properties(), TAO_Notify::Topology_Object::initialize(), TAO_Notify_Properties::instance(), TAO_Notify_Refcountable_Guard_T< T >::reset(), TAO_Notify_Object::set_qos(), supplier_admin_, TAO_SYNCH_MUTEX, and TAO_Notify::Topology_Object::topology_parent().

00049 {
00050   ACE_ASSERT( this->supplier_admin_.get() == 0 );
00051 
00052   TAO_Notify_Proxy::initialize (topology_parent);
00053 
00054   this->supplier_admin_.reset (dynamic_cast<TAO_Notify_SupplierAdmin *>(topology_parent));
00055   ACE_ASSERT (this->supplier_admin_.get() != 0);
00056 
00057   const CosNotification::QoSProperties &default_ps_qos =
00058     TAO_Notify_PROPERTIES::instance ()->default_proxy_consumer_qos_properties ();
00059 
00060   {
00061     ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00062                          CORBA::INTERNAL ());
00063     this->TAO_Notify_Object::set_qos (default_ps_qos);
00064   }
00065 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE bool TAO_Notify_ProxyConsumer::is_connected ( void   )  const

Return true if connected.

Definition at line 8 of file ProxyConsumer.inl.

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 112 of file ProxyConsumer.cpp.

References ACE_DEBUG, ACE_TEXT(), TAO_Notify::Routing_Slip::create(), DEBUG_LEVEL, TAO_Notify_Object::execute_task(), LM_DEBUG, and TAO_Notify_Event::queueable_copy().

Referenced by TAO_Notify_ProxyPushConsumer::push(), TAO_Notify_StructuredProxyPushConsumer::push_structured_event(), and TAO_Notify_SequenceProxyPushConsumer::push_structured_events().

00113 {
00114   if (this->supports_reliable_events ())
00115     {
00116       TAO_Notify_Event::Ptr pevent(event->queueable_copy());
00117       TAO_Notify::Routing_Slip_Ptr routing_slip =
00118         TAO_Notify::Routing_Slip::create (pevent);
00119       if (DEBUG_LEVEL > 0)
00120         ACE_DEBUG((LM_DEBUG, ACE_TEXT ("ProxyConsumer routing event.\n")));
00121       routing_slip->route (this, true);
00122       routing_slip->wait_persist ();
00123     }
00124   else
00125     {
00126       TAO_Notify_Method_Request_Lookup_No_Copy request (event, this);
00127       this->execute_task (request);
00128     }
00129 }

int TAO_Notify_ProxyConsumer::shutdown ( void   )  [virtual]

Shutdown (TAO_Notify_Container_T method).

Reimplemented from TAO_Notify_Object.

Definition at line 161 of file ProxyConsumer.cpp.

References disconnect().

Referenced by destroy().

00162 {
00163   if (this->TAO_Notify_Object::shutdown () == 1)
00164     return 1;
00165 
00166 
00167   this->disconnect ();
00168 
00169   if (this->supplier_.get() != 0)
00170   {
00171     this->supplier_->shutdown ();
00172   }
00173   return 0;
00174 }

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(), and supplier_.

Referenced by connect(), TAO_Notify_ProxyPushConsumer::connect_any_push_supplier(), TAO_Notify_CosEC_ProxyPushConsumer::connect_push_supplier(), TAO_Notify_SequenceProxyPushConsumer::connect_sequence_push_supplier(), TAO_Notify_StructuredProxyPushConsumer::connect_structured_push_supplier(), and 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, and supplier_admin_.

Referenced by TAO_Notify_Method_Request_Lookup::execute_i(), and TAO_Notify_ProxyConsumer_T< SERVANT_TYPE >::MyAdmin().

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 132 of file ProxyConsumer.cpp.

References CosNotification::EventReliability, and CosNotification::Persistent.

00133 {
00134   bool reliable = false;
00135   CosNotification::PropertyValue value;
00136   if (this->find_qos_property_value (CosNotification::EventReliability, value))
00137     {
00138       CORBA::Short setting;
00139       if (value >>= setting)
00140         {
00141           reliable = (setting == CosNotification::Persistent);
00142         }
00143     }
00144   return reliable;
00145 }


Member Data Documentation

ACE_Auto_Ptr<TAO_Notify_Supplier> TAO_Notify_ProxyConsumer::supplier_ [private]

The Supplier that we're connect to.

Definition at line 87 of file ProxyConsumer.h.

Referenced by connect(), and supplier().

TAO_Notify_SupplierAdmin::Ptr TAO_Notify_ProxyConsumer::supplier_admin_ [private]

= Data Members. The SA parent.

Definition at line 84 of file ProxyConsumer.h.

Referenced by connect(), destroy(), init(), and supplier_admin().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:46:26 2010 for TAO_CosNotification by  doxygen 1.4.7