Topology_Object.cpp

Go to the documentation of this file.
00001 // Topology_Object.cpp,v 1.18 2006/03/14 06:14:34 jtc Exp
00002 
00003 #include "orbsvcs/Notify/Topology_Object.h"
00004 
00005 #if ! defined (__ACE_INLINE__)
00006 #include "orbsvcs/Notify/Topology_Object.inl"
00007 #endif /* __ACE_INLINE__ */
00008 
00009 // question: is there a race_conditon with self_changed and children_changed?
00010 // answer: toplogy_changed and/or children_changed must be set after the change is
00011 // made, and before the call to child_change.
00012 // self_changed and children_changed must be cleared before this object and its
00013 // children have been saved in Topology_Object::save_persistent ().
00014 // If these rules are followed, the only risk is a (harmless) extra save.
00015 
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 namespace TAO_Notify
00019 {
00020   Topology_Savable::~Topology_Savable (void)
00021   {
00022   }
00023 
00024   void
00025   Topology_Savable::reconnect (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00026   {
00027   }
00028 
00029   Topology_Object::Topology_Object ()
00030     : TAO_Notify_Object ()
00031     , Topology_Savable ()
00032     , self_changed_ (false)
00033     , children_changed_ (false)
00034     , topology_parent_ (0)
00035   {
00036   }
00037 
00038   Topology_Object::~Topology_Object ()
00039   {
00040   }
00041 
00042   void
00043   Topology_Object::initialize (Topology_Parent* topology_parent ACE_ENV_ARG_DECL_NOT_USED)
00044   {
00045     ACE_ASSERT (topology_parent != 0 && this->topology_parent_ == 0);
00046     this->topology_parent_ = topology_parent;
00047     TAO_Notify_Object::initialize (topology_parent);
00048   }
00049 
00050   Topology_Parent *
00051   Topology_Object::topology_parent () const
00052   {
00053     return this->topology_parent_;
00054   }
00055 
00056 
00057   Topology_Object *
00058   Topology_Object::load_child (const ACE_CString & /*type*/,
00059     CORBA::Long /* id */,
00060     const NVPList& /* attrs */
00061     ACE_ENV_ARG_DECL_NOT_USED)
00062   {
00063     return 0;
00064   }
00065 
00066   bool
00067   Topology_Object::is_persistent () const
00068   {
00069     bool result = false;
00070     if (this->qos_properties_.event_reliability().is_valid ())
00071     {
00072       result = CosNotification::Persistent == this->qos_properties_.event_reliability().value ();
00073     }
00074     else if (this->topology_parent () != 0)
00075     {
00076       result = this->topology_parent ()->is_persistent ();
00077     }
00078     return result;
00079   }
00080 
00081   bool
00082   Topology_Object::self_change (ACE_ENV_SINGLE_ARG_DECL)
00083   {
00084     this->self_changed_ = true;
00085     return send_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00086   }
00087 
00088   bool
00089   Topology_Object::send_change (ACE_ENV_SINGLE_ARG_DECL)
00090   {
00091     bool saving = false;
00092     if (is_persistent ())
00093     {
00094       while (this->self_changed_ || this->children_changed_)
00095       {
00096         saving = this->change_to_parent (ACE_ENV_SINGLE_ARG_PARAMETER);
00097         ACE_CHECK_RETURN (false);
00098         if (!saving)
00099         {
00100           this->self_changed_ = false;
00101           this->children_changed_ = false;
00102         }
00103       }
00104     }
00105     else
00106     {
00107       this->self_changed_ = false;
00108       this->children_changed_ = false;
00109     }
00110     return saving;
00111   }
00112 
00113   bool
00114   Topology_Object::change_to_parent (ACE_ENV_SINGLE_ARG_DECL)
00115   {
00116     bool result = false;
00117     Topology_Parent * parent = this->topology_parent();
00118     if (parent != 0)
00119     {
00120       result = parent->child_change(ACE_ENV_SINGLE_ARG_PARAMETER);
00121       ACE_CHECK_RETURN (false);
00122     }
00123     return result;
00124   }
00125 
00126   void
00127   Topology_Object::get_id_path (TAO_Notify::IdVec & id_path) const
00128   {
00129     if (this->topology_parent() != 0)
00130     {
00131       this->topology_parent()->get_id_path (id_path);
00132     }
00133     id_path.push_back (this->get_id ());
00134   }
00135 
00136   TAO_Notify_Object::ID
00137   Topology_Object::get_id () const
00138   {
00139     // If this assert triggers then implement the
00140     // get_id method in the actual class
00141     // derived from Topology_Object
00142     // or else figure out why this method was called
00143     // on an object that doesn't have an id.
00144     ACE_ASSERT (false);
00145     // if it is called in a release build, provide 'em a value
00146     return -1;
00147   }
00148 
00149 } // namespace TAO_Notify
00150 
00151 TAO_END_VERSIONED_NAMESPACE_DECL

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