00001 // $Id: RT_Transport_Descriptor.cpp 77409 2007-02-26 23:48:49Z ossama $ 00002 00003 #include "tao/RTCORBA/RT_Transport_Descriptor.h" 00004 #include "ace/OS_Memory.h" 00005 00006 #if ! defined (__ACE_INLINE__) 00007 #include "tao/RTCORBA/RT_Transport_Descriptor.inl" 00008 #endif /* __ACE_INLINE__ */ 00009 00010 ACE_RCSID(RTCORBA, TAO_RT_Transport_Descriptor, "$Id: RT_Transport_Descriptor.cpp 77409 2007-02-26 23:48:49Z ossama $") 00011 00012 #include "tao/RTCORBA/RT_Transport_Descriptor_Property.h" 00013 #include "tao/Endpoint.h" 00014 00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00016 00017 TAO_RT_Transport_Descriptor::~TAO_RT_Transport_Descriptor () 00018 { 00019 if (this->delete_properties_ == 1) 00020 { 00021 TAO_RT_Transport_Descriptor_Property *current = 00022 this->property_list_; 00023 00024 while (current) 00025 { 00026 TAO_RT_Transport_Descriptor_Property *next = 00027 current->next_; 00028 00029 delete current; 00030 00031 current = next; 00032 } 00033 } 00034 } 00035 00036 TAO_Transport_Descriptor_Interface * 00037 TAO_RT_Transport_Descriptor::duplicate (void) 00038 { 00039 // Get a copy of the underlying endpoint 00040 TAO_Endpoint *endpoint = 00041 this->endpoint_->duplicate (); 00042 if (endpoint == 0) 00043 return 0; 00044 00045 TAO_RT_Transport_Descriptor *new_descriptor = 0; 00046 00047 ACE_NEW_RETURN (new_descriptor, 00048 TAO_RT_Transport_Descriptor (endpoint, 1), 00049 0); 00050 00051 // Copy the Properties. 00052 TAO_RT_Transport_Descriptor_Property *current_property = 00053 this->property_list_; 00054 00055 TAO_RT_Transport_Descriptor_Property *current_new_property = 0; 00056 TAO_RT_Transport_Descriptor_Property *new_property = 0; 00057 00058 while (current_property) 00059 { 00060 new_property = 00061 current_property->duplicate (); 00062 00063 // Note that we cannot use <insert> because that will reverse the stack. 00064 if (new_descriptor->property_list_ == 0) 00065 new_descriptor->property_list_ = new_property; 00066 else if (current_new_property != 0) 00067 current_new_property->next_ = new_property; 00068 00069 current_new_property = new_property; 00070 current_property = current_property->next_; 00071 } 00072 00073 return new_descriptor; 00074 } 00075 00076 CORBA::Boolean 00077 TAO_RT_Transport_Descriptor::is_equivalent (const TAO_Transport_Descriptor_Interface *other_prop) 00078 { 00079 const TAO_RT_Transport_Descriptor *rhs = 00080 dynamic_cast<const TAO_RT_Transport_Descriptor*> (other_prop); 00081 00082 if (rhs == 0) 00083 return false; 00084 00085 // Check if endpoint is equivalent. 00086 if (this->endpoint_->is_equivalent (rhs->endpoint_) == 0) 00087 return false; 00088 00089 // Check the property_list_. 00090 TAO_RT_Transport_Descriptor_Property *current = 00091 this->property_list_; 00092 00093 TAO_RT_Transport_Descriptor_Property *rhs_current = 00094 rhs->property_list_; 00095 00096 while (current || rhs_current) 00097 { 00098 if (rhs_current == 0 || current == 0) 00099 return false; 00100 00101 if (current->is_equivalent (rhs_current) == 0) 00102 return false; 00103 00104 current = current->next_; 00105 rhs_current = rhs_current->next_; 00106 } 00107 00108 return true; 00109 } 00110 00111 u_long 00112 TAO_RT_Transport_Descriptor::hash (void) const 00113 { 00114 return this->endpoint_->hash (); 00115 } 00116 00117 TAO_END_VERSIONED_NAMESPACE_DECL