Proxy.cpp

Go to the documentation of this file.
00001 // Proxy.cpp,v 1.19 2006/03/14 06:14:34 jtc Exp
00002 
00003 #include "orbsvcs/Notify/Proxy.h"
00004 
00005 #if ! defined (__ACE_INLINE__)
00006 #include "orbsvcs/Notify/Proxy.inl"
00007 #endif /* __ACE_INLINE__ */
00008 
00009 ACE_RCSID(Notify, TAO_Notify_Proxy, "Proxy.cpp,v 1.19 2006/03/14 06:14:34 jtc Exp")
00010 
00011 #include "orbsvcs/Notify/Peer.h"
00012 #include "orbsvcs/Notify/Proxy.h"
00013 #include "orbsvcs/Notify/Method_Request_Updates.h"
00014 #include "orbsvcs/Notify/Worker_Task.h"
00015 #include "orbsvcs/Notify/Properties.h"
00016 #include "orbsvcs/Notify/POA_Helper.h"
00017 #include "orbsvcs/Notify/Topology_Saver.h"
00018 
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020 
00021 TAO_Notify_Proxy::TAO_Notify_Proxy (void)
00022   : updates_off_ (0)
00023 {
00024 }
00025 
00026 TAO_Notify_Proxy::~TAO_Notify_Proxy ()
00027 {
00028 }
00029 
00030 CORBA::Object_ptr
00031 TAO_Notify_Proxy::activate (PortableServer::Servant servant ACE_ENV_ARG_DECL)
00032 {
00033   // Set the POA that we use to return our <ref>
00034   this->set_primary_as_proxy_poa();
00035   return TAO_Notify_Object::activate (servant ACE_ENV_ARG_PARAMETER);
00036 }
00037 
00038 CORBA::Object_ptr
00039 TAO_Notify_Proxy::activate (PortableServer::Servant servant,
00040                             CORBA::Long id
00041                             ACE_ENV_ARG_DECL)
00042 {
00043   // Set the POA that we use to return our <ref>
00044   this->set_primary_as_proxy_poa();
00045   return TAO_Notify_Object::activate (servant, id ACE_ENV_ARG_PARAMETER);
00046 }
00047 
00048 void
00049 TAO_Notify_Proxy::deactivate (ACE_ENV_SINGLE_ARG_DECL)
00050 {
00051   ACE_ASSERT (this->proxy_poa() != 0 );
00052   this->proxy_poa()->deactivate (this->id() ACE_ENV_ARG_PARAMETER);
00053 }
00054 
00055 void
00056 TAO_Notify_Proxy::subscribed_types (TAO_Notify_EventTypeSeq& subscribed_types ACE_ENV_ARG_DECL)
00057 {
00058   ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00059                         CORBA::INTERNAL ());
00060   ACE_CHECK;
00061 
00062   // copy
00063   subscribed_types = this->subscribed_types_;
00064 }
00065 
00066 void
00067 TAO_Notify_Proxy::types_changed (const TAO_Notify_EventTypeSeq& added, const TAO_Notify_EventTypeSeq& removed ACE_ENV_ARG_DECL)
00068 {
00069   // return if the updates for this proxy are turned off or
00070   // if all the updates in the channel are switched off.
00071   if (this->updates_off_ == 1 || TAO_Notify_PROPERTIES::instance()->updates () == 0)
00072     return;
00073 
00074   TAO_Notify_Method_Request_Updates_No_Copy request (added, removed, this);
00075 
00076   if (TAO_Notify_PROPERTIES::instance()->asynch_updates () == 1) // if we should send the updates synchronously.
00077     {
00078       this->execute_task (request ACE_ENV_ARG_PARAMETER);
00079       ACE_CHECK;
00080     }
00081   else // execute in the current thread context.
00082     {
00083       request.execute (ACE_ENV_SINGLE_ARG_PARAMETER);
00084       ACE_CHECK;
00085     }
00086 }
00087 
00088 CosNotification::EventTypeSeq*
00089 TAO_Notify_Proxy::obtain_types (CosNotifyChannelAdmin::ObtainInfoMode mode, const TAO_Notify_EventTypeSeq& types ACE_ENV_ARG_DECL)
00090   ACE_THROW_SPEC ((
00091                    CORBA::SystemException
00092                    ))
00093 {
00094   CosNotification::EventTypeSeq_var event_type_seq;
00095 
00096   ACE_NEW_THROW_EX (event_type_seq,
00097                     CosNotification::EventTypeSeq (),
00098                     CORBA::NO_MEMORY ());
00099 
00100   ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ());
00101   ACE_CHECK_RETURN (event_type_seq._retn ());
00102 
00103   if (mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_OFF ||
00104       mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_ON)
00105     {
00106       types.populate (event_type_seq);
00107     }
00108 
00109   if (mode == CosNotifyChannelAdmin::NONE_NOW_UPDATES_ON ||
00110       mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_ON)
00111     {
00112       this->updates_off_ = 0;
00113     }
00114   else
00115     {
00116       this->updates_off_ = 1;
00117     }
00118 
00119   return event_type_seq._retn ();
00120 }
00121 
00122 void
00123 TAO_Notify_Proxy::qos_changed (const TAO_Notify_QoSProperties& qos_properties)
00124 {
00125   //Inform Peers of qos changes.
00126   TAO_Notify_Peer* peer = this->peer ();
00127 
00128   if (peer != 0)
00129     peer->qos_changed (qos_properties);
00130 }
00131 
00132 void
00133 TAO_Notify_Proxy::save_persistent (TAO_Notify::Topology_Saver& saver ACE_ENV_ARG_DECL)
00134 {
00135   bool changed = this->children_changed_;
00136   this->children_changed_ = false;
00137   this->self_changed_ = false;
00138 
00139   if (is_persistent ())
00140   {
00141     TAO_Notify::NVPList attrs;
00142     this->save_attrs(attrs);
00143 
00144     const char * type_name = this->get_proxy_type_name ();
00145     bool want_all_children = saver.begin_object(this->id(), type_name, attrs, changed ACE_ENV_ARG_PARAMETER);
00146     ACE_CHECK;
00147 
00148     if (want_all_children || this->filter_admin_.is_changed ())
00149     {
00150       this->filter_admin_.save_persistent(saver ACE_ENV_ARG_PARAMETER);
00151       ACE_CHECK;
00152     }
00153 
00154     if (want_all_children || this->subscribed_types_.is_changed ())
00155     {
00156       this->subscribed_types_.save_persistent(saver ACE_ENV_ARG_PARAMETER);
00157       ACE_CHECK;
00158     }
00159 
00160     // todo: handle removed children
00161 
00162     saver.end_object(this->id(), type_name ACE_ENV_ARG_PARAMETER);
00163   }
00164 }
00165 
00166 void
00167 TAO_Notify_Proxy::save_attrs (TAO_Notify::NVPList& attrs)
00168 {
00169   TAO_Notify_Object::save_attrs(attrs);
00170   TAO_Notify_Peer * peer = this->peer();
00171   if (peer != 0)
00172   {
00173     attrs.push_back (TAO_Notify::NVP("PeerIOR", peer->get_ior()));
00174   }
00175 }
00176 
00177 TAO_Notify::Topology_Object*
00178 TAO_Notify_Proxy::load_child (const ACE_CString &type, CORBA::Long id,
00179   const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL)
00180 {
00181   ACE_UNUSED_ARG (id);
00182   ACE_UNUSED_ARG (attrs);
00183   TAO_Notify::Topology_Object* result = this;
00184   if (type == "subscriptions")
00185   {
00186     // since we initialized our subscribed types to everything
00187     // in the constructor. we have to clear it out first.
00188     this->subscribed_types_.reset();
00189     result = &this->subscribed_types_;
00190     ACE_CHECK_RETURN(0);
00191   }
00192   else if (type == "filter_admin")
00193   {
00194     result = & this->filter_admin_;
00195   }
00196   return result;
00197 }
00198 
00199 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:24:13 2006 for TAO_CosNotification by doxygen 1.3.6