SupplierAdmin.cpp

Go to the documentation of this file.
00001 // $Id: SupplierAdmin.cpp 79084 2007-07-30 13:13:45Z elliott_c $
00002 
00003 #include "orbsvcs/Notify/SupplierAdmin.h"
00004 
00005 ACE_RCSID (RT_Notify,
00006            TAO_Notify_SupplierAdmin,
00007            "$Id: SupplierAdmin.cpp 79084 2007-07-30 13:13:45Z elliott_c $")
00008 
00009 #include "orbsvcs/Notify/Builder.h"
00010 #include "orbsvcs/Notify/ProxyConsumer.h"
00011 #include "orbsvcs/Notify/EventChannel.h"
00012 #include "orbsvcs/Notify/Subscription_Change_Worker.h"
00013 #include "orbsvcs/Notify/Find_Worker_T.h"
00014 #include "orbsvcs/Notify/Seq_Worker_T.h"
00015 #include "orbsvcs/Notify/Properties.h"
00016 
00017 #include "tao/debug.h"
00018 
00019 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00020 
00021 //#define DEBUG_LEVEL 9
00022 #ifndef DEBUG_LEVEL
00023 # define DEBUG_LEVEL TAO_debug_level
00024 #endif //DEBUG_LEVEL
00025 
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 typedef TAO_Notify_Find_Worker_T<TAO_Notify_Proxy
00029                                  , CosNotifyChannelAdmin::ProxyConsumer
00030                                  , CosNotifyChannelAdmin::ProxyConsumer_ptr
00031                                  , CosNotifyChannelAdmin::ProxyNotFound>
00032 TAO_Notify_ProxyConsumer_Find_Worker;
00033 
00034 typedef TAO_Notify_Seq_Worker_T<TAO_Notify_Proxy> TAO_Notify_Proxy_Seq_Worker;
00035 
00036 TAO_Notify_SupplierAdmin::TAO_Notify_SupplierAdmin (void)
00037   : TAO_Notify_Admin ()
00038 {
00039 }
00040 
00041 const char *
00042 TAO_Notify_SupplierAdmin::get_admin_type_name () const
00043 {
00044   return "supplier_admin";
00045 }
00046 
00047 TAO_Notify_SupplierAdmin::~TAO_Notify_SupplierAdmin ()
00048 {
00049 }
00050 
00051 void
00052 TAO_Notify_SupplierAdmin::init (TAO_Notify_EventChannel *ec)
00053 {
00054   TAO_Notify_Admin::init (ec);
00055 
00056   const CosNotification::QoSProperties &default_sa_qos =
00057     TAO_Notify_PROPERTIES::instance ()->default_supplier_admin_qos_properties ();
00058 
00059   this->set_qos (default_sa_qos);
00060 }
00061 
00062 void
00063 TAO_Notify_SupplierAdmin::_add_ref (void)
00064 {
00065   this->_incr_refcnt ();
00066 }
00067 
00068 void
00069 TAO_Notify_SupplierAdmin::_remove_ref (void)
00070 {
00071   this->_decr_refcnt ();
00072 }
00073 
00074 void
00075 TAO_Notify_SupplierAdmin::release (void)
00076 {
00077   delete this;
00078   //@@ inform factory
00079 }
00080 
00081 void
00082 TAO_Notify_SupplierAdmin::destroy (void)
00083 {
00084   this->shutdown ();
00085   this->ec_->remove (this);
00086   this->proxy_container ().destroy ();
00087 }
00088 
00089 TAO_Notify::Topology_Object*
00090 TAO_Notify_SupplierAdmin::load_child (const ACE_CString &type,
00091   CORBA::Long id, const TAO_Notify::NVPList& attrs)
00092 {
00093   TAO_Notify::Topology_Object* result = this;
00094   if (type == "proxy_push_consumer")
00095   {
00096     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00097       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00098       , static_cast<int> (id)
00099       ));
00100     result = this->load_proxy(id, CosNotifyChannelAdmin::ANY_EVENT, attrs);
00101   }
00102   else if (type == "structured_proxy_push_consumer")
00103   {
00104     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00105       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00106       , static_cast<int> (id)
00107       ));
00108     result = this->load_proxy(id, CosNotifyChannelAdmin::STRUCTURED_EVENT, attrs);
00109   }
00110   else if (type == "sequence_proxy_push_consumer")
00111   {
00112     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00113       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00114       , static_cast<int> (id)
00115       ));
00116     result = this->load_proxy(id, CosNotifyChannelAdmin::SEQUENCE_EVENT, attrs);
00117   }
00118   else
00119   {
00120     result = TAO_Notify_Admin::load_child (type, id, attrs);
00121   }
00122   return result;
00123 }
00124 
00125 TAO_Notify::Topology_Object*
00126 TAO_Notify_SupplierAdmin::load_proxy (
00127   CORBA::Long id,
00128   CosNotifyChannelAdmin::ClientType ctype,
00129   const TAO_Notify::NVPList& attrs)
00130 {
00131   TAO_Notify_Builder* bld = TAO_Notify_PROPERTIES::instance()->builder();
00132   TAO_Notify_ProxyConsumer * proxy =
00133     bld->build_proxy (this
00134                , ctype
00135                , id);
00136   ACE_ASSERT(proxy != 0);
00137   proxy->load_attrs (attrs);
00138   return proxy;
00139 }
00140 
00141 
00142 void
00143 TAO_Notify_SupplierAdmin::set_qos (const CosNotification::QoSProperties & qos)
00144 {
00145   this->TAO_Notify_Object::set_qos (qos);
00146 }
00147 
00148 CosNotification::QoSProperties*
00149 TAO_Notify_SupplierAdmin::get_qos (void)
00150 {
00151   return this->TAO_Notify_Object::get_qos ();
00152 }
00153 
00154 CosNotifyChannelAdmin::ProxyConsumer_ptr
00155 TAO_Notify_SupplierAdmin::obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype
00156                                                          , CosNotifyChannelAdmin::ProxyID_out proxy_id)
00157 
00158 {
00159   CosNotification::QoSProperties initial_qos;
00160 
00161   CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00162     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00163                                                                 , ctype
00164                                                                 , proxy_id
00165                                                                 , initial_qos);
00166   this->self_change ();
00167   return proxy._retn ();
00168 }
00169 
00170 CosNotifyChannelAdmin::ProxyConsumer_ptr
00171 TAO_Notify_SupplierAdmin::obtain_notification_push_consumer_with_qos (CosNotifyChannelAdmin::ClientType ctype,
00172                                                                   CosNotifyChannelAdmin::ProxyID_out proxy_id,
00173                                                                   const CosNotification::QoSProperties & initial_qos
00174                                                                   )
00175 {
00176   CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00177     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00178                                                                 , ctype
00179                                                                 , proxy_id,
00180                                                                 initial_qos);
00181   this->self_change ();
00182   return proxy._retn ();
00183 }
00184 
00185 
00186 CosEventChannelAdmin::ProxyPushConsumer_ptr
00187 TAO_Notify_SupplierAdmin::obtain_push_consumer (void)
00188 {
00189   CosEventChannelAdmin::ProxyPushConsumer_var proxy =
00190     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this);
00191   this->self_change ();
00192   return proxy._retn ();
00193 }
00194 
00195 CosNotifyChannelAdmin::AdminID
00196 TAO_Notify_SupplierAdmin::MyID (void)
00197 {
00198   return this->id ();
00199 }
00200 
00201 CosNotifyChannelAdmin::EventChannel_ptr
00202 TAO_Notify_SupplierAdmin::MyChannel (void)
00203 {
00204   return this->ec_->_this ();
00205 }
00206 
00207 ::CosNotifyChannelAdmin::InterFilterGroupOperator
00208 TAO_Notify_SupplierAdmin::MyOperator (void)
00209 {
00210   return this->filter_operator_;
00211 }
00212 
00213 CosNotifyChannelAdmin::ProxyIDSeq*
00214 TAO_Notify_SupplierAdmin::push_consumers (void)
00215 {
00216   TAO_Notify_Proxy_Seq_Worker seq_worker;
00217 
00218   return seq_worker.create (this->proxy_container());
00219 }
00220 
00221 CosNotifyChannelAdmin::ProxyConsumer_ptr
00222 TAO_Notify_SupplierAdmin::get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id)
00223 {
00224   TAO_Notify_ProxyConsumer_Find_Worker find_worker;
00225 
00226   return find_worker.resolve (proxy_id, this->proxy_container());
00227 }
00228 
00229 void
00230 TAO_Notify_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & added,
00231                                     const CosNotification::EventTypeSeq & removed
00232                                     )
00233 
00234 {
00235   TAO_Notify_EventTypeSeq seq_added (added);
00236   TAO_Notify_EventTypeSeq seq_removed (removed);
00237 
00238   {
00239     ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00240                         CORBA::INTERNAL ());
00241 
00242     this->subscribed_types_.add_and_remove (seq_added, seq_removed);
00243 
00244     TAO_Notify_Subscription_Change_Worker worker (added, removed);
00245 
00246     this->proxy_container().collection ()->for_each (&worker);
00247   }
00248 }
00249 
00250 CosNotifyFilter::FilterID
00251 TAO_Notify_SupplierAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter)
00252 {
00253   CosNotifyFilter::FilterID fid =
00254     this->filter_admin_.add_filter (new_filter);
00255   this->self_change ();
00256   return fid;
00257 }
00258 
00259 void
00260 TAO_Notify_SupplierAdmin::remove_filter (CosNotifyFilter::FilterID filter)
00261 {
00262   this->filter_admin_.remove_filter (filter);
00263 }
00264 
00265 ::CosNotifyFilter::Filter_ptr
00266 TAO_Notify_SupplierAdmin::get_filter (CosNotifyFilter::FilterID filter)
00267 {
00268   return this->filter_admin_.get_filter (filter);
00269 }
00270 
00271 ::CosNotifyFilter::FilterIDSeq*
00272 TAO_Notify_SupplierAdmin::get_all_filters (void)
00273 {
00274   return this->filter_admin_.get_all_filters ();
00275 }
00276 
00277 void
00278 TAO_Notify_SupplierAdmin::remove_all_filters (void)
00279 {
00280   this->filter_admin_.remove_all_filters ();
00281 }
00282 
00283 /************** UNIMPLEMENTED METHODS ***************/
00284 
00285 CosEventChannelAdmin::ProxyPullConsumer_ptr
00286 TAO_Notify_SupplierAdmin::obtain_pull_consumer (void)
00287 {
00288   throw CORBA::NO_IMPLEMENT ();
00289 }
00290 
00291 CosNotifyChannelAdmin::ProxyIDSeq*
00292 TAO_Notify_SupplierAdmin::pull_consumers (void)
00293 {
00294   throw CORBA::NO_IMPLEMENT ();
00295 }
00296 
00297 
00298 void
00299 TAO_Notify_SupplierAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/,
00300                                     CosNotification::NamedPropertyRangeSeq_out /*available_qos*/)
00301 {
00302   throw CORBA::NO_IMPLEMENT ();
00303 }
00304 
00305 CosNotifyChannelAdmin::ProxyConsumer_ptr
00306 TAO_Notify_SupplierAdmin::obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType /*ctype*/,
00307                                                          CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/)
00308 {
00309   throw CORBA::NO_IMPLEMENT ();
00310 }
00311 
00312 TAO_Notify_ProxyConsumer *
00313 TAO_Notify_SupplierAdmin::find_proxy_consumer (
00314     TAO_Notify::IdVec & id_path,
00315     size_t position)
00316 {
00317   TAO_Notify_ProxyConsumer * result = 0;
00318   size_t path_size = id_path.size ();
00319   if (position < path_size)
00320   {
00321     TAO_Notify_ProxyConsumer_Find_Worker find_worker;
00322     TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container());
00323     result = dynamic_cast <TAO_Notify_ProxyConsumer *> (proxy);
00324   }
00325   return result;
00326 }
00327 
00328 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 15:40:01 2008 for TAO_CosNotification by doxygen 1.3.6