EC_Timeout_Filter.cpp

Go to the documentation of this file.
00001 // $Id: EC_Timeout_Filter.cpp 76589 2007-01-25 18:04:11Z elliott_c $
00002 
00003 #include "orbsvcs/Event/EC_Timeout_Filter.h"
00004 #include "orbsvcs/Event/EC_Timeout_Generator.h"
00005 #include "orbsvcs/Event/EC_Event_Channel_Base.h"
00006 #include "orbsvcs/Event/EC_ProxySupplier.h"
00007 #include "orbsvcs/Time_Utilities.h"
00008 #include "orbsvcs/Event_Service_Constants.h"
00009 
00010 #if ! defined (__ACE_INLINE__)
00011 #include "orbsvcs/Event/EC_Timeout_Filter.inl"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 ACE_RCSID (Event,
00015            EC_Timeout_Filter,
00016            "$Id: EC_Timeout_Filter.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 TAO_EC_Timeout_Filter::TAO_EC_Timeout_Filter (
00021       TAO_EC_Event_Channel_Base *event_channel,
00022       TAO_EC_ProxyPushSupplier *supplier,
00023       const TAO_EC_QOS_Info& qos_info,
00024       RtecEventComm::EventType type,
00025       RtecEventComm::Time period)
00026   : event_channel_ (event_channel),
00027     supplier_ (supplier),
00028     qos_info_ (qos_info),
00029     type_ (type),
00030     period_ (period),
00031     id_ (-1)
00032 {
00033   ACE_Time_Value tv_delta;
00034   ORBSVCS_Time::TimeT_to_Time_Value (tv_delta, period);
00035 
00036   TAO_EC_Timeout_Generator *tg =
00037     this->event_channel_->timeout_generator ();
00038 
00039   if (this->type_ == ACE_ES_EVENT_INTERVAL_TIMEOUT
00040       || this->type_ == ACE_ES_EVENT_DEADLINE_TIMEOUT)
00041     {
00042       ACE_Time_Value tv_interval;
00043       ORBSVCS_Time::TimeT_to_Time_Value (tv_interval, this->period_);
00044 
00045       this->id_ =
00046         tg->schedule_timer (this,
00047                             tv_delta,
00048                             tv_interval);
00049     }
00050   else
00051     {
00052       this->id_ =
00053         tg->schedule_timer (this,
00054                             tv_delta,
00055                             ACE_Time_Value::zero);
00056     }
00057 
00058   //  ACE_DEBUG ((LM_DEBUG,
00059   //              "EC_Timeout_Filter - interval = %d:%d, ID = %d\n",
00060   //              tv_interval.sec (), tv_interval.usec (),
00061   //              this->id_));
00062 }
00063 
00064 TAO_EC_Timeout_Filter::~TAO_EC_Timeout_Filter (void)
00065 {
00066   this->event_channel_->timeout_generator ()->cancel_timer (this->qos_info_,
00067                                                             this->id_);
00068 }
00069 
00070 void
00071 TAO_EC_Timeout_Filter::push_to_proxy (const RtecEventComm::EventSet& event,
00072                                       TAO_EC_QOS_Info& qos_info)
00073 {
00074   qos_info.timer_id_ = this->id_;
00075 
00076   if (this->supplier_ != 0)
00077     this->supplier_->filter (event,
00078                              qos_info);
00079 }
00080 
00081 int
00082 TAO_EC_Timeout_Filter::filter (const RtecEventComm::EventSet &event,
00083                                TAO_EC_QOS_Info &qos_info)
00084 {
00085   if (qos_info.timer_id_ == this->id_
00086       && this->parent () != 0)
00087     {
00088       this->parent ()->push (event, qos_info);
00089       return 1;
00090     }
00091   return 0;
00092 }
00093 
00094 int
00095 TAO_EC_Timeout_Filter::filter_nocopy (RtecEventComm::EventSet &event,
00096                                       TAO_EC_QOS_Info &qos_info)
00097 {
00098   if (qos_info.timer_id_ == this->id_
00099       && this->parent () != 0)
00100     {
00101       this->parent ()->push_nocopy (event, qos_info);
00102       return 1;
00103     }
00104   return 0;
00105 }
00106 
00107 void
00108 TAO_EC_Timeout_Filter::push (const RtecEventComm::EventSet&,
00109                           TAO_EC_QOS_Info&)
00110 {
00111 }
00112 
00113 void
00114 TAO_EC_Timeout_Filter::push_nocopy (RtecEventComm::EventSet&,
00115                                     TAO_EC_QOS_Info&)
00116 {
00117 }
00118 
00119 void
00120 TAO_EC_Timeout_Filter::clear (void)
00121 {
00122   if (this->type_ == ACE_ES_EVENT_DEADLINE_TIMEOUT)
00123     {
00124       TAO_EC_Timeout_Generator *tg =
00125         this->event_channel_->timeout_generator ();
00126 
00127       tg->cancel_timer (this->qos_info_,
00128                         this->id_);
00129 
00130       ACE_Time_Value tv_interval;
00131       ORBSVCS_Time::TimeT_to_Time_Value (tv_interval, this->period_);
00132       ACE_Time_Value tv_delta = tv_interval;
00133 
00134       this->id_ =
00135         tg->schedule_timer (this,
00136                             tv_delta,
00137                             tv_interval);
00138     }
00139 }
00140 
00141 CORBA::ULong
00142 TAO_EC_Timeout_Filter::max_event_size (void) const
00143 {
00144   return 1;
00145 }
00146 
00147 int
00148 TAO_EC_Timeout_Filter::can_match (
00149       const RtecEventComm::EventHeader&) const
00150 {
00151   return 0;
00152 }
00153 
00154 int
00155 TAO_EC_Timeout_Filter::add_dependencies (
00156       const RtecEventComm::EventHeader&,
00157       const TAO_EC_QOS_Info &)
00158 {
00159   return 0;
00160 }
00161 
00162 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:44:06 2010 for TAO_RTEvent by  doxygen 1.4.7