Go to the documentation of this file.00001
00002
00003
00004
00005 #include "tao/Strategies/COIOP_Endpoint.h"
00006
00007 #if defined (TAO_HAS_COIOP) && (TAO_HAS_COIOP != 0)
00008
00009 #include "tao/Strategies/COIOP_Connection_Handler.h"
00010 #include "tao/debug.h"
00011 #include "tao/ORB_Constants.h"
00012
00013 #include "ace/OS_NS_stdio.h"
00014 #include "ace/OS_NS_string.h"
00015
00016 ACE_RCSID (Strategies,
00017 COIOP_Endpoint,
00018 "$Id: COIOP_Endpoint.cpp 74533 2006-09-26 11:59:32Z johnnyw $")
00019
00020
00021 #if !defined (__ACE_INLINE__)
00022 # include "tao/Strategies/COIOP_Endpoint.inl"
00023 #endif
00024
00025 #include "ace/os_include/os_netdb.h"
00026
00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029 TAO_COIOP_Endpoint::TAO_COIOP_Endpoint (const ACE_Utils::UUID& uuid)
00030 : TAO_Endpoint (TAO_TAG_COIOP_PROFILE)
00031 , uuid_ (uuid)
00032 , next_ (0)
00033 {
00034 }
00035
00036 TAO_COIOP_Endpoint::TAO_COIOP_Endpoint (void)
00037 : TAO_Endpoint (TAO_TAG_COIOP_PROFILE),
00038 uuid_ (),
00039 next_ (0)
00040 {
00041 }
00042
00043 TAO_COIOP_Endpoint::~TAO_COIOP_Endpoint (void)
00044 {
00045
00046 }
00047
00048 int
00049 TAO_COIOP_Endpoint::addr_to_string (char *buffer, size_t length)
00050 {
00051 const ACE_CString *str = uuid_.to_string ();
00052 size_t const actual_len =
00053 str->length ();
00054
00055 if (length < actual_len)
00056 return -1;
00057
00058 ACE_OS::sprintf (buffer, "%s",
00059 str->c_str());
00060
00061 return 0;
00062 }
00063
00064 TAO_Endpoint *
00065 TAO_COIOP_Endpoint::next (void)
00066 {
00067 return 0;
00068 }
00069
00070 TAO_Endpoint *
00071 TAO_COIOP_Endpoint::duplicate (void)
00072 {
00073 TAO_COIOP_Endpoint *endpoint = 0;
00074
00075 ACE_NEW_RETURN (endpoint,
00076 TAO_COIOP_Endpoint (this->uuid_),
00077 0);
00078
00079 return endpoint;
00080 }
00081
00082 CORBA::Boolean
00083 TAO_COIOP_Endpoint::is_equivalent (const TAO_Endpoint *other_endpoint)
00084 {
00085 TAO_Endpoint *endpt = const_cast<TAO_Endpoint *> (other_endpoint);
00086
00087 TAO_COIOP_Endpoint *endpoint = dynamic_cast<TAO_COIOP_Endpoint *> (endpt);
00088 if (endpoint == 0)
00089 return false;
00090
00091 return (this->uuid_ == endpoint->uuid_);
00092 }
00093
00094 CORBA::ULong
00095 TAO_COIOP_Endpoint::hash (void)
00096 {
00097 if (this->hash_val_ != 0)
00098 return this->hash_val_;
00099
00100 {
00101 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00102 guard,
00103 this->addr_lookup_lock_,
00104 this->hash_val_);
00105
00106 if (this->hash_val_ != 0)
00107 return this->hash_val_;
00108
00109 const ACE_CString *stringval = this->uuid_.to_string ();
00110 this->hash_val_ =
00111 stringval->hash ();
00112 }
00113
00114 return this->hash_val_;
00115 }
00116
00117 TAO_END_VERSIONED_NAMESPACE_DECL
00118
00119 #endif