QoSProperties.cpp

Go to the documentation of this file.
00001 // $Id: QoSProperties.cpp 78785 2007-07-05 06:23:30Z johnnyw $
00002 
00003 #include "orbsvcs/Notify/QoSProperties.h"
00004 
00005 #if ! defined (__ACE_INLINE__)
00006 #include "orbsvcs/Notify/QoSProperties.inl"
00007 #endif /* __ACE_INLINE__ */
00008 
00009 ACE_RCSID(Notify, TAO_Notify_QoSProperties, "$Id: QoSProperties.cpp 78785 2007-07-05 06:23:30Z johnnyw $")
00010 
00011 #include "orbsvcs/Notify/Property.h"
00012 #include "orbsvcs/Notify/Notify_Extensions.h"
00013 
00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 TAO_Notify_QoSProperties::TAO_Notify_QoSProperties (void)
00017   : event_reliability_(CosNotification::EventReliability)
00018   , connection_reliability_(CosNotification::ConnectionReliability)
00019   , priority_ (CosNotification::Priority)
00020   , timeout_ (CosNotification::Timeout)
00021   , stop_time_supported_ (CosNotification::StopTimeSupported)
00022   , maximum_batch_size_ (CosNotification::MaximumBatchSize)
00023   , pacing_interval_ (CosNotification::PacingInterval)
00024   , max_events_per_consumer_ (CosNotification::MaxEventsPerConsumer)
00025   , discard_policy_ (CosNotification::DiscardPolicy)
00026   , order_policy_ (CosNotification::OrderPolicy)
00027   , thread_pool_ (NotifyExt::ThreadPool)
00028   , thread_pool_lane_ (NotifyExt::ThreadPoolLanes)
00029   , blocking_policy_(TAO_Notify_Extensions::BlockingPolicy)
00030 {
00031   unsupported_[0] = CosNotification::StartTimeSupported;
00032 }
00033 
00034 TAO_Notify_QoSProperties::~TAO_Notify_QoSProperties ()
00035 {
00036 }
00037 
00038 int
00039 TAO_Notify_QoSProperties::unsupported (ACE_CString& name)
00040 {
00041   for (int i = 0; i < UNSUPPORTED_PROPERTY_COUNT; ++i)
00042     {
00043       if (this->unsupported_[i] == name)
00044         return 1;
00045     }
00046 
00047   return 0;
00048 }
00049 void
00050 TAO_Notify_QoSProperties::init ()
00051 {
00052   if (this->event_reliability_.is_valid())
00053   {
00054     CORBA::Any a;
00055     a <<= this->event_reliability_.value();
00056     this->add(this->event_reliability_.name(), a);
00057   }
00058   if (this->connection_reliability_.is_valid())
00059   {
00060     CORBA::Any a;
00061     a <<= this->connection_reliability_.value();
00062     this->add(this->connection_reliability_.name(), a);
00063   }
00064   if (this->priority_.is_valid())
00065   {
00066     CORBA::Any a;
00067     a <<= this->priority_.value();
00068     this->add(this->priority_.name(), a);
00069   }
00070   if (this->timeout_.is_valid())
00071   {
00072     CORBA::Any a;
00073     a <<= this->timeout_.value();
00074     this->add(this->timeout_.name(), a);
00075   }
00076   if (this->stop_time_supported_.is_valid())
00077   {
00078     CORBA::Any a;
00079     a <<= CORBA::Any::from_boolean (this->stop_time_supported_.value());
00080     this->add(this->stop_time_supported_.name(), a);
00081   }
00082   if (this->maximum_batch_size_.is_valid())
00083   {
00084     CORBA::Any a;
00085     a <<= this->maximum_batch_size_.value();
00086     this->add(this->maximum_batch_size_.name(), a);
00087   }
00088   if (this->pacing_interval_.is_valid())
00089   {
00090     CORBA::Any a;
00091     a <<= this->pacing_interval_.value();
00092     this->add(this->pacing_interval_.name(), a);
00093   }
00094   if (this->max_events_per_consumer_.is_valid())
00095   {
00096     CORBA::Any a;
00097     a <<= this->max_events_per_consumer_.value();
00098     this->add(this->max_events_per_consumer_.name(), a);
00099   }
00100   if (this->discard_policy_.is_valid())
00101   {
00102     CORBA::Any a;
00103     a <<= this->discard_policy_.value();
00104     this->add(this->discard_policy_.name(), a);
00105   }
00106   if (this->order_policy_.is_valid())
00107   {
00108     CORBA::Any a;
00109     a <<= this->order_policy_.value();
00110     this->add(this->order_policy_.name(), a);
00111   }
00112 
00113   if (this->thread_pool_.is_valid())
00114   {
00115     CORBA::Any a;
00116     a <<= this->thread_pool_.value();
00117     this->add(this->thread_pool_.name(), a);
00118   }
00119   if (this->thread_pool_lane_.is_valid())
00120   {
00121     CORBA::Any a;
00122     a <<= this->thread_pool_lane_.value();
00123     this->add(this->thread_pool_lane_.name(), a);
00124   }
00125   if (this->blocking_policy_.is_valid())
00126   {
00127     CORBA::Any a;
00128     a <<= this->blocking_policy_.value();
00129     this->add(this->blocking_policy_.name(), a);
00130   }
00131 }
00132 
00133 int
00134 TAO_Notify_QoSProperties::init (const CosNotification::PropertySeq& prop_seq, CosNotification::PropertyErrorSeq& err_seq)
00135 {
00136   int err_index = -1;
00137 
00138   ACE_CString name;
00139   for (CORBA::ULong i = 0; i < prop_seq.length (); ++i)
00140     {
00141       name = prop_seq[i].name.in();
00142 
00143       if (this->unsupported (name))
00144         {
00145           err_index =  err_seq.length ();
00146           err_seq.length (err_seq.length () + 1);
00147 
00148           err_seq[err_index].code = CosNotification::UNSUPPORTED_PROPERTY;
00149           err_seq[err_index].name = CORBA::string_dup (prop_seq[i].name);
00150         }
00151       else if (this->property_map_.rebind (prop_seq[i].name.in (), prop_seq[i].value) == -1)
00152         return -1;
00153       // Note call to rebind. This allows to call <init> to set updates.
00154     }
00155 
00156   if (prop_seq.length () > 0)
00157     {
00158         this->event_reliability_.set (*this);
00159         this->connection_reliability_.set (*this);
00160         this->priority_.set (*this);
00161         this->timeout_.set (*this);
00162         this->stop_time_supported_.set (*this);
00163         this->maximum_batch_size_.set (*this);
00164         this->pacing_interval_.set (*this);
00165         this->max_events_per_consumer_.set (*this);
00166         this->discard_policy_.set (*this);
00167         this->order_policy_.set (*this);
00168 
00169         this->thread_pool_.set (*this);
00170         this->thread_pool_lane_.set (*this);
00171         this->blocking_policy_.set (*this);
00172   }
00173 
00174   return err_index == -1 ? 0 : 1;
00175 }
00176 
00177 int
00178 TAO_Notify_QoSProperties::copy (TAO_Notify_QoSProperties& qos_properties)
00179 {
00180   qos_properties.event_reliability_ = this->event_reliability_;
00181   qos_properties.connection_reliability_ = this->connection_reliability_;
00182   qos_properties.priority_ = this->priority_;
00183   qos_properties.timeout_ = this->timeout_;
00184   qos_properties.stop_time_supported_ = this->stop_time_supported_;
00185   qos_properties.maximum_batch_size_ = this->maximum_batch_size_;
00186   qos_properties.pacing_interval_ = this->pacing_interval_;
00187   qos_properties.max_events_per_consumer_ = this->max_events_per_consumer_;
00188   qos_properties.discard_policy_ = this->discard_policy_;
00189   qos_properties.order_policy_ = this->order_policy_;
00190 
00191   qos_properties.blocking_policy_ = this->blocking_policy_;
00192 
00193   PROPERTY_MAP::ITERATOR iter (this->property_map_);
00194   PROPERTY_MAP::ENTRY *entry;
00195 
00196   for (; iter.next (entry); iter.advance ())
00197     {
00198       if (qos_properties.property_map_.rebind (entry->ext_id_, entry->int_id_) == -1)
00199         return -1;
00200     }
00201 
00202   return 0;
00203 }
00204 
00205 int
00206 TAO_Notify_QoSProperties::transfer (TAO_Notify_QoSProperties& qos_properties)
00207 {
00208   if (this->copy (qos_properties) == -1)
00209     return -1;
00210 
00211   // unbind the properties that we don't want to transfer.
00212   qos_properties.property_map_.unbind (NotifyExt::ThreadPool);
00213   qos_properties.property_map_.unbind (NotifyExt::ThreadPoolLanes);
00214 
00215   return 0;
00216 }
00217 
00218 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7