Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / RTCORBA / RT_Transport_Descriptor.cpp
blob78c96423d38de58ef1f863b71ee52c72a22f5c7f
1 #include "tao/RTCORBA/RT_Transport_Descriptor.h"
2 #include "ace/OS_Memory.h"
4 #if ! defined (__ACE_INLINE__)
5 #include "tao/RTCORBA/RT_Transport_Descriptor.inl"
6 #endif /* __ACE_INLINE__ */
8 #include "tao/RTCORBA/RT_Transport_Descriptor_Property.h"
9 #include "tao/Endpoint.h"
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 TAO_RT_Transport_Descriptor::~TAO_RT_Transport_Descriptor ()
15 if (this->delete_properties_ == 1)
17 TAO_RT_Transport_Descriptor_Property *current =
18 this->property_list_;
20 while (current)
22 TAO_RT_Transport_Descriptor_Property *next =
23 current->next_;
25 delete current;
27 current = next;
32 TAO_Transport_Descriptor_Interface *
33 TAO_RT_Transport_Descriptor::duplicate ()
35 // Get a copy of the underlying endpoint
36 TAO_Endpoint *endpoint =
37 this->endpoint_->duplicate ();
38 if (endpoint == 0)
39 return 0;
41 TAO_RT_Transport_Descriptor *new_descriptor = 0;
43 ACE_NEW_RETURN (new_descriptor,
44 TAO_RT_Transport_Descriptor (endpoint, 1),
45 0);
47 // Copy the Properties.
48 TAO_RT_Transport_Descriptor_Property *current_property =
49 this->property_list_;
51 TAO_RT_Transport_Descriptor_Property *current_new_property = 0;
52 TAO_RT_Transport_Descriptor_Property *new_property = 0;
54 while (current_property)
56 new_property =
57 current_property->duplicate ();
59 // Note that we cannot use <insert> because that will reverse the stack.
60 if (new_descriptor->property_list_ == 0)
61 new_descriptor->property_list_ = new_property;
62 else if (current_new_property != 0)
63 current_new_property->next_ = new_property;
65 current_new_property = new_property;
66 current_property = current_property->next_;
69 return new_descriptor;
72 CORBA::Boolean
73 TAO_RT_Transport_Descriptor::is_equivalent (const TAO_Transport_Descriptor_Interface *other_prop)
75 const TAO_RT_Transport_Descriptor *rhs =
76 dynamic_cast<const TAO_RT_Transport_Descriptor*> (other_prop);
78 if (rhs == 0)
79 return false;
81 // Check if endpoint is equivalent.
82 if (this->endpoint_->is_equivalent (rhs->endpoint_) == 0)
83 return false;
85 // Check the property_list_.
86 TAO_RT_Transport_Descriptor_Property *current =
87 this->property_list_;
89 TAO_RT_Transport_Descriptor_Property *rhs_current =
90 rhs->property_list_;
92 while (current || rhs_current)
94 if (rhs_current == 0 || current == 0)
95 return false;
97 if (current->is_equivalent (rhs_current) == 0)
98 return false;
100 current = current->next_;
101 rhs_current = rhs_current->next_;
104 return true;
107 u_long
108 TAO_RT_Transport_Descriptor::hash () const
110 return this->endpoint_->hash ();
113 TAO_END_VERSIONED_NAMESPACE_DECL