diff options
57 files changed, 5025 insertions, 787 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 0ac36fc8031..b0955198c2b 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,115 @@ +Wed Sep 13 19:15:01 2000 Marina Spivak <marina@cs.wustl.edu> + + * tao/Endpoint.cpp + * tao/Endpoint.h + * tao/Endpoint.i + * tao/IIOP_Endpoint.cpp + * tao/IIOP_Endpoint.h + * tao/IIOP_Endpoint.i + * tao/SHMIOP_Endpoint.cpp + * tao/SHMIOP_Endpoint.h + * tao/SHMIOP_Endpoint.i + * tao/UIOP_Endpoint.cpp + * tao/UIOP_Endpoint.h + * tao/UIOP_Endpoint.i: + + Added a new interface, Endpoint, to the pluggable protocols + framework. Endpoint encapsulates addressing information of a + single acceptor endpoint. A Profile contains one or more + Endpoints. In other words, Endpoint represents a single server + contact point for a client. + + Some of the motivations for this change: + - smaller iors + - preparation for TAG_ALTERNATE_IIOP + support + - preparation for new connection cache scheme + - more organized iors => easier policy-based endpoint selection + + * tao/uiop_endpoints.pidl + * tao/iiop_endpoints.pidl + * tao/uiop_endpoints.h + * tao/uiop_endpoints.i + * tao/uiop_endpoints.cpp + * tao/iiop_endpoints.h + * tao/iiop_endpoints.i + * tao/iiop_endpoints.cpp: + + Pidl files above define data structures for representing a list + of endpoints from a single profile on the wire. Pidl files are + used to generate .h, .cpp and .i above. + + * tao/Invocation.h + * tao/Invocation.cpp + * tao/Pluggable.h + * tao/Profile.h + * tao/Profile.cpp + * tao/Profile.i + * tao/Stub.cpp + * tao/Acceptor_Registry.cpp + * tao/Acceptor_Registry.h + * tao/Connector_Registry.cpp + * tao/Connector_Registry.h + * tao/IIOP_Acceptor.h + * tao/IIOP_Acceptor.cpp + * tao/IIOP_Connector.h + * tao/IIOP_Connector.cpp + * tao/IIOP_Profile.h + * tao/IIOP_Profile.cpp + * tao/IIOP_Profile.i + * tao/UIOP_Acceptor.h + * tao/UIOP_Acceptor.cpp + * tao/UIOP_Connector.h + * tao/UIOP_Connector.cpp + * tao/UIOP_Profile.h + * tao/UIOP_Profile.cpp + * tao/UIOP_Profile.i + * tao/SHMIOP_Acceptor.h + * tao/SHMIOP_Acceptor.cpp + * tao/SHMIOP_Connector.h + * tao/SHMIOP_Connector.cpp + * tao/SHMIOP_Profile.h + * tao/SHMIOP_Profile.cpp + * tao/SHMIOP_Profile.i: + + Updated pp framework components to use new Endpoint component + described above. Main changes include: + - The way mprofiles are created. If TAO_HAS_RT_CORBA is not + enabled, there are no changes: one profile + is created for each server acceptor endpoint, i.e., an IOR + can contain multiple profiles for the same protocol. If + TAO_HAS_RT_CORBA _is_ enabled, only one profile per protocol is added + to the IOR. Multiple acceptor endpoints for a particular + protocol do not result in additional profiles being created, but + rather in Endpoint objects being added to that protocol's + profile. In other words, there is only one profile for each + protocol in an IOR. These changes are encapsulated in + <*_Acceptor::create_mprofile > method. + - TAO_Connector::connect now takes Endpoint* rather than Profile* as + one of its arguments + - TAO_Acceptor::is_collocated now takes Endpoint* rather than + Profile* as its argument + - TAO_Acceptor_Registry::is_collocated now searches for a + "collocation match" among all endpoints of all profiles + + * tao/Tagged_Components.h + * tao/Tagged_Components.i + * tao/Tagged_Components.cpp: + + Removed TAO-specific priority tagged component. It is no longer + necessary since each endpoint stores its priority. + + * tao/corbafwd.h + + Removed TAO_TAG_PRIORITY. Added TAO_TAG_ENDPOINTS. + + * tao/TAO.dsp + * tao/TAO_Static.dsp + * tao/Makefile + * tao/Makefile.bor: + + Updated. + Wed Sep 13 15:54:47 2000 Ossama Othman <ossama@uci.edu> * tao/Acceptor_Impl.h: diff --git a/TAO/tao/Acceptor_Registry.cpp b/TAO/tao/Acceptor_Registry.cpp index 5fc54180505..9cd0466c746 100644 --- a/TAO/tao/Acceptor_Registry.cpp +++ b/TAO/tao/Acceptor_Registry.cpp @@ -10,6 +10,7 @@ #include "tao/debug.h" #include "tao/RT_Policy_i.h" #include "tao/Acceptor_Filter.h" +#include "tao/Endpoint.h" #include "ace/Auto_Ptr.h" #include "ace/SString.h" @@ -75,6 +76,8 @@ TAO_Acceptor_Registry::is_collocated (const TAO_MProfile &mprofile) { TAO_AcceptorSetIterator end = this->end (); + // If at least one endpoint in one of the profiles matches one of + // the acceptors, we are collocated. for (TAO_AcceptorSetIterator i = this->begin (); i != end; ++i) { for (TAO_PHandle j = 0; @@ -83,10 +86,22 @@ TAO_Acceptor_Registry::is_collocated (const TAO_MProfile &mprofile) { const TAO_Profile *profile = mprofile.get_profile (j); - // Check the address for equality. - if ((*i)->tag () == profile->tag () - && (*i)->is_collocated (profile)) - return 1; + // @@ We need to invoke a nonconst <endpoint> method on + // <profile>. The content of profile/endpoint + // will not be modified. + TAO_Profile *pf = + ACE_const_cast (TAO_Profile *, + profile); + + // Check all endpoints for address equality. + if ((*i)->tag () == pf->tag ()) + for (TAO_Endpoint *endp = pf->endpoint (); + endp != 0; + endp = endp->next ()) + { + if ((*i)->is_collocated (pf->endpoint ())) + return 1; + } } } diff --git a/TAO/tao/Acceptor_Registry.h b/TAO/tao/Acceptor_Registry.h index 7e9d46f400c..97c042e50bf 100644 --- a/TAO/tao/Acceptor_Registry.h +++ b/TAO/tao/Acceptor_Registry.h @@ -73,8 +73,7 @@ public: // Close all open acceptors. size_t endpoint_count (void); - // Returns the total number of endpoints, i.e., the number of - // profiles that have been created. + // Returns the total number of endpoints in all of its acceptors. int make_mprofile (const TAO_ObjectKey& object_key, TAO_MProfile &mprofile, diff --git a/TAO/tao/Connector_Registry.cpp b/TAO/tao/Connector_Registry.cpp index 78e69d87b82..2348f087ea3 100644 --- a/TAO/tao/Connector_Registry.cpp +++ b/TAO/tao/Connector_Registry.cpp @@ -4,6 +4,7 @@ #include "tao/Connector_Registry.h" #include "tao/ORB_Core.h" #include "tao/Profile.h" +#include "tao/Endpoint.h" #include "tao/Environment.h" #include "tao/debug.h" @@ -262,18 +263,18 @@ TAO_Connector_Registry::preprocess_preconnects (TAO_ORB_Core *orb_core, int -TAO_Connector_Registry::connect (TAO_Profile *&profile, +TAO_Connector_Registry::connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time) { // Find the appropriate connector object TAO_Connector *connector = - this->get_connector (profile->tag ()); + this->get_connector (endpoint->tag ()); if (connector == 0) return -1; - return connector->connect (profile, transport, max_wait_time); + return connector->connect (endpoint, transport, max_wait_time); } int diff --git a/TAO/tao/Connector_Registry.h b/TAO/tao/Connector_Registry.h index f4a0e9cc475..646deb7cac2 100644 --- a/TAO/tao/Connector_Registry.h +++ b/TAO/tao/Connector_Registry.h @@ -75,7 +75,7 @@ public: // For this list of preconnections call the connector specific // preconnect method for each preconnection. - int connect (TAO_Profile *&profile, + int connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time = 0); // This is where the transport protocol is selected based on some diff --git a/TAO/tao/Endpoint.cpp b/TAO/tao/Endpoint.cpp new file mode 100644 index 00000000000..45fd6b652c8 --- /dev/null +++ b/TAO/tao/Endpoint.cpp @@ -0,0 +1,14 @@ +// $Id$ + +#include "tao/Endpoint.h" + +#if !defined (__ACE_INLINE__) +#include "tao/Endpoint.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(tao, Endpoint, "$Id$") + + +TAO_Endpoint::~TAO_Endpoint (void) +{ +} diff --git a/TAO/tao/Endpoint.h b/TAO/tao/Endpoint.h new file mode 100644 index 00000000000..cfbb49855b8 --- /dev/null +++ b/TAO/tao/Endpoint.h @@ -0,0 +1,85 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// Endpoint.h +// +// = AUTHOR +// Marina Spivak <marina@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_ENDPOINT_H +#define TAO_ENDPOINT_H +#include "ace/pre.h" + +#include "tao/corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class TAO_Export TAO_Endpoint +{ + // = TITLE + // Defines the Endpoint interface in the Pluggable Protocol + // framework. + // + // = DESCRIPTION + // A lightweight object encapsulating a addressing information for + // a single endpoint. + // +public: + TAO_Endpoint (CORBA::ULong tag); + // Constructor + + virtual ~TAO_Endpoint (void); + // If you have a virtual method you need a virtual dtor. + + CORBA::ULong tag (void) const; + // The tag, each concrete class will have a specific tag value. + + void priority (CORBA::Short priority); + // Sets the <priority_> attribute. + + virtual TAO_Endpoint *next (void) = 0; + // Return the next endpoint in the list. + + CORBA::Short priority (void) const; + // Gets the <priority_> attribute. + + virtual int addr_to_string (char *buffer, size_t length) = 0; + // Return a string representation for the address. Returns + // -1 if buffer is too small. The purpose of this method is to + // provide a general interface to the underlying address object's + // addr_to_string method. This allows the protocol implementor to + // select the appropriate string format. + + virtual void reset_hint (void) = 0; + // This method is used with a connection has been reset requiring + // the hint to be cleaned up and reset to NULL. + +private: + + // Profiles should not be copied! + ACE_UNIMPLEMENTED_FUNC (TAO_Endpoint (const TAO_Endpoint&)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Endpoint&)) + + CORBA::ULong tag_; + // IOP protocol tag. + + CORBA::Short priority_; + // +}; + +#if defined (__ACE_INLINE__) +# include "tao/Endpoint.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_PROFILE_H */ diff --git a/TAO/tao/Endpoint.i b/TAO/tao/Endpoint.i new file mode 100644 index 00000000000..e21f3a31bbd --- /dev/null +++ b/TAO/tao/Endpoint.i @@ -0,0 +1,27 @@ +// -*- C++ -*- +// $Id$ + +ACE_INLINE +TAO_Endpoint::TAO_Endpoint (CORBA::ULong tag) + : tag_ (tag), + priority_ (0) +{ +} + +ACE_INLINE CORBA::ULong +TAO_Endpoint::tag (void) const +{ + return this->tag_; +} + +ACE_INLINE CORBA::Short +TAO_Endpoint::priority (void) const +{ + return this->priority_; +} + +ACE_INLINE void +TAO_Endpoint::priority (CORBA::Short p) +{ + this->priority_ = p; +} diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp index 5733663fcb5..8e4bcc56a1a 100644 --- a/TAO/tao/IIOP_Acceptor.cpp +++ b/TAO/tao/IIOP_Acceptor.cpp @@ -79,6 +79,21 @@ int TAO_IIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, TAO_MProfile &mprofile) { + // Sanity check. + if (this->endpoint_count_ == 0) + return -1; + + // If RT_CORBA is enabled, only one IIOP profile is created for + // <mprofile> and all IIOP endpoints are added into that profile. + // If RT_CORBA is not enabled, we create a separate profile for each + // endpoint. + +#if (TAO_HAS_RT_CORBA == 1) + + return create_rt_mprofile (object_key, mprofile); + +#else /* TAO_HAS_RT_CORBA == 1 */ + // Adding this->endpoint_count_ to the TAO_MProfile. int count = mprofile.profile_count (); if ((mprofile.size () - count) < this->endpoint_count_ @@ -87,6 +102,7 @@ TAO_IIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, for (size_t i = 0; i < this->endpoint_count_; ++i) { + // @@ Use autopointer here. TAO_IIOP_Profile *pfile = 0; ACE_NEW_RETURN (pfile, TAO_IIOP_Profile (this->hosts_[i].c_str (), @@ -115,28 +131,101 @@ TAO_IIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, code_set_info.ForWcharData.native_code_set = TAO_DEFAULT_WCHAR_CODESET_ID; pfile->tagged_components ().set_code_sets (code_set_info); + } + + return 0; + +#endif /* TAO_HAS_RT_CORBA == 1 */ +} + +int +TAO_IIOP_Acceptor::create_rt_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) +{ + size_t index = 0; + TAO_Profile *pfile = 0; + TAO_IIOP_Profile *iiop_profile = 0; + + // First see if <mprofile> already contains a IIOP profile. + for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i) + { + pfile = mprofile.get_profile (i); + if (pfile->tag () == TAO_TAG_IIOP_PROFILE) + { + iiop_profile = ACE_dynamic_cast (TAO_IIOP_Profile *, + pfile); + break; + } + } + + // If <mprofile> doesn't contain IIOP_Profile, we need to create + // one. + if (iiop_profile == 0) + { + ACE_NEW_RETURN (iiop_profile, + TAO_IIOP_Profile (this->hosts_[0].c_str (), + this->addrs_[0].get_port_number (), + object_key, + this->addrs_[0], + this->version_, + this->orb_core_), + -1); + iiop_profile->endpoint ()->priority (this->priority ()); - pfile->tagged_components ().set_tao_priority (this->priority ()); + if (mprofile.give_profile (iiop_profile) == -1) + { + iiop_profile->_decr_refcnt (); + iiop_profile = 0; + return -1; + } + + if (this->orb_core_->orb_params ()->std_profile_components () != 0) + { + iiop_profile->tagged_components ().set_orb_type (TAO_ORB_TYPE); + + CONV_FRAME::CodeSetComponentInfo code_set_info; + code_set_info.ForCharData.native_code_set = + TAO_DEFAULT_CHAR_CODESET_ID; + code_set_info.ForWcharData.native_code_set = + TAO_DEFAULT_WCHAR_CODESET_ID; + iiop_profile->tagged_components ().set_code_sets (code_set_info); + } + + index = 1; } + // Add any remaining endpoints to the IIOP_Profile. + for (; + index < this->endpoint_count_; + ++index) + { + TAO_IIOP_Endpoint *endpoint = 0; + ACE_NEW_RETURN (endpoint, + TAO_IIOP_Endpoint (this->hosts_[index].c_str (), + this->addrs_[index].get_port_number (), + this->addrs_[index]), + -1); + endpoint->priority (this->priority_); + iiop_profile->add_endpoint (endpoint); + } + return 0; } int -TAO_IIOP_Acceptor::is_collocated (const TAO_Profile *pfile) +TAO_IIOP_Acceptor::is_collocated (const TAO_Endpoint *endpoint) { - const TAO_IIOP_Profile *profile = - ACE_dynamic_cast (const TAO_IIOP_Profile *, - pfile); + const TAO_IIOP_Endpoint *endp = + ACE_dynamic_cast (const TAO_IIOP_Endpoint *, endpoint); // Make sure the dynamically cast pointer is valid. - if (profile == 0) + if (endp == 0) return 0; for (size_t i = 0; i < this->endpoint_count_; ++i) { // compare the port and sin_addr (numeric host address) - if (profile->object_addr () == this->addrs_[i]) + if (endp->object_addr () == this->addrs_[i]) return 1; // Collocated } diff --git a/TAO/tao/IIOP_Acceptor.h b/TAO/tao/IIOP_Acceptor.h index 666fcf5315e..290cf3478b2 100644 --- a/TAO/tao/IIOP_Acceptor.h +++ b/TAO/tao/IIOP_Acceptor.h @@ -75,7 +75,7 @@ public: virtual int close (void); virtual int create_mprofile (const TAO_ObjectKey &object_key, TAO_MProfile &mprofile); - virtual int is_collocated (const TAO_Profile* profile); + virtual int is_collocated (const TAO_Endpoint *endpoint); virtual CORBA::ULong endpoint_count (void); virtual int object_key (IOP::TaggedProfile &profile, @@ -103,6 +103,11 @@ private: // Obtain tcp properties that must be used by this acceptor, i.e., // initialize <tcp_properties_>. + int create_rt_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile); + // Rather than creating a profile for each endpoint, this version of + // <create_mprofile> adds all endpoints to a single IIOP profile. + protected: ACE_INET_Addr *addrs_; diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index 46bdf20f4df..856cbe26cf6 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -452,21 +452,21 @@ TAO_IIOP_Connector::close (void) } int -TAO_IIOP_Connector::connect (TAO_Profile *profile, +TAO_IIOP_Connector::connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time) { - if (profile->tag () != TAO_TAG_IIOP_PROFILE) + if (endpoint->tag () != TAO_TAG_IIOP_PROFILE) return -1; - TAO_IIOP_Profile *iiop_profile = - ACE_dynamic_cast (TAO_IIOP_Profile *, - profile); - if (iiop_profile == 0) + TAO_IIOP_Endpoint *iiop_endpoint = + ACE_dynamic_cast (TAO_IIOP_Endpoint *, + endpoint); + if (iiop_endpoint == 0) return -1; const ACE_INET_Addr &remote_address = - iiop_profile->object_addr (); + iiop_endpoint->object_addr (); // Verify that the remote ACE_INET_Addr was initialized properly. // Failure can occur if hostname lookup failed when initializing the @@ -497,7 +497,7 @@ TAO_IIOP_Connector::connect (TAO_Profile *profile, // object; but we obtain the transport in the <svc_handler> // variable. Other threads may modify the hint, but we are not // affected. - result = this->base_connector_.connect (iiop_profile->hint (), + result = this->base_connector_.connect (iiop_endpoint->hint (), svc_handler, remote_address, synch_options); @@ -508,7 +508,7 @@ TAO_IIOP_Connector::connect (TAO_Profile *profile, // object; but we obtain the transport in the <svc_handler> // variable. Other threads may modify the hint, but we are not // affected. - result = this->base_connector_.connect (iiop_profile->hint (), + result = this->base_connector_.connect (iiop_endpoint->hint (), svc_handler, remote_address); } @@ -523,30 +523,14 @@ TAO_IIOP_Connector::connect (TAO_Profile *profile, ACE_TEXT ("%s:%d failed (%p)\n"), __FILE__, __LINE__, - iiop_profile->host (), - iiop_profile->port (), + iiop_endpoint->host (), + iiop_endpoint->port (), "errno")); } return -1; } transport = svc_handler->transport (); - - // Now that we have the client connection handler object we need to - // set the right messaging protocol for in the client side transport. - const TAO_GIOP_Version& version = iiop_profile->version (); - int ret_val = transport->messaging_init (version.major, - version.minor); - if (ret_val == -1) - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%N|%l|%p|%t) init_mesg_protocol () failed \n"))); - } - return -1; - } - return 0; } diff --git a/TAO/tao/IIOP_Connector.h b/TAO/tao/IIOP_Connector.h index 6e626131af2..3569a45953d 100644 --- a/TAO/tao/IIOP_Connector.h +++ b/TAO/tao/IIOP_Connector.h @@ -100,7 +100,7 @@ public: // Pluggable.h int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_Profile *profile, + int connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time); int preconnect (const char *preconnections); diff --git a/TAO/tao/IIOP_Endpoint.cpp b/TAO/tao/IIOP_Endpoint.cpp new file mode 100644 index 00000000000..111d9cc8649 --- /dev/null +++ b/TAO/tao/IIOP_Endpoint.cpp @@ -0,0 +1,135 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +#include "tao/IIOP_Endpoint.h" +#include "tao/IIOP_Connect.h" +#include "tao/debug.h" + +ACE_RCSID(tao, IIOP_Endpoint, "$Id$") + +#if !defined (__ACE_INLINE__) +# include "tao/IIOP_Endpoint.i" +#endif /* __ACE_INLINE__ */ + +TAO_IIOP_Endpoint::TAO_IIOP_Endpoint (const ACE_INET_Addr &addr, + int use_dotted_decimal_addresses) + : TAO_Endpoint (TAO_TAG_IIOP_PROFILE), + host_ (), + port_ (0), + object_addr_ (addr), + hint_ (0), + next_ (0) +{ + this->set (addr, use_dotted_decimal_addresses); +} + +TAO_IIOP_Endpoint::TAO_IIOP_Endpoint (const char *host, + CORBA::UShort port, + const ACE_INET_Addr &addr) + : TAO_Endpoint (TAO_TAG_IIOP_PROFILE), + host_ (), + port_ (port), + object_addr_ (addr), + hint_ (0), + next_ (0) +{ + if (host != 0) + this->host_ = host; +} + +TAO_IIOP_Endpoint::TAO_IIOP_Endpoint (void) + : TAO_Endpoint (TAO_TAG_IIOP_PROFILE), + host_ (), + port_ (0), + object_addr_ (), + hint_ (0), + next_ (0) +{ +} + +TAO_IIOP_Endpoint::TAO_IIOP_Endpoint (const char *host, + CORBA::UShort port, + CORBA::Short priority) + : TAO_Endpoint (TAO_TAG_IIOP_PROFILE), + host_ (), + port_ (port), + object_addr_ (), + hint_ (0), + next_ (0) +{ + if (host != 0) + this->host_ = host; + + this->object_addr_.set_type (-1); + this->priority (priority); +} + +TAO_IIOP_Endpoint::~TAO_IIOP_Endpoint (void) +{ +} + +int +TAO_IIOP_Endpoint::set (const ACE_INET_Addr &addr, + int use_dotted_decimal_addresses) +{ + char tmp_host[MAXHOSTNAMELEN + 1]; + + if (use_dotted_decimal_addresses + || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) + { + const char *tmp = addr.get_host_addr (); + if (tmp == 0) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\n\nTAO (%P|%t) ") + ACE_TEXT ("IIOP_Endpoint::set ") + ACE_TEXT ("- %p\n\n"), + ACE_TEXT ("cannot determine hostname"))); + return -1; + } + else + this->host_ = tmp; + } + else + this->host_ = CORBA::string_dup (tmp_host); + + this->port_ = addr.get_port_number(); + + return 0; +} + +int +TAO_IIOP_Endpoint::addr_to_string (char *buffer, size_t length) +{ + size_t actual_len = + ACE_OS::strlen (this->host_.in ()) // chars in host name + + sizeof (':') // delimiter + + ACE_OS::strlen ("65536") // max port + + sizeof ('\0'); + + if (length < actual_len) + return -1; + + ACE_OS::sprintf (buffer, "%s:%d", + this->host_.in (), this->port_); + + return 0; +} + +const char * +TAO_IIOP_Endpoint::host (const char *h) +{ + this->host_ = h; + + return this->host_.in (); +} + +void +TAO_IIOP_Endpoint::reset_hint (void) +{ + if (this->hint_) + this->hint_->cleanup_hint ((void **) &this->hint_); +} + diff --git a/TAO/tao/IIOP_Endpoint.h b/TAO/tao/IIOP_Endpoint.h new file mode 100644 index 00000000000..5ee104798c1 --- /dev/null +++ b/TAO/tao/IIOP_Endpoint.h @@ -0,0 +1,138 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// IIOP_Endpoint.h +// +// = AUTHOR +// Marina Spivak <marina@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_IIOP_ENDPOINT_H +#define TAO_IIOP_ENDPOINT_H +#include "ace/pre.h" + +#include "tao/Endpoint.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/ORB.h" + +#include "ace/INET_Addr.h" + + +class TAO_IIOP_Client_Connection_Handler; + +class TAO_Export TAO_IIOP_Endpoint : public TAO_Endpoint +{ + // = TITLE + // This class defines the protocol specific attributes required + // for locating ORBs over a TCP/IP network. + // + // = DESCRIPTION + // This class defines the IIOP profile as specified in the CORBA + // specification. +public: + + friend class TAO_IIOP_Profile; + + TAO_IIOP_Endpoint (const ACE_INET_Addr &addr, + int use_dotted_decimal_addresses); + // Profile constructor + + TAO_IIOP_Endpoint (const char *host, + CORBA::UShort port, + const ACE_INET_Addr &addr); + // Endpoint constructor, this is the most efficient since it + // doesn't require any address resolution processing. + + TAO_IIOP_Endpoint (const char *host, + CORBA::UShort port, + CORBA::Short priority); + // Endpoint constructor - used when decoding endpoints from the wire. + + TAO_IIOP_Endpoint (void); + // Endpoint constructor, default. + + ~TAO_IIOP_Endpoint (void); + // Destructor is to be called only through <_decr_refcnt>. + + CORBA::Boolean is_equivalent (const TAO_IIOP_Endpoint *other_endpoint); + // Return true if this profile is equivalent to other_profile. Two + // profiles are equivalent iff their key, port, host, object_key and + // version are the same. + + CORBA::ULong hash (void); + // Return a hash value for this object. + + // = Abstract Endpoint interface methods. + + TAO_Endpoint *next (void); + // Return the next endpoint in the list. + + virtual int addr_to_string (char *buffer, size_t length); + // Return a string representation for the address. + + virtual void reset_hint (void); + // Reset the hint's value. + + // = IIOP Endpoint methods. + + const ACE_INET_Addr &object_addr (void) const; + // return a reference to the object_addr. + + const char *host (void) const; + // Return a pointer to the host string. This object maintains + // ownership of this string. + + const char *host (const char *h); + // Copy the string h into <host_> and return the resulting pointer. + // This object maintains ownership of this string. + + CORBA::UShort port (void) const; + // Return the port number. + + CORBA::UShort port (CORBA::UShort p); + // Set the port number. + + TAO_IIOP_Client_Connection_Handler *&hint (void); + // This is a hint for which connection handler to use. + +private: + int set (const ACE_INET_Addr &addr, + int use_dotted_decimal_addresses); + // helper method to set the INET_Addr. + + CORBA::String_var host_; + // String representing the hosts name. + + CORBA::UShort port_; + // TCP port number + + ACE_INET_Addr object_addr_; + // Cached instance of <ACE_INET_Addr> for use in making + // invocations, etc. + + TAO_IIOP_Client_Connection_Handler *hint_; + // Pointer to a connection handler which we successfully used + // already. + + TAO_IIOP_Endpoint *next_; + // Next endpoint in the list. +}; + +#if defined (__ACE_INLINE__) +# include "tao/IIOP_Endpoint.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_IIOP_PROFILE_H */ diff --git a/TAO/tao/IIOP_Endpoint.i b/TAO/tao/IIOP_Endpoint.i new file mode 100644 index 00000000000..857e8da4f22 --- /dev/null +++ b/TAO/tao/IIOP_Endpoint.i @@ -0,0 +1,80 @@ +// -*- C++ -*- +// $Id$ + +ACE_INLINE const ACE_INET_Addr & +TAO_IIOP_Endpoint::object_addr (void) const +{ + // The object_addr_ is initialized here, rather than at IOR decode + // time for several reasons: + // 1. A request on the object may never be invoked. + // 2. The DNS setup may have changed dynamically. + // ...etc.. + + // We need to modify the object_addr_ in this method. Do so using a + // non-const copy of the <this> pointer. + TAO_IIOP_Endpoint *endpoint = + ACE_const_cast (TAO_IIOP_Endpoint *, + this); + + if (this->object_addr_.get_type () != AF_INET + && endpoint->object_addr_.set (this->port_, + this->host_.in ()) == -1) + { + // If this call fails, it most likely due a hostname lookup + // failure caused by a DNS misconfiguration. If a request is + // made to the object at the given host and port, then a + // CORBA::TRANSIENT() exception should be thrown. + + // Invalidate the ACE_INET_Addr. This is used as a flag to + // denote that ACE_INET_Addr initialization failed. + endpoint->object_addr_.set_type (-1); + } + + return this->object_addr_; +} + +ACE_INLINE const char * +TAO_IIOP_Endpoint::host (void) const +{ + return this->host_.in (); +} + +ACE_INLINE CORBA::UShort +TAO_IIOP_Endpoint::port (void) const +{ + return this->port_; +} + +ACE_INLINE CORBA::UShort +TAO_IIOP_Endpoint::port (CORBA::UShort p) +{ + return this->port_ = p; +} + +ACE_INLINE TAO_IIOP_Client_Connection_Handler *& +TAO_IIOP_Endpoint::hint (void) +{ + return this->hint_; +} + +ACE_INLINE CORBA::ULong +TAO_IIOP_Endpoint::hash (void) +{ + return + ACE::hash_pjw (this->host_.in ()) + + this->port_; +} + +ACE_INLINE CORBA::Boolean +TAO_IIOP_Endpoint::is_equivalent (const TAO_IIOP_Endpoint *other_endpoint) +{ + return + this->port_ == other_endpoint->port_ + && ACE_OS::strcmp (this->host_.in (), other_endpoint->host_.in ()) == 0; +} + +ACE_INLINE TAO_Endpoint * +TAO_IIOP_Endpoint::next (void) +{ + return this->next_; +} diff --git a/TAO/tao/IIOP_Profile.cpp b/TAO/tao/IIOP_Profile.cpp index 9330b00e959..8a8ed22fb78 100644 --- a/TAO/tao/IIOP_Profile.cpp +++ b/TAO/tao/IIOP_Profile.cpp @@ -3,12 +3,12 @@ #include "tao/IIOP_Profile.h" -#include "tao/IIOP_Connect.h" #include "tao/CDR.h" #include "tao/Environment.h" #include "tao/ORB.h" #include "tao/ORB_Core.h" #include "tao/debug.h" +#include "tao/iiop_endpoints.h" ACE_RCSID(tao, IIOP_Profile, "$Id$") @@ -31,17 +31,14 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr &addr, const TAO_ObjectKey &object_key, const TAO_GIOP_Version &version, TAO_ORB_Core *orb_core) - : TAO_Profile (TAO_TAG_IIOP_PROFILE, - orb_core), - host_ (), - port_ (0), - version_ (version), + : TAO_Profile (TAO_TAG_IIOP_PROFILE, orb_core, version), + endpoint_ (addr, + orb_core->orb_params ()->use_dotted_decimal_addresses ()), + count_ (1), + endpoints_encoded_ (0), object_key_ (object_key), - object_addr_ (addr), - hint_ (0), tagged_profile_ () { - this->set (addr); } TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host, @@ -50,30 +47,26 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host, const ACE_INET_Addr &addr, const TAO_GIOP_Version &version, TAO_ORB_Core *orb_core) - : TAO_Profile (TAO_TAG_IIOP_PROFILE, - orb_core), - host_ (), - port_ (port), - version_ (version), + : TAO_Profile (TAO_TAG_IIOP_PROFILE, orb_core, version), + endpoint_ (host, port, addr), + count_ (1), + endpoints_encoded_ (0), object_key_ (object_key), - object_addr_ (addr), - hint_ (0) + tagged_profile_ () { - if (host != 0) - this->host_ = host; } TAO_IIOP_Profile::TAO_IIOP_Profile (const char *string, TAO_ORB_Core *orb_core, CORBA::Environment &ACE_TRY_ENV) : TAO_Profile (TAO_TAG_IIOP_PROFILE, - orb_core), - host_ (), - port_ (0), - version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)), + endpoint_ (), + count_ (1), + endpoints_encoded_ (0), object_key_ (), - object_addr_ (), - hint_ (0) + tagged_profile_ () { this->parse_string (string, ACE_TRY_ENV); ACE_CHECK; @@ -81,48 +74,28 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char *string, TAO_IIOP_Profile::TAO_IIOP_Profile (TAO_ORB_Core *orb_core) : TAO_Profile (TAO_TAG_IIOP_PROFILE, - orb_core), - host_ (), - port_ (0), - version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)), + endpoint_ (), + count_ (1), + endpoints_encoded_ (0), object_key_ (), - object_addr_ (), - hint_ (0) + tagged_profile_ () { } -int -TAO_IIOP_Profile::set (const ACE_INET_Addr &addr) +TAO_IIOP_Profile::~TAO_IIOP_Profile (void) { - char tmp_host[MAXHOSTNAMELEN + 1]; + // Clean up endpoint list. + TAO_Endpoint *tmp = 0; - if (this->orb_core ()->orb_params ()->use_dotted_decimal_addresses () - || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) + for (TAO_Endpoint *next = this->endpoint ()->next (); + next != 0; + next = tmp) { - const char *tmp = addr.get_host_addr (); - if (tmp == 0) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\n\nTAO (%P|%t) ") - ACE_TEXT ("IIOP_Profile::set ") - ACE_TEXT ("- %p\n\n"), - ACE_TEXT ("cannot determine hostname"))); - return -1; - } - else - this->host_ = tmp; + tmp = next->next (); + delete next; } - else - this->host_ = CORBA::string_dup (tmp_host); - - this->port_ = addr.get_port_number(); - - return 0; -} - -TAO_IIOP_Profile::~TAO_IIOP_Profile (void) -{ } // return codes: @@ -158,9 +131,11 @@ TAO_IIOP_Profile::decode (TAO_InputCDR& cdr) if (minor <= TAO_DEF_GIOP_MINOR) this->version_.minor = minor; + // Do we have decode method in the endpoint? + // Or do we decode into endpoint straight from here? // Get host and port - if (cdr.read_string (this->host_.out ()) == 0 - || cdr.read_ushort (this->port_) == 0) + if (cdr.read_string (this->endpoint_.host_.out ()) == 0 + || cdr.read_ushort (this->endpoint_.port_) == 0) { if (TAO_debug_level > 0) { @@ -193,10 +168,13 @@ TAO_IIOP_Profile::decode (TAO_InputCDR& cdr) encap_len)); } + // Decode endpoints if any. + this->decode_endpoints (); + if (cdr.good_bit ()) { // Invalidate the object_addr_ until first access. - this->object_addr_.set_type (-1); + this->endpoint_.object_addr_.set_type (-1); return 1; } @@ -288,7 +266,7 @@ TAO_IIOP_Profile::parse_string (const char *string, ACE_OS::strncpy (tmp.inout (), cp + 1, length); tmp[length] = '\0'; - this->port_ = (CORBA::UShort) ACE_OS::atoi (tmp.in ()); + this->endpoint_.port_ = (CORBA::UShort) ACE_OS::atoi (tmp.in ()); length = cp - start; @@ -297,10 +275,10 @@ TAO_IIOP_Profile::parse_string (const char *string, ACE_OS::strncpy (tmp.inout (), start, length); tmp[length] = '\0'; - this->host_ = tmp._retn (); + this->endpoint_.host_ = tmp._retn (); - if (this->object_addr_.set (this->port_, - this->host_.in ()) == -1) + if (this->endpoint_.object_addr_.set (this->endpoint_.port_, + this->endpoint_.host_.in ()) == -1) { if (TAO_debug_level > 0) { @@ -330,21 +308,43 @@ TAO_IIOP_Profile::is_equivalent (const TAO_Profile *other_profile) ACE_ASSERT (op->object_key_.length () < UINT_MAX); - return this->port_ == op->port_ - && this->object_key_ == op->object_key_ - && ACE_OS::strcmp (this->host_.in (), op->host_.in ()) == 0 - && this->version_ == op->version_; + if (!(this->object_key_ == op->object_key_ + && this->version_ == op->version_ + && this->count_ == op->count_)) + return 0; + + // Check endpoints equivalence. + // @@ Are we guaranteed that the endpoints in both profiles will be + // in the same order? + const TAO_IIOP_Endpoint *other_endp = &op->endpoint_; + for (TAO_IIOP_Endpoint *endp = &this->endpoint_; + endp != 0; + endp = endp->next_) + { + if (endp->is_equivalent (other_endp)) + other_endp = other_endp->next_; + else + return 0; + } + + return 1; } CORBA::ULong TAO_IIOP_Profile::hash (CORBA::ULong max, CORBA::Environment &) { - CORBA::ULong hashval = - ACE::hash_pjw (this->host_.in ()) - + this->port_ - + this->version_.minor - + this->tag (); + // Get the hashvalue for all endpoints. + CORBA::ULong hashval = 0; + for (TAO_IIOP_Endpoint *endp = &this->endpoint_; + endp != 0; + endp = endp->next_) + { + hashval += endp->hash (); + } + + hashval += this->version_.minor; + hashval += this->tag (); if (this->object_key_.length () >= 4) { @@ -355,37 +355,19 @@ TAO_IIOP_Profile::hash (CORBA::ULong max, return hashval % max; } -int -TAO_IIOP_Profile::addr_to_string (char *buffer, size_t length) -{ - size_t actual_len = - ACE_OS::strlen (this->host_.in ()) // chars in host name - + sizeof (':') // delimiter - + ACE_OS::strlen ("65536") // max port - + sizeof ('\0'); - - if (length < actual_len) - return -1; - - ACE_OS::sprintf (buffer, "%s:%d", - this->host_.in (), this->port_); - - return 0; -} - -const char * -TAO_IIOP_Profile::host (const char *h) +TAO_Endpoint* +TAO_IIOP_Profile::endpoint (void) { - this->host_ = h; - - return this->host_.in (); + return &this->endpoint_; } void -TAO_IIOP_Profile::reset_hint (void) +TAO_IIOP_Profile::add_endpoint (TAO_IIOP_Endpoint *endp) { - if (this->hint_) - this->hint_->cleanup_hint ((void **) &this->hint_); + endp->next_ = this->endpoint_.next_; + this->endpoint_.next_ = endp; + + this->count_++; } char * @@ -403,7 +385,7 @@ TAO_IIOP_Profile::to_string (CORBA::Environment &) 1 /* decimal point */ + 1 /* minor version */ + 1 /* `@' character */ + - ACE_OS::strlen (this->host_.in ()) + + ACE_OS::strlen (this->endpoint_.host ()) + 1 /* colon separator */ + 5 /* port number */ + 1 /* object key separator */ + @@ -418,8 +400,8 @@ TAO_IIOP_Profile::to_string (CORBA::Environment &) ::prefix_, digits [this->version_.major], digits [this->version_.minor], - this->host_.in (), - this->port_, + this->endpoint_.host (), + this->endpoint_.port (), this->object_key_delimiter_, key.in ()); return buf; @@ -514,15 +496,117 @@ TAO_IIOP_Profile::create_profile_body (TAO_OutputCDR &encap) const encap.write_octet (this->version_.minor); // STRING hostname from profile - encap.write_string (this->host_.in ()); + encap.write_string (this->endpoint_.host ()); // UNSIGNED SHORT port number - encap.write_ushort (this->port_); + encap.write_ushort (this->endpoint_.port ()); // OCTET SEQUENCE for object key encap << this->object_key_; + // Encode profile endpoints. + TAO_IIOP_Profile *p = + ACE_const_cast (TAO_IIOP_Profile *, this); + if (!endpoints_encoded_) + p->encode_endpoints (); + if (this->version_.major > 1 || this->version_.minor > 0) this->tagged_components ().encode (encap); } + +int +TAO_IIOP_Profile::encode_endpoints (void) +{ + // Create a data structure with endpoint info for wire transfer. + TAO_IIOPEndpointSequence endpoints; + endpoints.length (this->count_); + + const TAO_IIOP_Endpoint *endpoint = &this->endpoint_; + for (size_t i = 0; + i < this->count_; + ++i) + { + endpoints[i].host = endpoint->host (); + endpoints[i].port = endpoint->port (); + endpoints[i].priority = endpoint->priority (); + + endpoint = endpoint->next_; + } + + // Encode. + TAO_OutputCDR out_cdr; + out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); + out_cdr << endpoints; + CORBA::ULong length = out_cdr.total_length (); + + IOP::TaggedComponent tagged_component; + tagged_component.tag = TAO_TAG_ENDPOINTS; + tagged_component.component_data.length (length); + CORBA::Octet *buf = + tagged_component.component_data.get_buffer (); + + for (const ACE_Message_Block *iterator = out_cdr.begin (); + iterator != 0; + iterator = iterator->cont ()) + { + CORBA::ULong i_length = iterator->length (); + ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length); + + buf += i_length; + } + + // Eventually we add the TaggedComponent to the TAO_TaggedComponents + // member variable. + tagged_components_.set_component (tagged_component); + this->endpoints_encoded_ = 1; + + return 1; +} + +int +TAO_IIOP_Profile::decode_endpoints (void) +{ + IOP::TaggedComponent tagged_component; + tagged_component.tag = TAO_TAG_ENDPOINTS; + + if (this->tagged_components_.get_component (tagged_component)) + { + const CORBA::Octet *buf = + tagged_component.component_data.get_buffer (); + + TAO_InputCDR in_cdr (ACE_reinterpret_cast (const char*, buf), + tagged_component.component_data.length ()); + + // Extract the Byte Order. + CORBA::Boolean byte_order; + if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + return 0; + in_cdr.reset_byte_order (ACE_static_cast(int, byte_order)); + + // Extract endpoints sequence. + TAO_IIOPEndpointSequence endpoints; + in_cdr >> endpoints; + + // Get the priority of the first endpoint. It's other data is + // extracted as part of the standard iiop decoding. + this->endpoint_.priority (endpoints[0].priority); + + // Start with the second endpoint, because the first endpoint is + // always extracted through standard iiop profile body. + for (CORBA::ULong i = 1; i < endpoints.length (); ++i) + { + TAO_IIOP_Endpoint *endpoint = 0; + ACE_NEW_RETURN (endpoint, + TAO_IIOP_Endpoint (endpoints[i].host, + endpoints[i].port, + endpoints[i].priority), + 0); + + this->add_endpoint (endpoint); + } + } + + this->endpoints_encoded_ = 1; + return 1; +} diff --git a/TAO/tao/IIOP_Profile.h b/TAO/tao/IIOP_Profile.h index 3b494267d34..2ea538063c7 100644 --- a/TAO/tao/IIOP_Profile.h +++ b/TAO/tao/IIOP_Profile.h @@ -23,16 +23,15 @@ #include "ace/pre.h" #include "tao/Profile.h" -#include "tao/GIOP_Message_State.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "tao/ORB.h" #include "tao/Object_KeyC.h" +#include "tao/IIOP_Endpoint.h" #include "ace/Synch.h" -#include "ace/INET_Addr.h" +//#include "ace/INET_Addr.h" class TAO_IIOP_Client_Connection_Handler; @@ -82,15 +81,24 @@ public: ~TAO_IIOP_Profile (void); // Destructor is to be called only through <_decr_refcnt>. + virtual TAO_Endpoint *endpoint (void); + // Head of the list of endpoints for this profile. + + void add_endpoint (TAO_IIOP_Endpoint *endp); + // + int parse_string (const char *string, CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()); // Initialize this object using the given input string. + // Url-style string contain only one endpoint. char * to_string (CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()); // Return a string representation for this profile. // client must deallocate memory. + // This is used to create url-style reference. Only one + // endpoint is included into the string. int decode (TAO_InputCDR& cdr); // Initialize this object using the given CDR octet string. @@ -112,71 +120,39 @@ public: CORBA::ULong hash (CORBA::ULong max, CORBA::Environment &ACE_TRY_ENV = - TAO_default_environment ()); + TAO_default_environment ()); // Return a hash value for this object. - int addr_to_string (char *buffer, size_t length); - // Return a string representation for the address. - - const ACE_INET_Addr &object_addr (void) const; - // return a reference to the object_addr. - - const char *host (void) const; - // Return a pointer to the host string. This object maintains - // ownership of this string. - - const char *host (const char *h); - // Copy the string h into <host_> and return the resulting pointer. - // This object maintains ownership of this string. - - CORBA::UShort port (void) const; - // Return the port number. - - CORBA::UShort port (CORBA::UShort p); - // Set the port number. - - const TAO_GIOP_Version& version (void) const; - // Return a pointer to this profile's version. This object - // maintains ownership. - - TAO_IIOP_Client_Connection_Handler *&hint (void); - // This is a hint for which connection handler to use. - - void reset_hint (void); - // Reset the hint's value. - IOP::TaggedProfile &create_tagged_profile (void); // Please refer to Profile.h for the documentation of this // function. private: - int set (const ACE_INET_Addr &addr); - // helper method to set the INET_Addr. - -private: void create_profile_body (TAO_OutputCDR &cdr) const; // Creates a encapsultaion of the ProfileBody struct in the <cdr> - CORBA::String_var host_; - // String representing the hosts name. + int encode_endpoints (void); + // Encodes endpoints from this profile into a tagged component. + + int decode_endpoints (void); + // Decodes endpoints of this profile from a tagged component. - CORBA::UShort port_; - // TCP port number + TAO_IIOP_Endpoint endpoint_; + // Head of the list of endpoints for this profile. - TAO_GIOP_Version version_; - // IIOP version number. + size_t count_; + // Number of endpoints this profile contains. + + int endpoints_encoded_; + // Flag indicating whether endpoints have already been encoded, + // saving us from repeatedly encoding them over and over. TAO_ObjectKey object_key_; // object_key associated with this profile. - ACE_INET_Addr object_addr_; - // Cached instance of <ACE_INET_Addr> for use in making - // invocations, etc. - - TAO_IIOP_Client_Connection_Handler *hint_; - // Pointer to a connection handler which we successfully used - // already. + TAO_ORB_Core *orb_core_; + // ORB Core. IOP::TaggedProfile tagged_profile_; // Our tagged profile diff --git a/TAO/tao/IIOP_Profile.i b/TAO/tao/IIOP_Profile.i index 94669b12db0..b498170ce78 100644 --- a/TAO/tao/IIOP_Profile.i +++ b/TAO/tao/IIOP_Profile.i @@ -19,66 +19,6 @@ TAO_IIOP_Profile::_key (void) const return key; } -ACE_INLINE const ACE_INET_Addr & -TAO_IIOP_Profile::object_addr (void) const -{ - // The object_addr_ is initialized here, rather than at IOR decode - // time for several reasons: - // 1. A request on the object may never be invoked. - // 2. The DNS setup may have changed dynamically. - // ...etc.. - - // We need to modify the object_addr_ in this method. Do so using a - // non-const copy of the <this> pointer. - TAO_IIOP_Profile *profile = - ACE_const_cast (TAO_IIOP_Profile *, - this); - - if (this->object_addr_.get_type () != AF_INET - && profile->object_addr_.set (this->port_, - this->host_.in ()) == -1) - { - // If this call fails, it most likely due a hostname lookup - // failure caused by a DNS misconfiguration. If a request is - // made to the object at the given host and port, then a - // CORBA::TRANSIENT() exception should be thrown. - - // Invalidate the ACE_INET_Addr. This is used as a flag to - // denote that ACE_INET_Addr initialization failed. - profile->object_addr_.set_type (-1); - } - - return this->object_addr_; -} - -ACE_INLINE const char * -TAO_IIOP_Profile::host (void) const -{ - return this->host_.in (); -} - -ACE_INLINE CORBA::UShort -TAO_IIOP_Profile::port (void) const -{ - return this->port_; -} - -ACE_INLINE CORBA::UShort -TAO_IIOP_Profile::port (CORBA::UShort p) -{ - return this->port_ = p; -} -ACE_INLINE const TAO_GIOP_Version & -TAO_IIOP_Profile::version (void) const -{ - return this->version_; -} - -ACE_INLINE TAO_IIOP_Client_Connection_Handler *& -TAO_IIOP_Profile::hint (void) -{ - return this->hint_; -} diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp index cfeefd5f7d7..e0da2afed4c 100644 --- a/TAO/tao/Invocation.cpp +++ b/TAO/tao/Invocation.cpp @@ -6,6 +6,7 @@ #include "tao/Timeprobe.h" #include "tao/Object_KeyC.h" +#include "tao/Endpoint.h" #include "tao/debug.h" #include "tao/Pluggable.h" #include "tao/Connector_Registry.h" @@ -86,6 +87,8 @@ TAO_GIOP_Invocation::TAO_GIOP_Invocation (TAO_Stub *stub, orb_core->to_unicode ()), orb_core_ (orb_core), transport_ (0), + profile_ (0), + endpoint_ (0), max_wait_time_ (0) { } @@ -94,8 +97,8 @@ TAO_GIOP_Invocation::~TAO_GIOP_Invocation (void) { } -TAO_Profile * -TAO_GIOP_Invocation::select_profile_based_on_policy +void +TAO_GIOP_Invocation::select_endpoint_based_on_policy (CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { @@ -104,7 +107,7 @@ TAO_GIOP_Invocation::select_profile_based_on_policy ACE_UNUSED_ARG (ACE_TRY_ENV); this->profile_ = this->stub_->profile_in_use (); - return this->profile_; + this->endpoint_ = this->profile_->endpoint (); #else @@ -118,7 +121,7 @@ TAO_GIOP_Invocation::select_profile_based_on_policy // Policy is not set. { this->profile_ = this->stub_->profile_in_use (); - return this->profile_; + this->endpoint_ = this->profile_->endpoint (); } else // Policy is set. @@ -133,63 +136,74 @@ TAO_GIOP_Invocation::select_profile_based_on_policy if (mode == TAO::USE_NO_PRIORITY) { this->profile_ = this->stub_->profile_in_use (); - return this->profile_; - } - - // Care about priority. - - // Determine priority range used to select the profile. - CORBA::Short min_priority; - CORBA::Short max_priority; - - if (mode == TAO::USE_PRIORITY_RANGE) - { - min_priority = priority_spec.min_priority; - max_priority = priority_spec.max_priority; + this->endpoint_ = profile_->endpoint (); } else - // mode == TAO::USE_THREAD_PRIORITY { - if (this->orb_core_->get_thread_priority (min_priority) == -1) - ACE_THROW_RETURN (CORBA::DATA_CONVERSION (1, - CORBA::COMPLETED_NO), - 0); - max_priority = min_priority; - } - if (TAO_debug_level > 3) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - matching priority range %d %d\n"), - min_priority, - max_priority)); - - // Select a base profile whose priority is in the range. - this->profile_ = 0; - const TAO_MProfile& mprofile = this->stub_->base_profiles (); - - for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i) - { - const TAO_Profile *profile = mprofile.get_profile (i); - const TAO_Tagged_Components &tc = profile->tagged_components (); - CORBA::Short profile_priority; - if (tc.get_tao_priority (profile_priority) == 0) - continue; + // Care about priority. - if (profile_priority >= min_priority - && profile_priority <= max_priority) + // Determine priority range used to select the profile. + CORBA::Short min_priority; + CORBA::Short max_priority; + + if (mode == TAO::USE_PRIORITY_RANGE) { - this->profile_ = - ACE_const_cast(TAO_Profile*,profile); - + min_priority = priority_spec.min_priority; + max_priority = priority_spec.max_priority; } + else + // mode == TAO::USE_THREAD_PRIORITY + { + if (this->orb_core_->get_thread_priority (min_priority) == -1) + ACE_THROW (CORBA::DATA_CONVERSION (1, + CORBA::COMPLETED_NO)); + max_priority = min_priority; + } + if (TAO_debug_level > 3) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) - matching priority range %d %d\n"), + min_priority, + max_priority)); + + // Select profile/endpoint satisfying the priority range. + // We start the search from <profile_in_use>. + // @@ Optimization: if this->profile_ != 0, we can start the + // search from this->profile_. + TAO_MProfile& mprofile = this->stub_->base_profiles (); + this->endpoint_ = 0; + + for (TAO_PHandle i = mprofile.get_current_handle (); + i < mprofile.profile_count (); + ++i) + { + TAO_Profile *profile = mprofile.get_profile (i); + + // Check if this profile contains any endpoints of the + // right priority. + for (TAO_Endpoint *endp = profile->endpoint (); + endp != 0; + endp = endp->next ()) + { + CORBA::Short priority = endp->priority (); + if (priority >= min_priority + && priority <= max_priority) + { + this->profile_ = profile; + this->endpoint_ = endp; + break; + } + } + + if (this->endpoint_ != 0) + break; + } + + // We were not able to find profile with the endpoint of the + // right priority. + if (this->endpoint_ == 0) + ACE_THROW (CORBA::INV_POLICY ()); } - - if (this->profile_ == 0) - ACE_THROW_RETURN (CORBA::INV_POLICY (), - 0); - else - return this->profile_; } - #endif /* TAO_HAS_CLIENT_PRIORITY_POLICY == 0 */ } @@ -341,18 +355,34 @@ TAO_GIOP_Invocation::start (CORBA::Environment &ACE_TRY_ENV) for (;;) { // Select the profile for this invocation. - this->select_profile_based_on_policy (ACE_TRY_ENV); + this->select_endpoint_based_on_policy (ACE_TRY_ENV); ACE_CHECK; // Get the transport object. if (this->transport_ != 0) this->transport_->idle (); - int result = conn_reg->connect (this->profile_, + int result = conn_reg->connect (this->endpoint_, this->transport_, this->max_wait_time_); if (result == 0) - break; + { + // Now that we have the client connection handler object we need to + // set the right messaging protocol for in the client side transport. + const TAO_GIOP_Version& version = this->profile_->version (); + result = this->transport_->messaging_init (version.major, + version.minor); + if (result == -1) + { + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%N|%l|%p|%t) init_mesg_protocol () failed \n"))); + } + } + else + break; + } if (errno == ETIME) { @@ -484,7 +514,7 @@ TAO_GIOP_Invocation::invoke (CORBA::Boolean is_roundtrip, this->transport_->close_connection (); this->transport_ = 0; - this->profile_->reset_hint (); + this->endpoint_->reset_hint (); return TAO_INVOKE_RESTART; } @@ -518,7 +548,8 @@ TAO_GIOP_Invocation::close_connection (void) this->transport_->idle (); this->transport_ = 0; - this->profile_->reset_hint (); + this->endpoint_->reset_hint (); + this->endpoint_ = 0; this->profile_ = 0; // @@ Get rid of any forwarding profiles and reset @@ -1392,7 +1423,7 @@ TAO_GIOP_Locate_Request_Invocation::invoke (CORBA::Environment &ACE_TRY_ENV) this->transport_->close_connection (); this->transport_ = 0; - this->profile_->reset_hint (); + this->endpoint_->reset_hint (); // @@ This code abort if the connection for the currenct profile // fails. Should we transparently try new profiles until one diff --git a/TAO/tao/Invocation.h b/TAO/tao/Invocation.h index 260b786208c..1cbad8a5017 100644 --- a/TAO/tao/Invocation.h +++ b/TAO/tao/Invocation.h @@ -45,6 +45,7 @@ struct TAO_Exception_Data; class TAO_Profile; class TAO_Transport; +class TAO_Endpoint; enum TAO_Invoke_Status { @@ -106,14 +107,13 @@ public: TAO_OutputCDR &out_stream (void); // Return the underlying output stream. - TAO_Profile *select_profile_based_on_policy ( - CORBA_Environment &ACE_TRY_ENV = TAO_default_environment () - ) + void select_endpoint_based_on_policy (CORBA_Environment &ACE_TRY_ENV + = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Select the profile we will use to in this invocation, based on - // policies for this object. (Currently the decision is based on a - // single Policy, TAO::Client_Priority_Policy.) I think this + // Select the endpoint (and profile) we will use to in this + // invocation, based on TAO::Client_Priority_Policy.) I think this // function may be more appropriate in TAO_Stub class. + protected: void start (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()) @@ -173,7 +173,10 @@ protected: // This invocation is using this transport, may change... TAO_Profile *profile_; - // This invocation is using this transport, may change... + // This invocation is this profile. + + TAO_Endpoint *endpoint_; + // This invocation is using this endpoint from <profile_>. ACE_Time_Value max_wait_time_value_; ACE_Time_Value *max_wait_time_; diff --git a/TAO/tao/Pluggable.h b/TAO/tao/Pluggable.h index 57e4cf2c83e..401f3b217d7 100644 --- a/TAO/tao/Pluggable.h +++ b/TAO/tao/Pluggable.h @@ -38,6 +38,7 @@ class ACE_Reactor; class TAO_ORB_Core; class TAO_Stub; +class TAO_Endpoint; class TAO_Profile; class TAO_MProfile; class TAO_Resource_Factory; @@ -302,7 +303,7 @@ public: TAO_MProfile &mprofile) = 0; // Create the corresponding profile for this endpoint. - virtual int is_collocated (const TAO_Profile* profile) = 0; + virtual int is_collocated (const TAO_Endpoint* endpoint) = 0; // Return 1 if the <profile> has the same endpoint as the acceptor. virtual CORBA::ULong endpoint_count (void) = 0; @@ -362,7 +363,7 @@ public: virtual int close (void) = 0; // Shutdown Connector bridge and concreate Connector. - virtual int connect (TAO_Profile *profile, + virtual int connect (TAO_Endpoint *endpoint, TAO_Transport *&, ACE_Time_Value *max_wait_time) = 0; // To support pluggable we need to abstract away the connect() diff --git a/TAO/tao/Profile.cpp b/TAO/tao/Profile.cpp index a693dcba571..722ffaa3071 100644 --- a/TAO/tao/Profile.cpp +++ b/TAO/tao/Profile.cpp @@ -212,11 +212,19 @@ TAO_Profile::the_stub (void) TAO_Unknown_Profile::TAO_Unknown_Profile (CORBA::ULong tag, TAO_ORB_Core *orb_core) - : TAO_Profile (tag, orb_core), + : TAO_Profile (tag, + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)), tagged_profile_ () { } +TAO_Endpoint* +TAO_Unknown_Profile::endpoint (void) +{ + return 0; +} + int TAO_Unknown_Profile::parse_string (const char *, CORBA::Environment &) diff --git a/TAO/tao/Profile.h b/TAO/tao/Profile.h index 305d71e13b4..b7535b9d716 100644 --- a/TAO/tao/Profile.h +++ b/TAO/tao/Profile.h @@ -25,11 +25,12 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "tao/Tagged_Components.h" - #include "tao/PolicyC.h" +#include "tao/GIOP_Message_State.h" class TAO_MProfile; class TAO_Stub; +class TAO_Endpoint; class TAO_ORB_Core; class TAO_Export TAO_Profile @@ -42,8 +43,10 @@ class TAO_Export TAO_Profile // information. This is based on the CORBA IOR definitions. // public: + TAO_Profile (CORBA::ULong tag, - TAO_ORB_Core *orb_core); + TAO_ORB_Core *orb_core, + const TAO_GIOP_Version &version); // Constructor virtual ~TAO_Profile (void); @@ -52,6 +55,13 @@ public: CORBA::ULong tag (void) const; // The tag, each concrete class will have a specific tag value. + const TAO_GIOP_Version& version (void) const; + // Return a pointer to this profile's version. This object + // maintains ownership. + + virtual TAO_Endpoint *endpoint (void) = 0; + // + TAO_ORB_Core *orb_core (void) const; // Get a poiter to the TAO_ORB_Core @@ -107,17 +117,6 @@ public: CORBA::Environment &ACE_TRY_ENV) = 0; // Return a hash value for this object. - virtual int addr_to_string (char *buffer, size_t length) = 0; - // Return a string representation for the address. Returns - // -1 if buffer is too small. The purpose of this method is to - // provide a general interface to the underlying address object's - // addr_to_string method. This allows the protocol implementor to - // select the appropriate string format. - - virtual void reset_hint (void) = 0; - // This method is used with a connection has been reset requiring - // the hint to be cleaned up and reset to NULL. - virtual IOP::TaggedProfile &create_tagged_profile (void) = 0; // This method is used to get the IOP::taggedProfile. The profile // information that is received from the server side would have @@ -148,6 +147,9 @@ private: ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Profile&)) protected: + TAO_GIOP_Version version_; + // IIOP version number. + TAO_Tagged_Components tagged_components_; // The tagged components @@ -207,6 +209,7 @@ public: // Create the profile // = The TAO_Profile methods look above + virtual TAO_Endpoint *endpoint (void); virtual int parse_string (const char *string, CORBA::Environment &ACE_TRY_ENV); virtual char object_key_delimiter (void) const; diff --git a/TAO/tao/Profile.i b/TAO/tao/Profile.i index 09a99e4261e..8a6ad57f4b8 100644 --- a/TAO/tao/Profile.i +++ b/TAO/tao/Profile.i @@ -3,8 +3,10 @@ ACE_INLINE TAO_Profile::TAO_Profile (CORBA::ULong tag, - TAO_ORB_Core *orb_core) - : are_policies_parsed_ (0), + TAO_ORB_Core *orb_core, + const TAO_GIOP_Version &version) + : version_ (version), + are_policies_parsed_ (0), policy_list_ (0), tag_ (tag), orb_core_ (orb_core), @@ -19,6 +21,12 @@ TAO_Profile::tag (void) const return this->tag_; } +ACE_INLINE const TAO_GIOP_Version & +TAO_Profile::version (void) const +{ + return this->version_; +} + ACE_INLINE TAO_ORB_Core * TAO_Profile::orb_core (void) const { diff --git a/TAO/tao/SHMIOP_Acceptor.cpp b/TAO/tao/SHMIOP_Acceptor.cpp index 7b190dd15e1..61250cc3972 100644 --- a/TAO/tao/SHMIOP_Acceptor.cpp +++ b/TAO/tao/SHMIOP_Acceptor.cpp @@ -74,9 +74,10 @@ TAO_SHMIOP_Acceptor::~TAO_SHMIOP_Acceptor (void) // interfaces over which we can receive requests. Thus a profile // must be made for each one. -int -TAO_SHMIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, - TAO_MProfile &mprofile) + +int +TAO_SHMIOP_Acceptor::create_profile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) { // @@ we only make one for now int count = mprofile.profile_count (); @@ -94,6 +95,8 @@ TAO_SHMIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, this->orb_core_), -1); + pfile->endpoint ()->priority (this->priority_); + if (mprofile.give_profile (pfile) == -1) { pfile->_decr_refcnt (); @@ -113,24 +116,83 @@ TAO_SHMIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, TAO_DEFAULT_WCHAR_CODESET_ID; pfile->tagged_components ().set_code_sets (code_set_info); - pfile->tagged_components ().set_tao_priority (this->priority ()); - return 0; } int -TAO_SHMIOP_Acceptor::is_collocated (const TAO_Profile *pfile) +TAO_SHMIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) +{ + // If RT_CORBA is enabled, only one SHMIOP profile is created for + // <mprofile> and all SHMIOP endpoints are added into that profile. + // If RT_CORBA is not enabled, we create a separate profile for each + // endpoint. + +#if (TAO_HAS_RT_CORBA == 1) + + return create_rt_mprofile (object_key, mprofile); + +#else /* TAO_HAS_RT_CORBA == 1 */ + + return create_profile (object_key, mprofile); + +#endif /* TAO_HAS_RT_CORBA == 1 */ +} + +int +TAO_SHMIOP_Acceptor::create_rt_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) +{ + TAO_Profile *pfile = 0; + TAO_SHMIOP_Profile *shmiop_profile = 0; + + // First see if <mprofile> already contains a SHMIOP profile. + for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i) + { + pfile = mprofile.get_profile (i); + if (pfile->tag () == TAO_TAG_SHMEM_PROFILE) + { + shmiop_profile = ACE_dynamic_cast (TAO_SHMIOP_Profile *, + pfile); + break; + } + } + + if (shmiop_profile == 0) + { + // If <mprofile> doesn't contain SHMIOP_Profile, we need to create + // one. + return create_profile (object_key, mprofile); + } + else + { + // There already is a SHMIOP_Profile - just add our endpoint to it. + + TAO_SHMIOP_Endpoint *endpoint = 0; + ACE_NEW_RETURN (endpoint, + TAO_SHMIOP_Endpoint (this->host_.c_str (), + this->address_.get_port_number (), + this->address_.get_remote_addr ()), + -1); + endpoint->priority (this->priority_); + shmiop_profile->add_endpoint (endpoint); + + return 0; + } +} + +int +TAO_SHMIOP_Acceptor::is_collocated (const TAO_Endpoint *endpoint) { - const TAO_SHMIOP_Profile *profile = - ACE_dynamic_cast(const TAO_SHMIOP_Profile *, - pfile); + const TAO_SHMIOP_Endpoint *endp = + ACE_dynamic_cast(const TAO_SHMIOP_Endpoint *, endpoint); // Make sure the dynamically cast pointer is valid. - if (profile == 0) + if (endp == 0) return 0; // compare the port and sin_addr (numeric host address) - return this->address_.same_host (profile->object_addr ()); + return this->address_.same_host (endp->object_addr ()); } int diff --git a/TAO/tao/SHMIOP_Acceptor.h b/TAO/tao/SHMIOP_Acceptor.h index 3aff41db3a6..85ea51ea9df 100644 --- a/TAO/tao/SHMIOP_Acceptor.h +++ b/TAO/tao/SHMIOP_Acceptor.h @@ -71,7 +71,7 @@ public: virtual int close (void); virtual int create_mprofile (const TAO_ObjectKey &object_key, TAO_MProfile &mprofile); - virtual int is_collocated (const TAO_Profile* profile); + virtual int is_collocated (const TAO_Endpoint* endpoint); virtual CORBA::ULong endpoint_count (void); virtual int object_key (IOP::TaggedProfile &profile, @@ -83,6 +83,17 @@ private: virtual int parse_options (const char *options); // Parse protocol specific options. + int create_rt_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile); + // Rather than creating a profile for each endpoint, this version of + // <create_mprofile> adds an endpoint to an existing SHMIOP profile + // if one already exists. + + int create_profile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile); + // Create a SHMIOP profile representing this acceptor. Factors out + // common functionality of <create_mprofile> and <create_rt_mprofile>. + protected: ACE_CString host_; // Cache the information about the endpoint serviced by this diff --git a/TAO/tao/SHMIOP_Connector.cpp b/TAO/tao/SHMIOP_Connector.cpp index 058c4e2e660..8cd3ae1d4a5 100644 --- a/TAO/tao/SHMIOP_Connector.cpp +++ b/TAO/tao/SHMIOP_Connector.cpp @@ -437,21 +437,21 @@ TAO_SHMIOP_Connector::close (void) } int -TAO_SHMIOP_Connector::connect (TAO_Profile *profile, +TAO_SHMIOP_Connector::connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time) { - if (profile->tag () != TAO_TAG_SHMEM_PROFILE) + if (endpoint->tag () != TAO_TAG_SHMEM_PROFILE) return -1; - TAO_SHMIOP_Profile *shmiop_profile = - ACE_dynamic_cast (TAO_SHMIOP_Profile *, - profile); - if (shmiop_profile == 0) + TAO_SHMIOP_Endpoint *shmiop_endpoint = + ACE_dynamic_cast (TAO_SHMIOP_Endpoint *, + endpoint); + if (shmiop_endpoint == 0) return -1; const ACE_INET_Addr &remote_address = - shmiop_profile->object_addr (); + shmiop_endpoint->object_addr (); // Verify that the remote ACE_INET_Addr was initialized properly. // Failure can occur if hostname lookup failed when initializing the @@ -483,7 +483,7 @@ TAO_SHMIOP_Connector::connect (TAO_Profile *profile, // object; but we obtain the transport in the <svc_handler> // variable. Other threads may modify the hint, but we are not // affected. - result = this->base_connector_.connect (shmiop_profile->hint (), + result = this->base_connector_.connect (shmiop_endpoint->hint (), svc_handler, remote_address, synch_options); @@ -494,7 +494,7 @@ TAO_SHMIOP_Connector::connect (TAO_Profile *profile, // object; but we obtain the transport in the <svc_handler> // variable. Other threads may modify the hint, but we are not // affected. - result = this->base_connector_.connect (shmiop_profile->hint (), + result = this->base_connector_.connect (shmiop_endpoint->hint (), svc_handler, remote_address); } @@ -504,7 +504,7 @@ TAO_SHMIOP_Connector::connect (TAO_Profile *profile, if (TAO_orbdebug) { char buffer [MAXNAMELEN * 2]; - profile->addr_to_string (buffer, + endpoint->addr_to_string (buffer, (MAXNAMELEN * 2) - 1); ACE_DEBUG ((LM_ERROR, ACE_TEXT ("(%P|%t) %s:%u, connection to ") @@ -519,21 +519,6 @@ TAO_SHMIOP_Connector::connect (TAO_Profile *profile, transport = svc_handler->transport (); - // Now that we have the client connection handler object we need to - // set the right messaging protocol for the connection handler. - const TAO_GIOP_Version& version = shmiop_profile->version (); - int ret_val = transport->messaging_init (version.major, - version.minor); - if (ret_val == -1) - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%N|%l|%p|%t) init_mesg_protocol () failed \n"))); - } - return -1; - } - return 0; } diff --git a/TAO/tao/SHMIOP_Connector.h b/TAO/tao/SHMIOP_Connector.h index 723efdc65cd..2444851d9ac 100644 --- a/TAO/tao/SHMIOP_Connector.h +++ b/TAO/tao/SHMIOP_Connector.h @@ -103,7 +103,7 @@ public: // Pluggable.h int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_Profile *profile, + int connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time); int preconnect (const char *preconnections); diff --git a/TAO/tao/SHMIOP_Endpoint.cpp b/TAO/tao/SHMIOP_Endpoint.cpp new file mode 100644 index 00000000000..d1e7eb02ae2 --- /dev/null +++ b/TAO/tao/SHMIOP_Endpoint.cpp @@ -0,0 +1,139 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +#include "tao/SHMIOP_Endpoint.h" + +#if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0) + +#include "tao/SHMIOP_Connect.h" +#include "tao/debug.h" + +ACE_RCSID(tao, SHMIOP_Endpoint, "$Id$") + +#if !defined (__ACE_INLINE__) +# include "tao/SHMIOP_Endpoint.i" +#endif /* __ACE_INLINE__ */ + +TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint (const ACE_MEM_Addr &addr, + int use_dotted_decimal_addresses) + : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE), + host_ (), + port_ (0), + object_addr_ (addr.get_remote_addr ()), + hint_ (0), + next_ (0) +{ + this->set (addr.get_remote_addr (), use_dotted_decimal_addresses); +} + +TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint (const char *host, + CORBA::UShort port, + const ACE_INET_Addr &addr) + : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE), + host_ (), + port_ (port), + object_addr_ (addr), + hint_ (0), + next_ (0) +{ + if (host != 0) + this->host_ = host; +} + +TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint (void) + : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE), + host_ (), + port_ (0), + object_addr_ (), + hint_ (0), + next_ (0) +{ +} + +TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint (const char *host, + CORBA::UShort port, + CORBA::Short priority) + : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE), + host_ (), + port_ (port), + object_addr_ (), + hint_ (0), + next_ (0) +{ + if (host != 0) + this->host_ = host; + + this->object_addr_.set_type (-1); + this->priority (priority); +} + +TAO_SHMIOP_Endpoint::~TAO_SHMIOP_Endpoint (void) +{ +} + +int +TAO_SHMIOP_Endpoint::set (const ACE_INET_Addr &addr, + int use_dotted_decimal_addresses) +{ + char tmp_host[MAXHOSTNAMELEN + 1]; + + if (use_dotted_decimal_addresses + || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) + { + const char *tmp = addr.get_host_addr (); + if (tmp == 0) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\n\nTAO (%P|%t) ") + ACE_TEXT ("SHMIOP_Endpoint::set ") + ACE_TEXT ("- %p\n\n"), + ACE_TEXT ("cannot determine hostname"))); + return -1; + } + else + this->host_ = tmp; + } + else + this->host_ = CORBA::string_dup (tmp_host); + + this->port_ = addr.get_port_number(); + + return 0; +} + +int +TAO_SHMIOP_Endpoint::addr_to_string (char *buffer, size_t length) +{ + size_t actual_len = + ACE_OS::strlen (this->host_.in ()) // chars in host name + + sizeof (':') // delimiter + + ACE_OS::strlen ("65536") // max port + + sizeof ('\0'); + + if (length < actual_len) + return -1; + + ACE_OS::sprintf (buffer, "%s:%d", + this->host_.in (), this->port_); + + return 0; +} + +const char * +TAO_SHMIOP_Endpoint::host (const char *h) +{ + this->host_ = h; + + return this->host_.in (); +} + +void +TAO_SHMIOP_Endpoint::reset_hint (void) +{ + if (this->hint_) + this->hint_->cleanup_hint ((void **) &this->hint_); +} + +#endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */ diff --git a/TAO/tao/SHMIOP_Endpoint.h b/TAO/tao/SHMIOP_Endpoint.h new file mode 100644 index 00000000000..89acc3dedb8 --- /dev/null +++ b/TAO/tao/SHMIOP_Endpoint.h @@ -0,0 +1,142 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// SHMIOP_Endpoint.h +// +// = AUTHOR +// Marina Spivak <marina@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_SHMIOP_ENDPOINT_H +#define TAO_SHMIOP_ENDPOINT_H +#include "ace/pre.h" + +#include "tao/Endpoint.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0) + +#include "tao/ORB.h" + +#include "ace/INET_Addr.h" +#include "ace/MEM_Addr.h" + +class TAO_SHMIOP_Client_Connection_Handler; + +class TAO_Export TAO_SHMIOP_Endpoint : public TAO_Endpoint +{ + // = TITLE + // This class defines the protocol specific attributes required + // for locating ORBs over a TCP/IP network. + // + // = DESCRIPTION + // This class defines the IIOP profile as specified in the CORBA + // specification. +public: + + friend class TAO_SHMIOP_Profile; + + TAO_SHMIOP_Endpoint (const ACE_MEM_Addr &addr, + int use_dotted_decimal_addresses); + // Profile constructor + + TAO_SHMIOP_Endpoint (const char *host, + CORBA::UShort port, + const ACE_INET_Addr &addr); + // Endpoint constructor, this is the most efficient since it + // doesn't require any address resolution processing. + + TAO_SHMIOP_Endpoint (const char *host, + CORBA::UShort port, + CORBA::Short priority); + // Endpoint constructor - used when decoding endpoints from the wire. + + TAO_SHMIOP_Endpoint (void); + // Endpoint constructor, default. + + ~TAO_SHMIOP_Endpoint (void); + // Destructor is to be called only through <_decr_refcnt>. + + CORBA::Boolean is_equivalent (const TAO_SHMIOP_Endpoint *other_endpoint); + // Return true if this profile is equivalent to other_profile. Two + // profiles are equivalent iff their key, port, host, object_key and + // version are the same. + + CORBA::ULong hash (void); + // Return a hash value for this object. + + // = Abstract Endpoint interface methods. + + TAO_Endpoint *next (void); + // Return the next endpoint in the list. + + virtual int addr_to_string (char *buffer, size_t length); + // Return a string representation for the address. + + virtual void reset_hint (void); + // Reset the hint's value. + + // = IIOP Endpoint methods. + + const ACE_INET_Addr &object_addr (void) const; + // return a reference to the object_addr. + + const char *host (void) const; + // Return a pointer to the host string. This object maintains + // ownership of this string. + + const char *host (const char *h); + // Copy the string h into <host_> and return the resulting pointer. + // This object maintains ownership of this string. + + CORBA::UShort port (void) const; + // Return the port number. + + CORBA::UShort port (CORBA::UShort p); + // Set the port number. + + TAO_SHMIOP_Client_Connection_Handler *&hint (void); + // This is a hint for which connection handler to use. + +private: + int set (const ACE_INET_Addr &addr, + int use_dotted_decimal_addresses); + // helper method to set the INET_Addr. + + CORBA::String_var host_; + // String representing the hosts name. + + CORBA::UShort port_; + // TCP port number + + ACE_INET_Addr object_addr_; + // Cached instance of <ACE_INET_Addr> for use in making + // invocations, etc. + + TAO_SHMIOP_Client_Connection_Handler *hint_; + // Pointer to a connection handler which we successfully used + // already. + + TAO_SHMIOP_Endpoint *next_; + // Next endpoint in the list. +}; + +#if defined (__ACE_INLINE__) +# include "tao/SHMIOP_Endpoint.i" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */ + +#include "ace/post.h" +#endif /* TAO_IIOP_PROFILE_H */ diff --git a/TAO/tao/SHMIOP_Endpoint.i b/TAO/tao/SHMIOP_Endpoint.i new file mode 100644 index 00000000000..538fc2bcc65 --- /dev/null +++ b/TAO/tao/SHMIOP_Endpoint.i @@ -0,0 +1,80 @@ +// -*- C++ -*- +// $Id$ + +ACE_INLINE const ACE_INET_Addr & +TAO_SHMIOP_Endpoint::object_addr (void) const +{ + // The object_addr_ is initialized here, rather than at IOR decode + // time for several reasons: + // 1. A request on the object may never be invoked. + // 2. The DNS setup may have changed dynamically. + // ...etc.. + + // We need to modify the object_addr_ in this method. Do so using a + // non-const copy of the <this> pointer. + TAO_SHMIOP_Endpoint *endpoint = + ACE_const_cast (TAO_SHMIOP_Endpoint *, + this); + + if (this->object_addr_.get_type () != AF_INET + && endpoint->object_addr_.set (this->port_, + this->host_.in ()) == -1) + { + // If this call fails, it most likely due a hostname lookup + // failure caused by a DNS misconfiguration. If a request is + // made to the object at the given host and port, then a + // CORBA::TRANSIENT() exception should be thrown. + + // Invalidate the ACE_INET_Addr. This is used as a flag to + // denote that ACE_INET_Addr initialization failed. + endpoint->object_addr_.set_type (-1); + } + + return this->object_addr_; +} + +ACE_INLINE const char * +TAO_SHMIOP_Endpoint::host (void) const +{ + return this->host_.in (); +} + +ACE_INLINE CORBA::UShort +TAO_SHMIOP_Endpoint::port (void) const +{ + return this->port_; +} + +ACE_INLINE CORBA::UShort +TAO_SHMIOP_Endpoint::port (CORBA::UShort p) +{ + return this->port_ = p; +} + +ACE_INLINE TAO_SHMIOP_Client_Connection_Handler *& +TAO_SHMIOP_Endpoint::hint (void) +{ + return this->hint_; +} + +ACE_INLINE CORBA::ULong +TAO_SHMIOP_Endpoint::hash (void) +{ + return + ACE::hash_pjw (this->host_.in ()) + + this->port_; +} + +ACE_INLINE CORBA::Boolean +TAO_SHMIOP_Endpoint::is_equivalent (const TAO_SHMIOP_Endpoint *other_endpoint) +{ + return + this->port_ == other_endpoint->port_ + && ACE_OS::strcmp (this->host_.in (), other_endpoint->host_.in ()) == 0; +} + +ACE_INLINE TAO_Endpoint * +TAO_SHMIOP_Endpoint::next (void) +{ + return this->next_; +} diff --git a/TAO/tao/SHMIOP_Profile.cpp b/TAO/tao/SHMIOP_Profile.cpp index bad4a5c6980..aa42c9982b8 100644 --- a/TAO/tao/SHMIOP_Profile.cpp +++ b/TAO/tao/SHMIOP_Profile.cpp @@ -5,12 +5,12 @@ #if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0) -#include "tao/SHMIOP_Connect.h" #include "tao/CDR.h" #include "tao/Environment.h" #include "tao/ORB.h" #include "tao/ORB_Core.h" #include "tao/debug.h" +#include "tao/iiop_endpoints.h" ACE_RCSID(tao, SHMIOP_Profile, "$Id$") @@ -32,17 +32,14 @@ TAO_SHMIOP_Profile::TAO_SHMIOP_Profile (const ACE_MEM_Addr &addr, const TAO_ObjectKey &object_key, const TAO_GIOP_Version &version, TAO_ORB_Core *orb_core) - : TAO_Profile (TAO_TAG_SHMEM_PROFILE, - orb_core), - host_ (), - port_ (0), - version_ (version), + : TAO_Profile (TAO_TAG_SHMEM_PROFILE, orb_core, version), + endpoint_ (addr, + orb_core->orb_params ()->use_dotted_decimal_addresses ()), + count_ (1), + endpoints_encoded_ (0), object_key_ (object_key), - object_addr_ (addr.get_remote_addr ()), - hint_ (0), tagged_profile_ () { - this->set (addr.get_remote_addr ()); } TAO_SHMIOP_Profile::TAO_SHMIOP_Profile (const char* host, @@ -51,30 +48,26 @@ TAO_SHMIOP_Profile::TAO_SHMIOP_Profile (const char* host, const ACE_INET_Addr &addr, const TAO_GIOP_Version &version, TAO_ORB_Core *orb_core) - : TAO_Profile (TAO_TAG_SHMEM_PROFILE, - orb_core), - host_ (), - port_ (port), - version_ (version), + : TAO_Profile (TAO_TAG_SHMEM_PROFILE, orb_core, version), + endpoint_ (host, port, addr), + count_ (1), + endpoints_encoded_ (0), object_key_ (object_key), - object_addr_ (addr), - hint_ (0) + tagged_profile_ () { - if (host != 0) - this->host_ = host; } TAO_SHMIOP_Profile::TAO_SHMIOP_Profile (const char *string, TAO_ORB_Core *orb_core, CORBA::Environment &ACE_TRY_ENV) : TAO_Profile (TAO_TAG_SHMEM_PROFILE, - orb_core), - host_ (), - port_ (0), - version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)), + endpoint_ (), + count_ (1), + endpoints_encoded_ (0), object_key_ (), - object_addr_ (), - hint_ (0) + tagged_profile_ () { parse_string (string, ACE_TRY_ENV); ACE_CHECK; @@ -82,48 +75,34 @@ TAO_SHMIOP_Profile::TAO_SHMIOP_Profile (const char *string, TAO_SHMIOP_Profile::TAO_SHMIOP_Profile (TAO_ORB_Core *orb_core) : TAO_Profile (TAO_TAG_SHMEM_PROFILE, - orb_core), - host_ (), - port_ (0), - version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)), + endpoint_ (), + count_ (1), + endpoints_encoded_ (0), object_key_ (), - object_addr_ (), - hint_ (0) + tagged_profile_ () { } -int -TAO_SHMIOP_Profile::set (const ACE_INET_Addr &addr) +TAO_SHMIOP_Profile::~TAO_SHMIOP_Profile (void) { - char tmp_host[MAXHOSTNAMELEN + 1]; + // Clean up endpoint list. + TAO_Endpoint *tmp = 0; - if (this->orb_core ()->orb_params ()->use_dotted_decimal_addresses () - || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) + for (TAO_Endpoint *next = this->endpoint ()->next (); + next != 0; + next = tmp) { - const char *tmp = addr.get_host_addr (); - if (tmp == 0) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\n\nTAO (%P|%t) ") - ACE_TEXT ("SHMIOP_Profile::set ") - ACE_TEXT ("- %p\n\n"), - ACE_TEXT ("cannot determine hostname"))); - return -1; - } - else - this->host_ = tmp; + tmp = next->next (); + delete next; } - else - this->host_ = CORBA::string_dup (tmp_host); - - this->port_ = addr.get_port_number(); - - return 0; } -TAO_SHMIOP_Profile::~TAO_SHMIOP_Profile (void) +TAO_Endpoint* +TAO_SHMIOP_Profile::endpoint (void) { + return &this->endpoint_; } // return codes: @@ -154,8 +133,8 @@ TAO_SHMIOP_Profile::decode (TAO_InputCDR& cdr) } // Get host and port - if (cdr.read_string (this->host_.out ()) == 0 - || cdr.read_ushort (this->port_) == 0) + if (cdr.read_string (this->endpoint_.host_.out ()) == 0 + || cdr.read_ushort (this->endpoint_.port_) == 0) { if (TAO_debug_level > 0) { @@ -189,10 +168,13 @@ TAO_SHMIOP_Profile::decode (TAO_InputCDR& cdr) encap_len)); } + // Decode endpoints if any. + this->decode_endpoints (); + if (cdr.good_bit ()) { // Invalidate the object_addr_ until first access. - this->object_addr_.set_type (-1); + this->endpoint_.object_addr_.set_type (-1); return 1; } @@ -284,7 +266,7 @@ TAO_SHMIOP_Profile::parse_string (const char *string, ACE_OS::strncpy (tmp.inout (), cp + 1, length); tmp[length] = '\0'; - this->port_ = (CORBA::UShort) ACE_OS::atoi (tmp.in ()); + this->endpoint_.port_ = (CORBA::UShort) ACE_OS::atoi (tmp.in ()); length = cp - start; @@ -293,10 +275,10 @@ TAO_SHMIOP_Profile::parse_string (const char *string, ACE_OS::strncpy (tmp.inout (), start, length); tmp[length] = '\0'; - this->host_ = tmp._retn (); + this->endpoint_.host_ = tmp._retn (); - if (this->object_addr_.set (this->port_, - this->host_.in ()) == -1) + if (this->endpoint_.object_addr_.set (this->endpoint_.port_, + this->endpoint_.host_.in ()) == -1) { if (TAO_debug_level > 0) { @@ -326,21 +308,43 @@ TAO_SHMIOP_Profile::is_equivalent (const TAO_Profile *other_profile) ACE_ASSERT (op->object_key_.length () < UINT_MAX); - return this->port_ == op->port_ - && this->object_key_ == op->object_key_ - && ACE_OS::strcmp (this->host_.in (), op->host_.in ()) == 0 - && this->version_ == op->version_; + if (!(this->object_key_ == op->object_key_ + && this->version_ == op->version_ + && this->count_ == op->count_)) + return 0; + + // Check endpoints equivalence. + // @@ Are we guaranteed that the endpoints in both profiles will be + // in the same order? + const TAO_SHMIOP_Endpoint *other_endp = &op->endpoint_; + for (TAO_SHMIOP_Endpoint *endp = &this->endpoint_; + endp != 0; + endp = endp->next_) + { + if (endp->is_equivalent (other_endp)) + other_endp = other_endp->next_; + else + return 0; + } + + return 1; } CORBA::ULong TAO_SHMIOP_Profile::hash (CORBA::ULong max, CORBA::Environment &) { - CORBA::ULong hashval = - ACE::hash_pjw (this->host_.in ()) - + this->port_ - + this->version_.minor - + this->tag (); + // Get the hashvalue for all endpoints. + CORBA::ULong hashval = 0; + for (TAO_SHMIOP_Endpoint *endp = &this->endpoint_; + endp != 0; + endp = endp->next_) + { + hashval += endp->hash (); + } + + hashval += this->version_.minor; + hashval += this->tag (); if (this->object_key_.length () >= 4) { @@ -351,37 +355,13 @@ TAO_SHMIOP_Profile::hash (CORBA::ULong max, return hashval % max; } -int -TAO_SHMIOP_Profile::addr_to_string (char *buffer, size_t length) -{ - size_t actual_len = - ACE_OS::strlen (this->host_.in ()) // chars in host name - + sizeof (':') // delimiter - + ACE_OS::strlen ("65536") // max port - + sizeof ('\0'); - - if (length < actual_len) - return -1; - - ACE_OS::sprintf (buffer, "%s:%d", - this->host_.in (), this->port_); - - return 0; -} - -const char * -TAO_SHMIOP_Profile::host (const char *h) -{ - this->host_ = h; - - return this->host_.in (); -} - void -TAO_SHMIOP_Profile::reset_hint (void) +TAO_SHMIOP_Profile::add_endpoint (TAO_SHMIOP_Endpoint *endp) { - if (this->hint_) - this->hint_->cleanup_hint ((void **) &this->hint_); + endp->next_ = this->endpoint_.next_; + this->endpoint_.next_ = endp; + + this->count_++; } char * @@ -399,7 +379,7 @@ TAO_SHMIOP_Profile::to_string (CORBA::Environment &) 1 /* decimal point */ + 1 /* minor version */ + 1 /* `@' character */ + - ACE_OS::strlen (this->host_.in ()) + + ACE_OS::strlen (this->endpoint_.host ()) + 1 /* colon separator */ + 5 /* port number */ + 1 /* object key separator */ + @@ -414,8 +394,8 @@ TAO_SHMIOP_Profile::to_string (CORBA::Environment &) ::prefix_, digits [this->version_.major], digits [this->version_.minor], - this->host_.in (), - this->port_, + this->endpoint_.host (), + this->endpoint_.port (), this->object_key_delimiter_, key.in ()); return buf; @@ -508,17 +488,121 @@ TAO_SHMIOP_Profile::create_profile_body (TAO_OutputCDR &encap) const encap.write_octet (this->version_.minor); // STRING hostname from profile - encap.write_string (this->host_.in ()); + encap.write_string (this->endpoint_.host ()); // UNSIGNED SHORT port number - encap.write_ushort (this->port_); + encap.write_ushort (this->endpoint_.port ()); // OCTET SEQUENCE for object key encap << this->object_key_; + // Encode profile endpoints. + TAO_SHMIOP_Profile *p = + ACE_const_cast (TAO_SHMIOP_Profile *, this); + if (!endpoints_encoded_) + p->encode_endpoints (); + if (this->version_.major > 1 || this->version_.minor > 0) this->tagged_components ().encode (encap); } +int +TAO_SHMIOP_Profile::encode_endpoints (void) +{ + // Create a data structure with endpoint info for wire transfer. + TAO_IIOPEndpointSequence endpoints; + endpoints.length (this->count_); + + TAO_SHMIOP_Endpoint *endpoint = &this->endpoint_; + for (size_t i = 0; + i < this->count_; + ++i) + { + endpoints[i].host = endpoint->host (); + endpoints[i].port = endpoint->port (); + endpoints[i].priority = endpoint->priority (); + + endpoint = endpoint->next_; + } + + // Encode. + TAO_OutputCDR out_cdr; + out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); + out_cdr << endpoints; + CORBA::ULong length = out_cdr.total_length (); + + IOP::TaggedComponent tagged_component; + tagged_component.tag = TAO_TAG_ENDPOINTS; + tagged_component.component_data.length (length); + CORBA::Octet *buf = + tagged_component.component_data.get_buffer (); + + for (const ACE_Message_Block *iterator = out_cdr.begin (); + iterator != 0; + iterator = iterator->cont ()) + { + CORBA::ULong i_length = iterator->length (); + ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length); + + buf += i_length; + } + + // Eventually we add the TaggedComponent to the TAO_TaggedComponents + // member variable. + tagged_components_.set_component (tagged_component); + this->endpoints_encoded_ = 1; + + return 1; +} + +int +TAO_SHMIOP_Profile::decode_endpoints (void) +{ + IOP::TaggedComponent tagged_component; + tagged_component.tag = TAO_TAG_ENDPOINTS; + + if (this->tagged_components_.get_component (tagged_component)) + { + const CORBA::Octet *buf = + tagged_component.component_data.get_buffer (); + + TAO_InputCDR in_cdr (ACE_reinterpret_cast (const char*, buf), + tagged_component.component_data.length ()); + + // Extract the Byte Order. + CORBA::Boolean byte_order; + if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + return 0; + in_cdr.reset_byte_order (ACE_static_cast(int, byte_order)); + + // Extract endpoints sequence. + TAO_IIOPEndpointSequence endpoints; + in_cdr >> endpoints; + + // Get the priority of the first endpoint. It's other data is + // extracted as part of the standard iiop decoding. + this->endpoint_.priority (endpoints[0].priority); + + // Start with the second endpoint, because the first endpoint is + // always extracted through standard iiop profile body. + for (CORBA::ULong i = 1; i < endpoints.length (); ++i) + { + TAO_SHMIOP_Endpoint *endpoint = 0; + ACE_NEW_RETURN (endpoint, + TAO_SHMIOP_Endpoint (endpoints[i].host, + endpoints[i].port, + endpoints[i].priority), + 0); + + this->add_endpoint (endpoint); + } + } + + this->endpoints_encoded_ = 1; + return 1; +} + + + #endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */ diff --git a/TAO/tao/SHMIOP_Profile.h b/TAO/tao/SHMIOP_Profile.h index b1f381dadfb..ace1d444640 100644 --- a/TAO/tao/SHMIOP_Profile.h +++ b/TAO/tao/SHMIOP_Profile.h @@ -30,12 +30,10 @@ #if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0) #include "tao/Profile.h" -#include "tao/ORB.h" #include "tao/Object_KeyC.h" -#include "tao/GIOP_Message_State.h" +#include "tao/SHMIOP_Endpoint.h" #include "ace/Synch.h" -#include "ace/MEM_Addr.h" class TAO_SHMIOP_Client_Connection_Handler; @@ -83,6 +81,12 @@ public: ~TAO_SHMIOP_Profile (void); // Destructor is to be called only through <_decr_refcnt>. + virtual TAO_Endpoint *endpoint (void); + // + + void add_endpoint (TAO_SHMIOP_Endpoint *endp); + // + int parse_string (const char *string, CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()); @@ -116,68 +120,33 @@ public: TAO_default_environment ()); // Return a hash value for this object. - int addr_to_string (char *buffer, size_t length); - // Return a string representation for the address. - - const ACE_INET_Addr &object_addr (void) const; - // Return a reference to the object_addr. - - const char *host (void) const; - // Return a pointer to the host string. This object maintains - // ownership of this string. - - const char *host (const char *h); - // Copy the string h into <host_> and return the resulting pointer. - // This object maintains ownership of this string. - - CORBA::UShort port (void) const; - // Return the port number. - - CORBA::UShort port (CORBA::UShort p); - // Set the port number. - - const TAO_GIOP_Version& version (void) const; - // Return a pointer to this profile's version. This object - // maintains ownership. - - TAO_SHMIOP_Client_Connection_Handler *&hint (void); - // This is a hint for which connection handler to use. - - void reset_hint (void); - // Reset the hint's value. - IOP::TaggedProfile &create_tagged_profile (void); // Please refer to Profile.h for the documentation of this method private: - int set (const ACE_INET_Addr &addr); - // helper method to set the INET_Addr. - -private: void create_profile_body (TAO_OutputCDR &cdr) const; // Create an encapsulation of the struct ProfileBody in <cdr> + + int encode_endpoints (void); + // Encodes endpoints from this profile into a tagged component. + + int decode_endpoints (void); + // Decodes endpoints of this profile from a tagged component. - CORBA::String_var host_; - // String representing the hosts name. + TAO_SHMIOP_Endpoint endpoint_; + // - CORBA::UShort port_; - // TCP port number + size_t count_; + // Number of endpoints this profile contains. - TAO_GIOP_Version version_; - // GIOP version number. + int endpoints_encoded_; + // Flag indicating whether endpoints have already been encoded, + // saving us from repeatedly encoding them over and over. TAO_ObjectKey object_key_; // object_key associated with this profile. - ACE_INET_Addr object_addr_; - // Cached instance of <ACE_INET_Addr> for use in making - // invocations, etc. - - TAO_SHMIOP_Client_Connection_Handler *hint_; - // Pointer to a connection handler which we successfully used - // already. - IOP::TaggedProfile tagged_profile_; // The tagged profile info }; diff --git a/TAO/tao/SHMIOP_Profile.i b/TAO/tao/SHMIOP_Profile.i index a5fb3610ddd..077e9117286 100644 --- a/TAO/tao/SHMIOP_Profile.i +++ b/TAO/tao/SHMIOP_Profile.i @@ -18,65 +18,3 @@ TAO_SHMIOP_Profile::_key (void) const return key; } - -ACE_INLINE const ACE_INET_Addr & -TAO_SHMIOP_Profile::object_addr (void) const -{ - // The object_addr_ is initialized here, rather than at IOR decode - // time for several reasons: - // 1. A request on the object may never be invoked. - // 2. The DNS setup may have changed dynamically. - // ...etc.. - - // We need to modify the object_addr_ in this method. Do so using a - // non-const copy of the <this> pointer. - TAO_SHMIOP_Profile *profile = - ACE_const_cast (TAO_SHMIOP_Profile *, - this); - - if (this->object_addr_.get_type () != AF_INET - && profile->object_addr_.set (this->port_, - this->host_.in ()) == -1) - { - // If this call fails, it most likely due a hostname lookup - // failure caused by a DNS misconfiguration. If a request is - // made to the object at the given host and port, then a - // CORBA::TRANSIENT() exception should be thrown. - - // Invalidate the ACE_INET_Addr. This is used as a flag to - // denote that ACE_INET_Addr initialization failed. - profile->object_addr_.set_type (-1); - } - - return this->object_addr_; -} - -ACE_INLINE const char * -TAO_SHMIOP_Profile::host (void) const -{ - return this->host_.in (); -} - -ACE_INLINE CORBA::UShort -TAO_SHMIOP_Profile::port (void) const -{ - return this->port_; -} - -ACE_INLINE CORBA::UShort -TAO_SHMIOP_Profile::port (CORBA::UShort p) -{ - return this->port_ = p; -} - -ACE_INLINE const TAO_GIOP_Version & -TAO_SHMIOP_Profile::version (void) const -{ - return this->version_; -} - -ACE_INLINE TAO_SHMIOP_Client_Connection_Handler *& -TAO_SHMIOP_Profile::hint (void) -{ - return this->hint_; -} diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index 82660f16cab..42607b3d55e 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -10,6 +10,7 @@ // based implementation, and can neither be used by other kinds of // objref nor have a default implementation. +#include "tao/Endpoint.h" #include "tao/Stub.h" #include "tao/Sequence.h" #include "tao/Object.h" @@ -119,7 +120,7 @@ TAO_Stub::~TAO_Stub (void) // it being destroy()ed, then no connectors exist so do not // reset the hint in case it points to non-existent // connection handler. - this->profile_in_use_->reset_hint (); + this->profile_in_use_->endpoint ()->reset_hint (); } // decrease reference count on profile diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp index 4eafaa78d7a..eb4aa247d4e 100644 --- a/TAO/tao/TAO.dsp +++ b/TAO/tao/TAO.dsp @@ -784,6 +784,25 @@ SOURCE=.\Encodable.cpp # End Source File
# Begin Source File
+SOURCE=.\Endpoint.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\Environment.cpp
!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
@@ -1107,6 +1126,44 @@ SOURCE=.\IIOP_Connector.cpp # End Source File
# Begin Source File
+SOURCE=.\IIOP_Endpoint.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\iiop_endpoints.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\IIOP_Factory.cpp
!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
@@ -2304,6 +2361,25 @@ SOURCE=.\SHMIOP_Connector.cpp # End Source File
# Begin Source File
+SOURCE=.\SHMIOP_Endpoint.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\SHMIOP_Factory.cpp
!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
@@ -2760,6 +2836,44 @@ SOURCE=.\UIOP_Connector.cpp # End Source File
# Begin Source File
+SOURCE=.\UIOP_Endpoint.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\uiop_endpoints.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\UIOP_Factory.cpp
!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
@@ -3112,6 +3226,10 @@ SOURCE=.\Encodable.h # End Source File
# Begin Source File
+SOURCE=.\Endpoint.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Environment.h
# End Source File
# Begin Source File
@@ -3172,6 +3290,14 @@ SOURCE=.\IIOP_Connector.h # End Source File
# Begin Source File
+SOURCE=.\IIOP_Endpoint.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\iiop_endpoints.h
+# End Source File
+# Begin Source File
+
SOURCE=.\IIOP_Factory.h
# End Source File
# Begin Source File
@@ -3424,6 +3550,10 @@ SOURCE=.\SHMIOP_Connector.h # End Source File
# Begin Source File
+SOURCE=.\SHMIOP_Endpoint.h
+# End Source File
+# Begin Source File
+
SOURCE=.\SHMIOP_Factory.h
# End Source File
# Begin Source File
@@ -3524,6 +3654,14 @@ SOURCE=.\UIOP_Connector.h # End Source File
# Begin Source File
+SOURCE=.\UIOP_Endpoint.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\uiop_endpoints.h
+# End Source File
+# Begin Source File
+
SOURCE=.\UIOP_Factory.h
# End Source File
# Begin Source File
@@ -3668,6 +3806,10 @@ SOURCE=.\DynamicC.i # End Source File
# Begin Source File
+SOURCE=.\Endpoint.i
+# End Source File
+# Begin Source File
+
SOURCE=.\Environment.i
# End Source File
# Begin Source File
@@ -3708,6 +3850,14 @@ SOURCE=.\IIOP_Connect.i # End Source File
# Begin Source File
+SOURCE=.\IIOP_Endpoint.i
+# End Source File
+# Begin Source File
+
+SOURCE=.\iiop_endpoints.i
+# End Source File
+# Begin Source File
+
SOURCE=.\IIOP_ORB.i
# End Source File
# Begin Source File
@@ -3916,6 +4066,10 @@ SOURCE=.\SHMIOP_Connect.i # End Source File
# Begin Source File
+SOURCE=.\SHMIOP_Endpoint.i
+# End Source File
+# Begin Source File
+
SOURCE=.\SHMIOP_Profile.i
# End Source File
# Begin Source File
@@ -3976,6 +4130,14 @@ SOURCE=.\UIOP_Connect.i # End Source File
# Begin Source File
+SOURCE=.\UIOP_Endpoint.i
+# End Source File
+# Begin Source File
+
+SOURCE=.\uiop_endpoints.i
+# End Source File
+# Begin Source File
+
SOURCE=.\UIOP_Profile.i
# End Source File
# Begin Source File
diff --git a/TAO/tao/Tagged_Components.cpp b/TAO/tao/Tagged_Components.cpp index f0737c8beb3..f83afd65a62 100644 --- a/TAO/tao/Tagged_Components.cpp +++ b/TAO/tao/Tagged_Components.cpp @@ -64,20 +64,6 @@ TAO_Tagged_Components::set_code_sets_i ( lhs.conversion_code_sets.replace (max, len, buffer, 1); } -void -TAO_Tagged_Components::set_tao_priority (CORBA::Short p) -{ - this->tao_priority_ = p; - this->tao_priority_set_ = 1; - - TAO_OutputCDR cdr; - cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); - - cdr << this->tao_priority_; - - this->set_component_i (TAO_TAG_PRIORITY, cdr); -} - // **************************************************************** void @@ -158,16 +144,6 @@ TAO_Tagged_Components::set_known_component_i ( ci.ForWcharData); this->code_sets_set_ = 1; } - else if (component.tag == TAO_TAG_PRIORITY) - { - CORBA::Short p; - - if ((cdr >> p) == 0) - return; - - this->tao_priority_ = p; - this->tao_priority_set_ = 1; - } } void @@ -255,7 +231,6 @@ TAO_Tagged_Components::decode (TAO_InputCDR& cdr) // Mark the well-known components as removed this->orb_type_set_ = 0; this->code_sets_set_ = 0; - this->tao_priority_set_ = 0; if ((cdr >> this->components_) == 0) return 0; diff --git a/TAO/tao/Tagged_Components.h b/TAO/tao/Tagged_Components.h index 0b1c589bd43..edab507f603 100644 --- a/TAO/tao/Tagged_Components.h +++ b/TAO/tao/Tagged_Components.h @@ -74,13 +74,6 @@ public: // Gets a copy of the IOP::TAG_CODE_SETS component value, return 0 // if the component is not present. - // = TAO specific components - void set_tao_priority (CORBA::Short priority); - // The the TAO_TAG_PRIORITY component value. - - int get_tao_priority (CORBA::Short& min_priority) const; - // Gets the TAO_TAG_PRIORITY component value. - // = Generic components void set_component (const IOP::TaggedComponent& component); @@ -136,7 +129,7 @@ private: CONV_FRAME::CodeSetComponentInfo code_sets_; // The ORB_TYPE component value - CORBA::Short tao_priority_; + // CORBA::Short tao_priority_; // The TAO_PRIORITY priorities IOP::MultipleComponentProfile components_; @@ -146,7 +139,6 @@ private: // A flag for each component... CORBA::Octet orb_type_set_; CORBA::Octet code_sets_set_; - CORBA::Octet tao_priority_set_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/tao/Tagged_Components.i b/TAO/tao/Tagged_Components.i index da5b23331ba..ce738b1c0e5 100644 --- a/TAO/tao/Tagged_Components.i +++ b/TAO/tao/Tagged_Components.i @@ -3,10 +3,8 @@ ACE_INLINE TAO_Tagged_Components::TAO_Tagged_Components (void) : orb_type_ (0), - tao_priority_ (0), orb_type_set_ (0), - code_sets_set_ (0), - tao_priority_set_ (0) + code_sets_set_ (0) { } @@ -19,16 +17,6 @@ TAO_Tagged_Components::get_orb_type (CORBA::ULong& orb_type) const } ACE_INLINE int -TAO_Tagged_Components::get_tao_priority (CORBA::Short& p) const -{ - if (this->tao_priority_set_ == 1) - { - p = this->tao_priority_; - } - return this->tao_priority_set_; -} - -ACE_INLINE int TAO_Tagged_Components::get_code_sets (const CONV_FRAME::CodeSetComponentInfo* &ci) const { if (this->code_sets_set_ == 1) @@ -48,8 +36,7 @@ ACE_INLINE int TAO_Tagged_Components::known_tag (IOP::ComponentId tag) const { return (tag == IOP::TAG_ORB_TYPE - || tag == IOP::TAG_CODE_SETS - || tag == TAO_TAG_PRIORITY); + || tag == IOP::TAG_CODE_SETS); } ACE_INLINE int @@ -57,8 +44,8 @@ TAO_Tagged_Components::unique_tag (IOP::ComponentId tag) const { return (tag == IOP::TAG_ORB_TYPE || tag == IOP::TAG_CODE_SETS - || tag == TAO_TAG_PRIORITY || tag == IOP::TAG_POLICIES + || tag == TAO_TAG_ENDPOINTS // || tag == IOP::TAG_ALTERNATE_IIOP_ADDRESS || tag == IOP::TAG_ASSOCIATION_OPTIONS || tag == IOP::TAG_SEC_NAME diff --git a/TAO/tao/UIOP_Acceptor.cpp b/TAO/tao/UIOP_Acceptor.cpp index 3684f9913b5..72f11f88f81 100644 --- a/TAO/tao/UIOP_Acceptor.cpp +++ b/TAO/tao/UIOP_Acceptor.cpp @@ -81,16 +81,15 @@ TAO_UIOP_Acceptor::~TAO_UIOP_Acceptor (void) delete this->accept_strategy_; } -int -TAO_UIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, - TAO_MProfile &mprofile) +int +TAO_UIOP_Acceptor::create_profile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) { ACE_UNIX_Addr addr; if (this->base_acceptor_.acceptor ().get_local_addr (addr) == -1) return 0; - // we only make one int count = mprofile.profile_count (); if ((mprofile.size () - count) < 1 && mprofile.grow (count + 1) == -1) @@ -104,6 +103,8 @@ TAO_UIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, this->orb_core_), -1); + pfile->endpoint ()->priority (this->priority_); + if (mprofile.give_profile (pfile) == -1) { pfile->_decr_refcnt (); @@ -121,20 +122,81 @@ TAO_UIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, code_set_info.ForWcharData.native_code_set = TAO_DEFAULT_WCHAR_CODESET_ID; pfile->tagged_components ().set_code_sets (code_set_info); - pfile->tagged_components ().set_tao_priority (this->priority ()); - return 0; } int -TAO_UIOP_Acceptor::is_collocated (const TAO_Profile *pfile) +TAO_UIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) +{ + // If RT_CORBA is enabled, only one UIOP profile is created for + // <mprofile>, and all UIOP endpoints are added into that profile. + // If RT_CORBA is not enabled, we create a separate profile for each + // endpoint. + +#if (TAO_HAS_RT_CORBA == 1) + + return create_rt_mprofile (object_key, mprofile); + +#else /* TAO_HAS_RT_CORBA == 1 */ + + return create_profile (object_key, mprofile); + +#endif /* TAO_HAS_RT_CORBA == 1 */ +} + +int +TAO_UIOP_Acceptor::create_rt_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile) +{ + TAO_Profile *pfile = 0; + TAO_UIOP_Profile *uiop_profile = 0; + + // First see if <mprofile> already contains a SHMIOP profile. + for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i) + { + pfile = mprofile.get_profile (i); + if (pfile->tag () == TAO_TAG_UIOP_PROFILE) + { + uiop_profile = ACE_dynamic_cast (TAO_UIOP_Profile *, + pfile); + break; + } + } + + if (uiop_profile == 0) + { + // If <mprofile> doesn't contain UIOP_Profile, we need to create + // one. + return create_profile (object_key, mprofile); + } + else + { + // There already is a UIOP_Profile - just add our endpoint to it. + ACE_UNIX_Addr addr; + + if (this->base_acceptor_.acceptor ().get_local_addr (addr) == -1) + return 0; + + TAO_UIOP_Endpoint *endpoint = 0; + ACE_NEW_RETURN (endpoint, + TAO_UIOP_Endpoint (addr), + -1); + endpoint->priority (this->priority_); + uiop_profile->add_endpoint (endpoint); + + return 0; + } +} + +int +TAO_UIOP_Acceptor::is_collocated (const TAO_Endpoint *endpoint) { - const TAO_UIOP_Profile *profile = - ACE_dynamic_cast (const TAO_UIOP_Profile *, - pfile); + const TAO_UIOP_Endpoint *endp = + ACE_dynamic_cast (const TAO_UIOP_Endpoint *, endpoint); // Make sure the dynamically cast pointer is valid. - if (profile == 0) + if (endp == 0) return 0; // For UNIX Files this is relatively cheap. @@ -142,7 +204,7 @@ TAO_UIOP_Acceptor::is_collocated (const TAO_Profile *pfile) if (this->base_acceptor_.acceptor ().get_local_addr (address) == -1) return 0; - return profile->object_addr () == address; + return endp->object_addr () == address; } int diff --git a/TAO/tao/UIOP_Acceptor.h b/TAO/tao/UIOP_Acceptor.h index 480dcd206b7..094bad7b72b 100644 --- a/TAO/tao/UIOP_Acceptor.h +++ b/TAO/tao/UIOP_Acceptor.h @@ -74,7 +74,7 @@ public: virtual int close (void); virtual int create_mprofile (const TAO_ObjectKey &object_key, TAO_MProfile &mprofile); - virtual int is_collocated (const TAO_Profile* profile); + virtual int is_collocated (const TAO_Endpoint* endpoint); virtual CORBA::ULong endpoint_count (void); virtual int object_key (IOP::TaggedProfile &profile, @@ -94,6 +94,17 @@ private: // Obtains uiop properties that must be used by this acceptor, i.e., // initializes <uiop_properties_>. + int create_rt_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile); + // Rather than creating a profile for each endpoint, this version of + // <create_mprofile> adds an endpoint to an existing UIOP profile + // if one already exists. + + int create_profile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile); + // Create a UIOP profile representing this acceptor. Factors out + // common functionality of <create_mprofile> and <create_rt_mprofile>. + private: TAO_UIOP_BASE_ACCEPTOR base_acceptor_; // the concrete acceptor, as a pointer to its base class. diff --git a/TAO/tao/UIOP_Connector.cpp b/TAO/tao/UIOP_Connector.cpp index 8f32720db10..7ebe564f6a2 100644 --- a/TAO/tao/UIOP_Connector.cpp +++ b/TAO/tao/UIOP_Connector.cpp @@ -456,21 +456,21 @@ TAO_UIOP_Connector::close (void) } int -TAO_UIOP_Connector::connect (TAO_Profile *profile, +TAO_UIOP_Connector::connect (TAO_Endpoint *endpoint TAO_Transport *& transport, ACE_Time_Value *max_wait_time) { - if (profile->tag () != TAO_TAG_UIOP_PROFILE) + if (endpoint->tag () != TAO_TAG_UIOP_PROFILE) return -1; - TAO_UIOP_Profile *uiop_profile = - ACE_dynamic_cast (TAO_UIOP_Profile *, + TAO_UIOP_Profile *uiop_endpoint = + ACE_dynamic_cast (TAO_UIOP_Endpoint *, profile); - if (uiop_profile == 0) + if (uiop_endpoint == 0) return -1; const ACE_UNIX_Addr &remote_address = - uiop_profile->object_addr (); + uiop_endpoint->object_addr (); // @@ Note, POSIX.1g renames AF_UNIX to AF_LOCAL. @@ -491,7 +491,7 @@ TAO_UIOP_Connector::connect (TAO_Profile *profile, // object; but we obtain the transport in the <svc_handler> // variable. Other threads may modify the hint, but we are not // affected. - result = this->base_connector_.connect (uiop_profile->hint (), + result = this->base_connector_.connect (uiop_endpoint->hint (), svc_handler, remote_address, synch_options); @@ -502,7 +502,7 @@ TAO_UIOP_Connector::connect (TAO_Profile *profile, // object; but we obtain the transport in the <svc_handler> // variable. Other threads may modify the hint, but we are not // affected. - result = this->base_connector_.connect (uiop_profile->hint (), + result = this->base_connector_.connect (uiop_endpoint->hint (), svc_handler, remote_address); } @@ -517,7 +517,7 @@ TAO_UIOP_Connector::connect (TAO_Profile *profile, ACE_TEXT ("%s failed (%p)\n"), __FILE__, __LINE__, - uiop_profile->rendezvous_point (), + uiop_endpoint->rendezvous_point (), "errno")); } @@ -525,20 +525,6 @@ TAO_UIOP_Connector::connect (TAO_Profile *profile, } transport = svc_handler->transport (); - // Now that we have the client connection handler object we need to - // set the right messaging protocol for the connection handler. - const TAO_GIOP_Version& version = uiop_profile->version (); - int ret_val = transport->messaging_init (version.major, - version.minor); - if (ret_val == -1) - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%N|%l|%p|%t) init_mesg_protocol () failed \n"))); - } - return -1; - } return 0; } diff --git a/TAO/tao/UIOP_Connector.h b/TAO/tao/UIOP_Connector.h index ecf65a9ce44..be4fbf36f11 100644 --- a/TAO/tao/UIOP_Connector.h +++ b/TAO/tao/UIOP_Connector.h @@ -103,7 +103,7 @@ public: // Pluggable.h int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_Profile *profile, + int connect (TAO_Endpoint *endpoint, TAO_Transport *&transport, ACE_Time_Value *max_wait_time); int preconnect (const char *preconnections); diff --git a/TAO/tao/UIOP_Endpoint.cpp b/TAO/tao/UIOP_Endpoint.cpp new file mode 100644 index 00000000000..28e9f962cf4 --- /dev/null +++ b/TAO/tao/UIOP_Endpoint.cpp @@ -0,0 +1,55 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +#include "tao/UIOP_Endpoint.h" + +#if TAO_HAS_UIOP == 1 + +#include "tao/debug.h" + +ACE_RCSID(tao, UIOP_Endpoint, "$Id$") + +#if !defined (__ACE_INLINE__) +# include "tao/UIOP_Endpoint.i" +#endif /* __ACE_INLINE__ */ + +TAO_UIOP_Endpoint::TAO_UIOP_Endpoint (const ACE_UNIX_Addr &addr) + : TAO_Endpoint (TAO_TAG_UIOP_PROFILE), + object_addr_ (addr), + hint_ (0), + next_ (0) +{ +} + +TAO_UIOP_Endpoint::TAO_UIOP_Endpoint (void) + : TAO_Endpoint (TAO_TAG_UIOP_PROFILE), + object_addr_ (), + hint_ (0), + next_ (0) +{ +} + +TAO_UIOP_Endpoint::~TAO_UIOP_Endpoint (void) +{ +} + +int +TAO_UIOP_Endpoint::addr_to_string (char *buffer, size_t length) +{ + if (length < (ACE_OS::strlen (this->rendezvous_point ()) + 1)) + return -1; + + ACE_OS::strcpy (buffer, this->rendezvous_point ()); + + return 0; +} + +void +TAO_UIOP_Endpoint::reset_hint (void) +{ + if (this->hint_) + this->hint_->cleanup_hint ((void **) &this->hint_); +} + +#endif /* TAO_HAS_UIOP == 1 */ diff --git a/TAO/tao/UIOP_Endpoint.h b/TAO/tao/UIOP_Endpoint.h new file mode 100644 index 00000000000..886f8b0e3c5 --- /dev/null +++ b/TAO/tao/UIOP_Endpoint.h @@ -0,0 +1,109 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// UIOP_Endpoint.h +// +// = AUTHOR +// Marina Spivak <marina@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_UIOP_ENDPOINT_H +#define TAO_UIOP_ENDPOINT_H +#include "ace/pre.h" + +#include "tao/Endpoint.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if TAO_HAS_UIOP == 1 + +#include "ace/UNIX_Addr.h" + +class TAO_UIOP_Client_Connection_Handler; + +class TAO_Export TAO_UIOP_Endpoint : public TAO_Endpoint +{ + // = TITLE + // This class defines the protocol specific attributes required + // for locating ORBs over a TCP/IP network. + // + // = DESCRIPTION + // This class defines the IIOP profile as specified in the CORBA + // specification. +public: + + friend class TAO_UIOP_Profile; + + TAO_UIOP_Endpoint (const ACE_UNIX_Addr &addr); + // Profile constructor + + TAO_UIOP_Endpoint (void); + // Endpoint constructor, default. + + ~TAO_UIOP_Endpoint (void); + // Destructor is to be called only through <_decr_refcnt>. + + CORBA::Boolean is_equivalent (const TAO_IIOP_Endpoint *other_endpoint); + // Return true if this profile is equivalent to other_profile. Two + // profiles are equivalent iff their key, port, host, object_key and + // version are the same. + + CORBA::ULong hash (void); + // Return a hash value for this object. + + // = Abstract Endpoint interface methods. + + TAO_Endpoint *next (void); + // Return the next endpoint in the list. + + virtual int addr_to_string (char *buffer, size_t length); + // Return a string representation for the address. + + virtual void reset_hint (void); + // Reset the hint's value. + + // = UIOP Endpoint methods. + + const char *rendezvous_point (void) const; + // Return a pointer to the rendezvous point string. + // This object maintains ownership of the returned string. + + const ACE_UNIX_Addr &object_addr (void) const; + // return a reference to the object_addr. + + TAO_UIOP_Client_Connection_Handler *&hint (void); + // This is a hint for which connection handler to use. + +private: + + ACE_UNIX_Addr object_addr_; + // Cached instance of <ACE_UNIX_Addr> for use in making + // invocations, etc. + + TAO_UIOP_Client_Connection_Handler *hint_; + // Pointer to a connection handler which we successfully used + // already. + + TAO_IIOP_Endpoint *next_; + // Next endpoint in the list. +}; + +#if defined (__ACE_INLINE__) +# include "tao/UIOP_Endpoint.i" +#endif /* __ACE_INLINE__ */ + +# endif /* TAO_HAS_UIOP == 1 */ + +#include "ace/post.h" +#endif /* TAO_UIOP_ENDPOINT_H */ + diff --git a/TAO/tao/UIOP_Endpoint.i b/TAO/tao/UIOP_Endpoint.i new file mode 100644 index 00000000000..60c34964663 --- /dev/null +++ b/TAO/tao/UIOP_Endpoint.i @@ -0,0 +1,45 @@ +// -*- C++ -*- +// $Id$ + +# if TAO_HAS_UIOP == 1 + +ACE_INLINE const ACE_UNIX_Addr & +TAO_UIOP_Endpoint::object_addr (void) const +{ + return this->object_addr_; +} + +ACE_INLINE TAO_UIOP_Client_Connection_Handler *& +TAO_UIOP_Endpoint::hint (void) +{ + return this->hint_; +} + +ACE_INLINE CORBA::ULong +TAO_UIOP_Endpoint::hash (void) +{ + return ACE::hash_pjw (this->rendezvous_point ()); +} + +ACE_INLINE CORBA::Boolean +TAO_UIOP_Endpoint::is_equivalent (const TAO_UIOP_Endpoint *other_endpoint) +{ + return + ACE_OS::strcmp (this->rendezvous_point (), + other_endpoint->rendezvous_point ()) == 0; +} + +ACE_INLINE const char * +TAO_UIOP_Endpoint::rendezvous_point (void) const +{ + return this->object_addr_.get_path_name (); +} + +ACE_INLINE TAO_Endpoint * +TAO_SHMIOP_Endpoint::next (void) +{ + return this->next_; +} + +#endif /* TAO_HAS_UIOP == 1 */ + diff --git a/TAO/tao/UIOP_Profile.cpp b/TAO/tao/UIOP_Profile.cpp index ad6e9e89d0c..b92858a86f4 100644 --- a/TAO/tao/UIOP_Profile.cpp +++ b/TAO/tao/UIOP_Profile.cpp @@ -11,6 +11,7 @@ #include "tao/ORB.h" #include "tao/ORB_Core.h" #include "tao/debug.h" +#include "tao/uiop_endpoints.h" ACE_RCSID(tao, UIOP_Profile, "$Id$") @@ -33,12 +34,11 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr &addr, const TAO_ObjectKey &object_key, const TAO_GIOP_Version &version, TAO_ORB_Core *orb_core) - : TAO_Profile (TAO_TAG_UIOP_PROFILE, - orb_core), - version_ (version), + : TAO_Profile (TAO_TAG_UIOP_PROFILE, orb_core, version), + endpoint_ (addr), + count_ (1), + endpoints_encoded_ (0), object_key_ (object_key), - object_addr_ (addr), - hint_ (0), tagged_profile_ () { } @@ -48,12 +48,12 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char *, const ACE_UNIX_Addr &addr, const TAO_GIOP_Version &version, TAO_ORB_Core *orb_core) - : TAO_Profile (TAO_TAG_UIOP_PROFILE, - orb_core), - version_ (version), + : TAO_Profile (TAO_TAG_UIOP_PROFILE, orb_core, version), + endpoint_ (addr), + count_ (1), + endpoints_encoded_ (0), object_key_ (object_key), - object_addr_ (addr), - hint_ (0) + tagged_profile_ () { } @@ -61,11 +61,14 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char *string, TAO_ORB_Core *orb_core, CORBA::Environment &ACE_TRY_ENV) : TAO_Profile (TAO_TAG_UIOP_PROFILE, - orb_core), - version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, + TAO_DEF_GIOP_MINOR)), + endpoint_ (), + count_ (1), + endpoints_encoded_ (0), object_key_ (), - object_addr_ (), - hint_ (0) + tagged_profile_ () { parse_string (string, ACE_TRY_ENV); ACE_CHECK; @@ -73,16 +76,35 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char *string, TAO_UIOP_Profile::TAO_UIOP_Profile (TAO_ORB_Core *orb_core) : TAO_Profile (TAO_TAG_UIOP_PROFILE, - orb_core), - version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), + orb_core, + TAO_GIOP_Version (TAO_DEF_GIOP_MAJOR, + TAO_DEF_GIOP_MINOR)), + endpoint_ (), + count_ (1), + endpoints_encoded_ (0), object_key_ (), - object_addr_ (), - hint_ (0) + tagged_profile_ () { } TAO_UIOP_Profile::~TAO_UIOP_Profile (void) { + // Clean up endpoint list. + TAO_Endpoint *tmp = 0; + + for (TAO_Endpoint *next = this->endpoint ()->next (); + next != 0; + next = tmp) + { + tmp = next->next (); + delete next; + } +} + +TAO_Endpoint* +TAO_UIOP_Profile::endpoint (void) +{ + return &this->endpoint_; } int @@ -152,7 +174,7 @@ TAO_UIOP_Profile::parse_string (const char *string, ACE_OS::strncpy (rendezvous.inout (), start, length); rendezvous[length] = '\0'; - if (this->object_addr_.set (rendezvous.in ()) != 0) + if (this->endpoint_.object_addr_.set (rendezvous.in ()) != 0) { ACE_THROW_RETURN (CORBA::INV_OBJREF ( CORBA_SystemException::_tao_minor_code ( @@ -181,20 +203,43 @@ TAO_UIOP_Profile::is_equivalent (const TAO_Profile *other_profile) ACE_ASSERT (op->object_key_.length () < UINT_MAX); - return this->object_key_ == op->object_key_ && - ACE_OS::strcmp (this->rendezvous_point (), - op->rendezvous_point ()) == 0 && - this->version_ == op->version_; + if (!(this->object_key_ == op->object_key_ + && this->version_ == op->version_ + && this->count_ == op->count_)) + return 0; + + // Check endpoints equivalence. + // @@ Are we guaranteed that the endpoints in both profiles will be + // in the same order? + const TAO_UIOP_Endpoint *other_endp = &op->endpoint_; + for (TAO_UIOP_Endpoint *endp = &this->endpoint_; + endp != 0; + endp = endp->next_) + { + if (endp->is_equivalent (other_endp)) + other_endp = other_endp->next_; + else + return 0; + } + + return 1; } CORBA::ULong TAO_UIOP_Profile::hash (CORBA::ULong max, CORBA::Environment &) { - CORBA::ULong hashval = - ACE::hash_pjw (this->rendezvous_point ()) - + this->version_.minor - + this->tag (); + // Get the hashvalue for all endpoints. + CORBA::ULong hashval = 0; + for (TAO_UIOP_Endpoint *endp = &this->endpoint_; + endp != 0; + endp = endp->next_) + { + hashval += endp->hash (); + } + + hashval += this->version_.minor; + hashval += this->tag (); if (this->object_key_.length () >= 4) { @@ -205,23 +250,15 @@ TAO_UIOP_Profile::hash (CORBA::ULong max, return hashval % max; } -int -TAO_UIOP_Profile::addr_to_string (char *buffer, size_t length) +void +TAO_UIOP_Profile::add_endpoint (TAO_UIOP_Endpoint *endp) { - if (length < (ACE_OS::strlen (this->rendezvous_point ()) + 1)) - return -1; + endp->next_ = this->endpoint_.next_; + this->endpoint_.next_ = endp; - ACE_OS::strcpy (buffer, this->rendezvous_point ()); - - return 0; + this->count_++; } -void -TAO_UIOP_Profile::reset_hint (void) -{ - if (this->hint_) - this->hint_->cleanup_hint ((void **) &this->hint_); -} char * TAO_UIOP_Profile::to_string (CORBA::Environment &) @@ -238,7 +275,7 @@ TAO_UIOP_Profile::to_string (CORBA::Environment &) 1 /* decimal point */ + 1 /* minor version */ + 1 /* `@' character */ + - ACE_OS::strlen (this->rendezvous_point ()) + + ACE_OS::strlen (this->endpoint_.rendezvous_point ()) + 1 /* object key separator */ + ACE_OS::strlen (key.in ())); @@ -251,7 +288,7 @@ TAO_UIOP_Profile::to_string (CORBA::Environment &) ::prefix_, digits [this->version_.major], digits [this->version_.minor], - this->rendezvous_point (), + this->endpoint_.rendezvous_point (), this->object_key_delimiter_, key.in ()); return buf; @@ -303,7 +340,7 @@ TAO_UIOP_Profile::decode (TAO_InputCDR& cdr) return -1; } - if (this->object_addr_.set (rendezvous) == -1) + if (this->endpoint_.object_addr_.set (rendezvous) == -1) { // In the case of an ACE_UNIX_Addr, this should call should // never fail! @@ -342,6 +379,9 @@ TAO_UIOP_Profile::decode (TAO_InputCDR& cdr) encap_len)); } + // Decode endpoints if any. + this->decode_endpoints (); + if (cdr.good_bit ()) return 1; @@ -433,14 +473,130 @@ TAO_UIOP_Profile::create_profile_body (TAO_OutputCDR &encap) const encap.write_octet (this->version_.minor); // STRING rendezvous_pointname from profile - encap.write_string (this->rendezvous_point ()); + encap.write_string (this->endpoint_.rendezvous_point ()); // OCTET SEQUENCE for object key encap << this->object_key_; + // Encode profile endpoints. + TAO_UIOP_Profile *p = + ACE_const_cast (TAO_UIOP_Profile *, this); + if (!endpoints_encoded_) + p->encode_endpoints (); + if (this->version_.major > 1 || this->version_.minor > 0) this->tagged_components ().encode (encap); } +int +TAO_UIOP_Profile::encode_endpoints (void) +{ + // Create a data structure with endpoint info for wire transfer. + TAO_UIOPEndpointSequence endpoints; + endpoints.length (this->count_); + + TAO_UIOP_Endpoint *endpoint = &this->endpoint_; + for (size_t i = 0; + i < this->count_; + ++i) + { + endpoints[i].rendezvous_point = endpoint->rendezvous_point (); + endpoints[i].priority = endpoint->priority (); + + endpoint = endpoint->next_; + } + + // Encode. + TAO_OutputCDR out_cdr; + out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); + out_cdr << endpoints; + CORBA::ULong length = out_cdr.total_length (); + + IOP::TaggedComponent tagged_component; + tagged_component.tag = TAO_TAG_ENDPOINTS; + tagged_component.component_data.length (length); + CORBA::Octet *buf = + tagged_component.component_data.get_buffer (); + + for (const ACE_Message_Block *iterator = out_cdr.begin (); + iterator != 0; + iterator = iterator->cont ()) + { + CORBA::ULong i_length = iterator->length (); + ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length); + + buf += i_length; + } + + // Eventually we add the TaggedComponent to the TAO_TaggedComponents + // member variable. + tagged_components_.set_component (tagged_component); + this->endpoints_encoded_ = 1; + + return 1; +} + +int +TAO_UIOP_Profile::decode_endpoints (void) +{ + IOP::TaggedComponent tagged_component; + tagged_component.tag = TAO_TAG_ENDPOINTS; + + if (this->tagged_components_.get_component (tagged_component)) + { + const CORBA::Octet *buf = + tagged_component.component_data.get_buffer (); + + TAO_InputCDR in_cdr (ACE_reinterpret_cast (const char*, buf), + tagged_component.component_data.length ()); + + // Extract the Byte Order. + CORBA::Boolean byte_order; + if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + return 0; + in_cdr.reset_byte_order (ACE_static_cast(int, byte_order)); + + // Extract endpoints sequence. + TAO_UIOPEndpointSequence endpoints; + in_cdr >> endpoints; + + // Get the priority of the first endpoint. It's other data is + // extracted as part of the standard iiop decoding. + this->endpoint_.priority (endpoints[0].priority); + + // Start with the second endpoint, because the first endpoint is + // always extracted through standard iiop profile body. + for (CORBA::ULong i = 1; i < endpoints.length (); ++i) + { + TAO_UIOP_Endpoint *endpoint = 0; + ACE_NEW_RETURN (endpoint, + TAO_UIOP_Endpoint, + 0); + this->add_endpoint (endpoint); + if (endpoint->object_addr_.set + (endpoints[i].rendezvous_point) + == -1) + { + // In the case of an ACE_UNIX_Addr, this should call should + // never fail! + // If the call fails, allow the profile to be created, and rely + // on TAO's connection handling to throw the appropriate + // exception. + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) UIOP_Profile::decode_endpoints - ") + ACE_TEXT ("ACE_UNIX_Addr::set() failed\n"))); + } + + } + endpoint->priority (endpoints[i].priority); + } + } + + this->endpoints_encoded_ = 1; + return 1; +} + #endif /* TAO_HAS_UIOP == 1 */ diff --git a/TAO/tao/UIOP_Profile.h b/TAO/tao/UIOP_Profile.h index 91c3bba617f..d08f55ba2cd 100644 --- a/TAO/tao/UIOP_Profile.h +++ b/TAO/tao/UIOP_Profile.h @@ -32,6 +32,7 @@ #include "tao/Object_KeyC.h" #include "tao/UIOP_Connect.h" +#include "tao/UIOP_Endpoint.h" #include "ace/UNIX_Addr.h" #include "ace/Synch.h" @@ -81,6 +82,12 @@ public: ~TAO_UIOP_Profile (void); // Destructor is to be called only through <_decr_refcnt>. + virtual TAO_Endpoint *endpoint (void); + // + + void add_endpoint (TAO_IIOP_Endpoint *endp); + // + int parse_string (const char *string, CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()); @@ -114,26 +121,6 @@ public: TAO_default_environment ()); // Return a hash value for this object. - int addr_to_string (char *buffer, size_t length); - // Return a string representation for the address. - - const ACE_UNIX_Addr &object_addr (void) const; - // return a reference to the object_addr. - - const char *rendezvous_point (void) const; - // Return a pointer to the rendezvous point string. - // This object maintains ownership of the returned string. - - const TAO_GIOP_Version &version (void) const; - // Return a pointer to this profile's version. This object - // maintains ownership. - - TAO_UIOP_Client_Connection_Handler *&hint (void); - // This is a hint for which connection handler to use. - - void reset_hint (void); - // Reset the hint's value. - IOP::TaggedProfile &create_tagged_profile (void); // Please see the Profile.h for the documentation of this method @@ -141,20 +128,25 @@ private: void create_profile_body (TAO_OutputCDR &cdr) const; // Create an encapsulation of the struct ProfileBody in <cdr> + + int encode_endpoints (void); + // Encodes endpoints from this profile into a tagged component. - TAO_GIOP_Version version_; - // UIOP version number. + int decode_endpoints (void); + // Decodes endpoints of this profile from a tagged component. - TAO_ObjectKey object_key_; - // object_key associated with this profile. + TAO_UIOP_Endpoint endpoint_; + // + + size_t count_; + // Number of endpoints this profile contains. - ACE_UNIX_Addr object_addr_; - // Cached instance of <ACE_UNIX_Addr> for use in making - // invocations, etc. + int endpoints_encoded_; + // Flag indicating whether endpoints have already been encoded, + // saving us from repeatedly encoding them over and over. - TAO_UIOP_Client_Connection_Handler *hint_; - // Pointer to a connection handler which we successfully used - // already. + TAO_ObjectKey object_key_; + // object_key associated with this profile. TAO_MProfile *forward_to_; // list of profiles which we should try forwarding on. diff --git a/TAO/tao/UIOP_Profile.i b/TAO/tao/UIOP_Profile.i index 45f520ecaf6..eab7e497f85 100644 --- a/TAO/tao/UIOP_Profile.i +++ b/TAO/tao/UIOP_Profile.i @@ -27,22 +27,4 @@ TAO_UIOP_Profile::object_addr (void) const return this->object_addr_; } -ACE_INLINE const char * -TAO_UIOP_Profile::rendezvous_point (void) const -{ - return this->object_addr_.get_path_name (); -} - -ACE_INLINE const TAO_GIOP_Version & -TAO_UIOP_Profile::version (void) const -{ - return this->version_; -} - -ACE_INLINE TAO_UIOP_Client_Connection_Handler *& -TAO_UIOP_Profile::hint (void) -{ - return this->hint_; -} - #endif /* TAO_HAS_UIOP == 1 */ diff --git a/TAO/tao/corbafwd.h b/TAO/tao/corbafwd.h index b378ba360a7..d159297570a 100644 --- a/TAO/tao/corbafwd.h +++ b/TAO/tao/corbafwd.h @@ -957,11 +957,8 @@ TAO_NAMESPACE_CLOSE // end of class (namespace) CORBA // We reserved the range 0x54414f00 - 0x54414f0f with the OMG to // define our own profile tagged components in TAO. -// Store the priority of the thread (pool) that services this -// endpoint, using that information the client can select the right -// endpoint providing very low priority inversion (basically only in -// the I/O subsystem). -#define TAO_TAG_PRIORITY 0x54414f00U +// Tag for storing multiple endpoints within a single profile. +#define TAO_TAG_ENDPOINTS 0x54414f00U // #define TAO_TAG_ANOTHER_COMPONENT 0x54414f01U // We reserved the range 0x54414f00 - 0x54414f0f with the OMG to diff --git a/TAO/tao/iiop_endpoints.cpp b/TAO/tao/iiop_endpoints.cpp new file mode 100644 index 00000000000..f8556e65c40 --- /dev/null +++ b/TAO/tao/iiop_endpoints.cpp @@ -0,0 +1,379 @@ +/* -*- C++ -*- $Id$ */ +// $Id$ +// +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "iiop_endpoints.h" + +#if !defined (__ACE_INLINE__) +#include "iiop_endpoints.i" +#endif /* !defined INLINE */ + +static const CORBA::Long _oc_TAO_IIOP_Endpoint_Info[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 31, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x49494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f3a31), ACE_NTOHL (0x2e300000), // repository ID = IDL:TAO_IIOP_Endpoint_Info:1.0 + 23, ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x49494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f0000), // name = TAO_IIOP_Endpoint_Info + 3, // member count + 5, ACE_NTOHL (0x686f7374), ACE_NTOHL (0x0), // name = host + CORBA::tk_string, + 0U, // string length + 5, ACE_NTOHL (0x706f7274), ACE_NTOHL (0x0), // name = port + CORBA::tk_short, + + 9, ACE_NTOHL (0x7072696f), ACE_NTOHL (0x72697479), ACE_NTOHL (0x0), // name = priority + CORBA::tk_short, + +}; +static CORBA::TypeCode _tc_TAO_tc_TAO_IIOP_Endpoint_Info (CORBA::tk_struct, sizeof (_oc_TAO_IIOP_Endpoint_Info), (char *) &_oc_TAO_IIOP_Endpoint_Info, 0, sizeof (TAO_IIOP_Endpoint_Info)); +CORBA::TypeCode_ptr _tc_TAO_IIOP_Endpoint_Info = &_tc_TAO_tc_TAO_IIOP_Endpoint_Info; + +void TAO_IIOP_Endpoint_Info::_tao_any_destructor (void *x) +{ + TAO_IIOP_Endpoint_Info *tmp = ACE_static_cast (TAO_IIOP_Endpoint_Info*,x); + delete tmp; +} + + +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + +#if !defined (__TAO_UNBOUNDED_SEQUENCE_TAO_IIOPENDPOINTSEQUENCE_CS_) +#define __TAO_UNBOUNDED_SEQUENCE_TAO_IIOPENDPOINTSEQUENCE_CS_ + + void + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::_allocate_buffer (CORBA::ULong length) + { + TAO_IIOP_Endpoint_Info* tmp = 0; + tmp = _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (length); + + if (this->buffer_ != 0) + { + TAO_IIOP_Endpoint_Info *old = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info *,this->buffer_); + + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp[i] = old[i]; + + if (this->release_) + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::freebuf (old); + + } + this->buffer_ = tmp; + } + + void + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::_deallocate_buffer (void) + { + if (this->buffer_ == 0 || this->release_ == 0) + return; + + TAO_IIOP_Endpoint_Info *tmp = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info *,this->buffer_); + + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::freebuf (tmp); + this->buffer_ = 0; + } + + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::~_TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (void) // Dtor. + { + this->_deallocate_buffer (); + } + + +#endif /* end #if !defined */ + + +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + +#if !defined (_TAO_IIOPENDPOINTSEQUENCE_CS_) +#define _TAO_IIOPENDPOINTSEQUENCE_CS_ + +// ************************************************************* +// TAO_IIOPEndpointSequence +// ************************************************************* + +TAO_IIOPEndpointSequence::TAO_IIOPEndpointSequence (void) +{} +TAO_IIOPEndpointSequence::TAO_IIOPEndpointSequence (CORBA::ULong max) // uses max size + : +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_IIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + (max) +{} +TAO_IIOPEndpointSequence::TAO_IIOPEndpointSequence (CORBA::ULong max, CORBA::ULong length, TAO_IIOP_Endpoint_Info *buffer, CORBA::Boolean release) + : +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_IIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + (max, length, buffer, release) +{} +TAO_IIOPEndpointSequence::TAO_IIOPEndpointSequence (const TAO_IIOPEndpointSequence &seq) // copy ctor + : +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_IIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + (seq) +{} +TAO_IIOPEndpointSequence::~TAO_IIOPEndpointSequence (void) // dtor +{} +void TAO_IIOPEndpointSequence::_tao_any_destructor (void *x) +{ + TAO_IIOPEndpointSequence *tmp = ACE_static_cast (TAO_IIOPEndpointSequence*,x); + delete tmp; +} + + +#endif /* end #if !defined */ + +static const CORBA::Long _oc_TAO_IIOPEndpointSequence[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 33, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x49494f50), ACE_NTOHL (0x456e6470), ACE_NTOHL (0x6f696e74), ACE_NTOHL (0x53657175), ACE_NTOHL (0x656e6365), ACE_NTOHL (0x3a312e30), ACE_NTOHL (0x0), // repository ID = IDL:TAO_IIOPEndpointSequence:1.0 + 25, ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x49494f50), ACE_NTOHL (0x456e6470), ACE_NTOHL (0x6f696e74), ACE_NTOHL (0x53657175), ACE_NTOHL (0x656e6365), ACE_NTOHL (0x0), // name = TAO_IIOPEndpointSequence + CORBA::tk_sequence, // typecode kind + 144, // encapsulation length + TAO_ENCAP_BYTE_ORDER, // byte order + CORBA::tk_struct, // typecode kind + 128, // encapsulation length + TAO_ENCAP_BYTE_ORDER, // byte order + 31, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x49494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f3a31), ACE_NTOHL (0x2e300000), // repository ID = IDL:TAO_IIOP_Endpoint_Info:1.0 + 23, ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x49494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f0000), // name = TAO_IIOP_Endpoint_Info + 3, // member count + 5, ACE_NTOHL (0x686f7374), ACE_NTOHL (0x0), // name = host + CORBA::tk_string, + 0U, // string length + 5, ACE_NTOHL (0x706f7274), ACE_NTOHL (0x0), // name = port + CORBA::tk_short, + + 9, ACE_NTOHL (0x7072696f), ACE_NTOHL (0x72697479), ACE_NTOHL (0x0), // name = priority + CORBA::tk_short, + + + 0U, + +}; +static CORBA::TypeCode _tc_TAO_tc_TAO_IIOPEndpointSequence (CORBA::tk_alias, sizeof (_oc_TAO_IIOPEndpointSequence), (char *) &_oc_TAO_IIOPEndpointSequence, 0, sizeof (TAO_IIOPEndpointSequence)); +CORBA::TypeCode_ptr _tc_TAO_IIOPEndpointSequence = &_tc_TAO_tc_TAO_IIOPEndpointSequence; + +void operator<<= (CORBA::Any &_tao_any, const TAO_IIOP_Endpoint_Info &_tao_elem) // copying +{ + TAO_OutputCDR stream; + stream << _tao_elem; + _tao_any._tao_replace ( + _tc_TAO_IIOP_Endpoint_Info, + TAO_ENCAP_BYTE_ORDER, + stream.begin () + ); +} + +void operator<<= (CORBA::Any &_tao_any, TAO_IIOP_Endpoint_Info *_tao_elem) // non copying +{ + TAO_OutputCDR stream; + stream << *_tao_elem; + _tao_any._tao_replace ( + _tc_TAO_IIOP_Endpoint_Info, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _tao_elem, + TAO_IIOP_Endpoint_Info::_tao_any_destructor + ); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TAO_IIOP_Endpoint_Info *&_tao_elem) +{ + return _tao_any >>= ACE_const_cast(const TAO_IIOP_Endpoint_Info*&,_tao_elem); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const TAO_IIOP_Endpoint_Info *&_tao_elem) +{ + _tao_elem = 0; + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equivalent (_tc_TAO_IIOP_Endpoint_Info, ACE_TRY_ENV)) // not equal + { + return 0; + } + ACE_TRY_CHECK; + if (_tao_any.any_owns_data ()) + { + _tao_elem = ACE_static_cast( + const TAO_IIOP_Endpoint_Info*, + _tao_any.value () + ); + return 1; + } + else + { + TAO_IIOP_Endpoint_Info *tmp; + ACE_NEW_RETURN (tmp, TAO_IIOP_Endpoint_Info, 0); + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *tmp) + { + ((CORBA::Any *)&_tao_any)->_tao_replace ( + _tc_TAO_IIOP_Endpoint_Info, + 1, + ACE_static_cast (void *, tmp), + TAO_IIOP_Endpoint_Info::_tao_any_destructor + ); + _tao_elem = tmp; + return 1; + } + else + { + delete tmp; + } + } + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + return 0; +} + +void operator<<= ( + CORBA::Any &_tao_any, + const TAO_IIOPEndpointSequence &_tao_elem + ) // copying +{ + TAO_OutputCDR stream; + if (stream << _tao_elem) + { + _tao_any._tao_replace ( + _tc_TAO_IIOPEndpointSequence, + TAO_ENCAP_BYTE_ORDER, + stream.begin () + ); + } +} + +void operator<<= (CORBA::Any &_tao_any, TAO_IIOPEndpointSequence *_tao_elem) // non copying +{ + TAO_OutputCDR stream; + stream << *_tao_elem; + _tao_any._tao_replace ( + _tc_TAO_IIOPEndpointSequence, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _tao_elem, + TAO_IIOPEndpointSequence::_tao_any_destructor + ); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TAO_IIOPEndpointSequence *&_tao_elem) +{ + return _tao_any >>= ACE_const_cast( + const TAO_IIOPEndpointSequence*&, + _tao_elem + ); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const TAO_IIOPEndpointSequence *&_tao_elem) +{ + _tao_elem = 0; + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equivalent (_tc_TAO_IIOPEndpointSequence, ACE_TRY_ENV)) // not equal + { + return 0; + } + ACE_TRY_CHECK; + if (_tao_any.any_owns_data ()) + { + _tao_elem = ACE_static_cast( + const TAO_IIOPEndpointSequence*, + _tao_any.value () + ); + return 1; + } + else + { + TAO_IIOPEndpointSequence *tmp; + ACE_NEW_RETURN (tmp, TAO_IIOPEndpointSequence, 0); + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *tmp) + { + ((CORBA::Any *)&_tao_any)->_tao_replace ( + _tc_TAO_IIOPEndpointSequence, + 1, + ACE_static_cast (void *, tmp), + TAO_IIOPEndpointSequence::_tao_any_destructor + ); + _tao_elem = tmp; + return 1; + } + else + { + delete tmp; + } + } + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + return 0; +} + +CORBA::Boolean operator<< ( + TAO_OutputCDR &strm, + const TAO_IIOPEndpointSequence &_tao_sequence + ) +{ + if (strm << _tao_sequence.length ()) + { + // encode all elements + CORBA::Boolean _tao_marshal_flag = 1; + for (CORBA::ULong i = 0; i < _tao_sequence.length () && _tao_marshal_flag; i++) + { + _tao_marshal_flag = (strm << _tao_sequence[i]); + } + return _tao_marshal_flag; + } + return 0; // error +} + +CORBA::Boolean operator>> ( + TAO_InputCDR &strm, + TAO_IIOPEndpointSequence &_tao_sequence + ) +{ + CORBA::ULong _tao_seq_len; + if (strm >> _tao_seq_len) + { + // set the length of the sequence + _tao_sequence.length (_tao_seq_len); + // If length is 0 we return true. + if (0 >= _tao_seq_len) + return 1; + // retrieve all the elements + CORBA::Boolean _tao_marshal_flag = 1; + for (CORBA::ULong i = 0; i < _tao_sequence.length () && _tao_marshal_flag; i++) + { + _tao_marshal_flag = (strm >> _tao_sequence[i]); + } + return _tao_marshal_flag; + } + return 0; // error +} + diff --git a/TAO/tao/iiop_endpoints.h b/TAO/tao/iiop_endpoints.h new file mode 100644 index 00000000000..d4b3dae8854 --- /dev/null +++ b/TAO/tao/iiop_endpoints.h @@ -0,0 +1,302 @@ +/* -*- C++ -*- $Id$ */ +// $Id$ +// +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#ifndef _TAO_IDL_IIOP_ENDPOINTSC_H_ +#define _TAO_IDL_IIOP_ENDPOINTSC_H_ + +#include "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Managed_Types.h" +#include "tao/corbafwd.h" +#include "tao/Sequence.h" +#include "tao/Any.h" +#include "tao/Typecode.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_Export + +#if defined (TAO_EXPORT_NESTED_CLASSES) +# if defined (TAO_EXPORT_NESTED_MACRO) +# undef TAO_EXPORT_NESTED_MACRO +# endif /* defined (TAO_EXPORT_NESTED_MACRO) */ +# define TAO_EXPORT_NESTED_MACRO TAO_Export +#endif /* TAO_EXPORT_NESTED_CLASSES */ + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +struct TAO_IIOP_Endpoint_Info; +class TAO_IIOP_Endpoint_Info_var; + +struct TAO_Export TAO_IIOP_Endpoint_Info +{ + +#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8) + typedef TAO_IIOP_Endpoint_Info_var _var_type; +#endif /* ! __GNUC__ || g++ >= 2.8 */ + + static void _tao_any_destructor (void*); + + TAO_String_Manager host; + CORBA::Short port; + CORBA::Short priority; +}; + +class TAO_Export TAO_IIOP_Endpoint_Info_var +{ +public: + TAO_IIOP_Endpoint_Info_var (void); // default constructor + TAO_IIOP_Endpoint_Info_var (TAO_IIOP_Endpoint_Info *); + TAO_IIOP_Endpoint_Info_var (const TAO_IIOP_Endpoint_Info_var &); // copy constructor + ~TAO_IIOP_Endpoint_Info_var (void); // destructor + + TAO_IIOP_Endpoint_Info_var &operator= (TAO_IIOP_Endpoint_Info *); + TAO_IIOP_Endpoint_Info_var &operator= (const TAO_IIOP_Endpoint_Info_var &); + TAO_IIOP_Endpoint_Info *operator-> (void); + const TAO_IIOP_Endpoint_Info *operator-> (void) const; + + operator const TAO_IIOP_Endpoint_Info &() const; + operator TAO_IIOP_Endpoint_Info &(); + operator TAO_IIOP_Endpoint_Info &() const; + operator TAO_IIOP_Endpoint_Info *&(); // variable-size types only + + // in, inout, out, _retn + const TAO_IIOP_Endpoint_Info &in (void) const; + TAO_IIOP_Endpoint_Info &inout (void); + TAO_IIOP_Endpoint_Info *&out (void); + TAO_IIOP_Endpoint_Info *_retn (void); + TAO_IIOP_Endpoint_Info *ptr (void) const; + +private: + TAO_IIOP_Endpoint_Info *ptr_; +}; + +class TAO_Export TAO_IIOP_Endpoint_Info_out +{ +public: + TAO_IIOP_Endpoint_Info_out (TAO_IIOP_Endpoint_Info *&); + TAO_IIOP_Endpoint_Info_out (TAO_IIOP_Endpoint_Info_var &); + TAO_IIOP_Endpoint_Info_out (const TAO_IIOP_Endpoint_Info_out &); + TAO_IIOP_Endpoint_Info_out &operator= (const TAO_IIOP_Endpoint_Info_out &); + TAO_IIOP_Endpoint_Info_out &operator= (TAO_IIOP_Endpoint_Info *); + operator TAO_IIOP_Endpoint_Info *&(); + TAO_IIOP_Endpoint_Info *&ptr (void); + TAO_IIOP_Endpoint_Info *operator-> (void); + +private: + TAO_IIOP_Endpoint_Info *&ptr_; + // assignment from T_var not allowed + void operator= (const TAO_IIOP_Endpoint_Info_var &); +}; + +extern TAO_Export CORBA::TypeCode_ptr _tc_TAO_IIOP_Endpoint_Info; + + +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + +#if !defined (__TAO_UNBOUNDED_SEQUENCE_TAO_IIOPENDPOINTSEQUENCE_CH_) +#define __TAO_UNBOUNDED_SEQUENCE_TAO_IIOPENDPOINTSEQUENCE_CH_ + + class TAO_EXPORT_NESTED_MACRO _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence : public TAO_Unbounded_Base_Sequence + { + public: + // = Initialization and termination methods. + + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (void); // Default constructor. + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (CORBA::ULong maximum); + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (CORBA::ULong maximum, + CORBA::ULong length, + TAO_IIOP_Endpoint_Info *data, + CORBA::Boolean release = 0); + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (const _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence &rhs); + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence &operator= (const _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence &rhs); + virtual ~_TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (void); // Dtor. + // = Accessors. + TAO_IIOP_Endpoint_Info &operator[] (CORBA::ULong i); + const TAO_IIOP_Endpoint_Info &operator[] (CORBA::ULong i) const; + // = Static operations. + static TAO_IIOP_Endpoint_Info *allocbuf (CORBA::ULong size); + static void freebuf (TAO_IIOP_Endpoint_Info *buffer); + virtual void _allocate_buffer (CORBA::ULong length); + virtual void _deallocate_buffer (void); + // Implement the TAO_Base_Sequence methods (see Sequence.h) + + TAO_IIOP_Endpoint_Info *get_buffer (CORBA::Boolean orphan = 0); + const TAO_IIOP_Endpoint_Info *get_buffer (void) const; + void replace (CORBA::ULong max, + CORBA::ULong length, + TAO_IIOP_Endpoint_Info *data, + CORBA::Boolean release); + }; + +#endif /* end #if !defined */ + + +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + +#if !defined (_TAO_IIOPENDPOINTSEQUENCE_CH_) +#define _TAO_IIOPENDPOINTSEQUENCE_CH_ + +class TAO_IIOPEndpointSequence; +class TAO_IIOPEndpointSequence_var; + +// ************************************************************* +// TAO_IIOPEndpointSequence +// ************************************************************* + +class TAO_Export TAO_IIOPEndpointSequence : public +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_IIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ +{ +public: + TAO_IIOPEndpointSequence (void); // default ctor + TAO_IIOPEndpointSequence (CORBA::ULong max); // uses max size + TAO_IIOPEndpointSequence ( + CORBA::ULong max, + CORBA::ULong length, + TAO_IIOP_Endpoint_Info *buffer, + CORBA::Boolean release=0 + ); + TAO_IIOPEndpointSequence (const TAO_IIOPEndpointSequence &); // copy ctor + ~TAO_IIOPEndpointSequence (void); + static void _tao_any_destructor (void*); + +#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8) + typedef TAO_IIOPEndpointSequence_var _var_type; +#endif /* ! __GNUC__ || g++ >= 2.8 */ + +}; + +#endif /* end #if !defined */ + + +#if !defined (_TAO_IIOPENDPOINTSEQUENCE___VAR_CH_) +#define _TAO_IIOPENDPOINTSEQUENCE___VAR_CH_ + +// ************************************************************* +// class TAO_IIOPEndpointSequence_var +// ************************************************************* + +class TAO_Export TAO_IIOPEndpointSequence_var +{ +public: + TAO_IIOPEndpointSequence_var (void); // default constructor + TAO_IIOPEndpointSequence_var (TAO_IIOPEndpointSequence *); + TAO_IIOPEndpointSequence_var (const TAO_IIOPEndpointSequence_var &); // copy constructor + ~TAO_IIOPEndpointSequence_var (void); // destructor + + TAO_IIOPEndpointSequence_var &operator= (TAO_IIOPEndpointSequence *); + TAO_IIOPEndpointSequence_var &operator= (const TAO_IIOPEndpointSequence_var &); + TAO_IIOPEndpointSequence *operator-> (void); + const TAO_IIOPEndpointSequence *operator-> (void) const; + + operator const TAO_IIOPEndpointSequence &() const; + operator TAO_IIOPEndpointSequence &(); + operator TAO_IIOPEndpointSequence &() const; + operator TAO_IIOPEndpointSequence *&(); // variable-size base types only + + TAO_IIOP_Endpoint_Info &operator[] (CORBA::ULong index); + // in, inout, out, _retn + const TAO_IIOPEndpointSequence &in (void) const; + TAO_IIOPEndpointSequence &inout (void); + TAO_IIOPEndpointSequence *&out (void); + TAO_IIOPEndpointSequence *_retn (void); + TAO_IIOPEndpointSequence *ptr (void) const; + +private: + TAO_IIOPEndpointSequence *ptr_; +}; + + +#endif /* end #if !defined */ + + +#if !defined (_TAO_IIOPENDPOINTSEQUENCE___OUT_CH_) +#define _TAO_IIOPENDPOINTSEQUENCE___OUT_CH_ + +class TAO_Export TAO_IIOPEndpointSequence_out +{ +public: + TAO_IIOPEndpointSequence_out (TAO_IIOPEndpointSequence *&); + TAO_IIOPEndpointSequence_out (TAO_IIOPEndpointSequence_var &); + TAO_IIOPEndpointSequence_out (const TAO_IIOPEndpointSequence_out &); + TAO_IIOPEndpointSequence_out &operator= (const TAO_IIOPEndpointSequence_out &); + TAO_IIOPEndpointSequence_out &operator= (TAO_IIOPEndpointSequence *); + operator TAO_IIOPEndpointSequence *&(); + TAO_IIOPEndpointSequence *&ptr (void); + TAO_IIOPEndpointSequence *operator-> (void); + TAO_IIOP_Endpoint_Info &operator[] (CORBA::ULong index); + +private: + TAO_IIOPEndpointSequence *&ptr_; + // assignment from T_var not allowed + void operator= (const TAO_IIOPEndpointSequence_var &); +}; + + +#endif /* end #if !defined */ + +extern TAO_Export CORBA::TypeCode_ptr _tc_TAO_IIOPEndpointSequence; + +TAO_Export void operator<<= (CORBA::Any &, const TAO_IIOP_Endpoint_Info &); // copying version +TAO_Export void operator<<= (CORBA::Any &, TAO_IIOP_Endpoint_Info*); // noncopying version +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, TAO_IIOP_Endpoint_Info *&); // deprecated +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const TAO_IIOP_Endpoint_Info *&); +TAO_Export void operator<<= (CORBA::Any &, const TAO_IIOPEndpointSequence &); // copying version +TAO_Export void operator<<= (CORBA::Any &, TAO_IIOPEndpointSequence*); // noncopying version +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, TAO_IIOPEndpointSequence *&); // deprecated +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const TAO_IIOPEndpointSequence *&); + +#ifndef __ACE_INLINE__ + +TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &, const TAO_IIOP_Endpoint_Info &); +TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &, TAO_IIOP_Endpoint_Info &); + +#if !defined _TAO_CDR_OP_TAO_IIOPEndpointSequence_H_ +#define _TAO_CDR_OP_TAO_IIOPEndpointSequence_H_ + +TAO_Export CORBA::Boolean operator<< ( + TAO_OutputCDR &, + const TAO_IIOPEndpointSequence & + ); +TAO_Export CORBA::Boolean operator>> ( + TAO_InputCDR &, + TAO_IIOPEndpointSequence & + ); + +#endif /* _TAO_CDR_OP_TAO_IIOPEndpointSequence_H_ */ + + +#endif /* __ACE_INLINE__ */ + + +#if defined (__ACE_INLINE__) +#include "iiop_endpoints.i" +#endif /* defined INLINE */ + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /* ifndef */ diff --git a/TAO/tao/iiop_endpoints.i b/TAO/tao/iiop_endpoints.i new file mode 100644 index 00000000000..19cb348c5f3 --- /dev/null +++ b/TAO/tao/iiop_endpoints.i @@ -0,0 +1,598 @@ +/* -*- C++ -*- $Id$ */ +// $Id$ +// +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// ************************************************************* +// Inline operations for class TAO_IIOP_Endpoint_Info_var +// ************************************************************* + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::TAO_IIOP_Endpoint_Info_var (void) // default constructor + : ptr_ (0) +{} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::TAO_IIOP_Endpoint_Info_var (TAO_IIOP_Endpoint_Info *p) + : ptr_ (p) +{} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::TAO_IIOP_Endpoint_Info_var (const ::TAO_IIOP_Endpoint_Info_var &p) // copy constructor +{ + if (p.ptr_) + ACE_NEW (this->ptr_, ::TAO_IIOP_Endpoint_Info (*p.ptr_)); + else + this->ptr_ = 0; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::~TAO_IIOP_Endpoint_Info_var (void) // destructor +{ + delete this->ptr_; +} + +ACE_INLINE TAO_IIOP_Endpoint_Info_var & +TAO_IIOP_Endpoint_Info_var::operator= (TAO_IIOP_Endpoint_Info *p) +{ + delete this->ptr_; + this->ptr_ = p; + return *this; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info_var & +TAO_IIOP_Endpoint_Info_var::operator= (const ::TAO_IIOP_Endpoint_Info_var &p) +{ + if (this != &p) + { + delete this->ptr_; + ACE_NEW_RETURN (this->ptr_, ::TAO_IIOP_Endpoint_Info (*p.ptr_), *this); + } + return *this; +} + +ACE_INLINE const ::TAO_IIOP_Endpoint_Info * +TAO_IIOP_Endpoint_Info_var::operator-> (void) const +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info * +TAO_IIOP_Endpoint_Info_var::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::operator const ::TAO_IIOP_Endpoint_Info &() const // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::operator ::TAO_IIOP_Endpoint_Info &() // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::operator ::TAO_IIOP_Endpoint_Info &() const // cast +{ + return *this->ptr_; +} + +// variable-size types only +ACE_INLINE +TAO_IIOP_Endpoint_Info_var::operator ::TAO_IIOP_Endpoint_Info *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE const ::TAO_IIOP_Endpoint_Info & +TAO_IIOP_Endpoint_Info_var::in (void) const +{ + return *this->ptr_; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info & +TAO_IIOP_Endpoint_Info_var::inout (void) +{ + return *this->ptr_; +} + +// mapping for variable size +ACE_INLINE ::TAO_IIOP_Endpoint_Info *& +TAO_IIOP_Endpoint_Info_var::out (void) +{ + delete this->ptr_; + this->ptr_ = 0; + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info * +TAO_IIOP_Endpoint_Info_var::_retn (void) +{ + ::TAO_IIOP_Endpoint_Info *tmp = this->ptr_; + this->ptr_ = 0; + return tmp; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info * +TAO_IIOP_Endpoint_Info_var::ptr (void) const +{ + return this->ptr_; +} + +// ************************************************************* +// Inline operations for class TAO_IIOP_Endpoint_Info_out +// ************************************************************* + +ACE_INLINE +TAO_IIOP_Endpoint_Info_out::TAO_IIOP_Endpoint_Info_out (::TAO_IIOP_Endpoint_Info *&p) + : ptr_ (p) +{ + this->ptr_ = 0; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_out::TAO_IIOP_Endpoint_Info_out (TAO_IIOP_Endpoint_Info_var &p) // constructor from _var + : ptr_ (p.out ()) +{ + delete this->ptr_; + this->ptr_ = 0; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_out::TAO_IIOP_Endpoint_Info_out (const ::TAO_IIOP_Endpoint_Info_out &p) // copy constructor + : ptr_ (ACE_const_cast (TAO_IIOP_Endpoint_Info_out&, p).ptr_) +{} + +ACE_INLINE TAO_IIOP_Endpoint_Info_out & +TAO_IIOP_Endpoint_Info_out::operator= (const ::TAO_IIOP_Endpoint_Info_out &p) +{ + this->ptr_ = ACE_const_cast (TAO_IIOP_Endpoint_Info_out&, p).ptr_; + return *this; +} + +ACE_INLINE TAO_IIOP_Endpoint_Info_out & +TAO_IIOP_Endpoint_Info_out::operator= (TAO_IIOP_Endpoint_Info *p) +{ + this->ptr_ = p; + return *this; +} + +ACE_INLINE +TAO_IIOP_Endpoint_Info_out::operator ::TAO_IIOP_Endpoint_Info *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info *& +TAO_IIOP_Endpoint_Info_out::ptr (void) // ptr +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOP_Endpoint_Info * +TAO_IIOP_Endpoint_Info_out::operator-> (void) +{ + return this->ptr_; +} + + +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + +#if !defined (__TAO_UNBOUNDED_SEQUENCE_TAO_IIOPENDPOINTSEQUENCE_CI_) +#define __TAO_UNBOUNDED_SEQUENCE_TAO_IIOPENDPOINTSEQUENCE_CI_ + + // = Static operations. + ACE_INLINE TAO_IIOP_Endpoint_Info * + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (CORBA::ULong size) + // Allocate storage for the sequence. + { + TAO_IIOP_Endpoint_Info *retval = 0; + ACE_NEW_RETURN (retval, TAO_IIOP_Endpoint_Info[size], 0); + return retval; + } + + ACE_INLINE void _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::freebuf (TAO_IIOP_Endpoint_Info *buffer) + // Free the sequence. + { + delete [] buffer; + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (void) // Default constructor. + { + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (CORBA::ULong maximum) // Constructor using a maximum length value. + : TAO_Unbounded_Base_Sequence (maximum, _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (maximum)) + { + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (CORBA::ULong maximum, + CORBA::ULong length, + TAO_IIOP_Endpoint_Info *data, + CORBA::Boolean release) + : TAO_Unbounded_Base_Sequence (maximum, length, data, release) + { + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence (const _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence &rhs) + // Copy constructor. + : TAO_Unbounded_Base_Sequence (rhs) + { + if (rhs.buffer_ != 0) + { + TAO_IIOP_Endpoint_Info *tmp1 = _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (this->maximum_); + TAO_IIOP_Endpoint_Info * const tmp2 = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info * ACE_CAST_CONST, rhs.buffer_); + + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp1[i] = tmp2[i]; + + this->buffer_ = tmp1; + } + else + { + this->buffer_ = 0; + } + } + + ACE_INLINE _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence & + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::operator= (const _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence &rhs) + // Assignment operator. + { + if (this == &rhs) + return *this; + + if (this->release_) + { + if (this->maximum_ < rhs.maximum_) + { + // free the old buffer + TAO_IIOP_Endpoint_Info *tmp = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info *, this->buffer_); + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::freebuf (tmp); + this->buffer_ = _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (rhs.maximum_); + } + } + else + this->buffer_ = _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (rhs.maximum_); + + TAO_Unbounded_Base_Sequence::operator= (rhs); + + TAO_IIOP_Endpoint_Info *tmp1 = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info *, this->buffer_); + TAO_IIOP_Endpoint_Info * const tmp2 = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info * ACE_CAST_CONST, rhs.buffer_); + + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp1[i] = tmp2[i]; + + return *this; + } + + // = Accessors. + ACE_INLINE TAO_IIOP_Endpoint_Info & + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::operator[] (CORBA::ULong i) + // operator [] + { + ACE_ASSERT (i < this->maximum_); + TAO_IIOP_Endpoint_Info* tmp = ACE_reinterpret_cast(TAO_IIOP_Endpoint_Info*,this->buffer_); + return tmp[i]; + } + + ACE_INLINE const TAO_IIOP_Endpoint_Info & + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::operator[] (CORBA::ULong i) const + // operator [] + { + ACE_ASSERT (i < this->maximum_); + TAO_IIOP_Endpoint_Info * const tmp = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info* ACE_CAST_CONST, this->buffer_); + return tmp[i]; + } + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + + ACE_INLINE TAO_IIOP_Endpoint_Info * + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::get_buffer (CORBA::Boolean orphan) + { + TAO_IIOP_Endpoint_Info *result = 0; + if (orphan == 0) + { + // We retain ownership. + if (this->buffer_ == 0) + { + result = _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::allocbuf (this->length_); + this->buffer_ = result; + this->release_ = 1; + } + else + { + result = ACE_reinterpret_cast (TAO_IIOP_Endpoint_Info*, this->buffer_); + } + } + else // if (orphan == 1) + { + if (this->release_ != 0) + { + // We set the state back to default and relinquish + // ownership. + result = ACE_reinterpret_cast(TAO_IIOP_Endpoint_Info*,this->buffer_); + this->maximum_ = 0; + this->length_ = 0; + this->buffer_ = 0; + this->release_ = 0; + } + } + return result; + } + + ACE_INLINE const TAO_IIOP_Endpoint_Info * + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::get_buffer (void) const + { + return ACE_reinterpret_cast(const TAO_IIOP_Endpoint_Info * ACE_CAST_CONST, this->buffer_); + } + + ACE_INLINE void + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::replace (CORBA::ULong max, + CORBA::ULong length, + TAO_IIOP_Endpoint_Info *data, + CORBA::Boolean release) + { + this->maximum_ = max; + this->length_ = length; + if (this->buffer_ && this->release_ == 1) + { + TAO_IIOP_Endpoint_Info *tmp = ACE_reinterpret_cast(TAO_IIOP_Endpoint_Info*,this->buffer_); + _TAO_Unbounded_Sequence_TAO_IIOPEndpointSequence::freebuf (tmp); + } + this->buffer_ = data; + this->release_ = release; + } + +#endif /* end #if !defined */ + + +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + +#if !defined (_TAO_IIOPENDPOINTSEQUENCE_CI_) +#define _TAO_IIOPENDPOINTSEQUENCE_CI_ + +// ************************************************************* +// Inline operations for class TAO_IIOPEndpointSequence_var +// ************************************************************* + +ACE_INLINE +TAO_IIOPEndpointSequence_var::TAO_IIOPEndpointSequence_var (void) // default constructor + : ptr_ (0) +{} + +ACE_INLINE +TAO_IIOPEndpointSequence_var::TAO_IIOPEndpointSequence_var (TAO_IIOPEndpointSequence *p) + : ptr_ (p) +{} + +ACE_INLINE +TAO_IIOPEndpointSequence_var::TAO_IIOPEndpointSequence_var (const ::TAO_IIOPEndpointSequence_var &p) // copy constructor +{ + if (p.ptr_) + ACE_NEW (this->ptr_, ::TAO_IIOPEndpointSequence (*p.ptr_)); + else + this->ptr_ = 0; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_var::~TAO_IIOPEndpointSequence_var (void) // destructor +{ + delete this->ptr_; +} + +ACE_INLINE TAO_IIOPEndpointSequence_var & +TAO_IIOPEndpointSequence_var::operator= (TAO_IIOPEndpointSequence *p) +{ + delete this->ptr_; + this->ptr_ = p; + return *this; +} + +ACE_INLINE TAO_IIOPEndpointSequence_var & +TAO_IIOPEndpointSequence_var::operator= (const ::TAO_IIOPEndpointSequence_var &p) // deep copy +{ + if (this != &p) + { + delete this->ptr_; + ACE_NEW_RETURN (this->ptr_, ::TAO_IIOPEndpointSequence (*p.ptr_), *this); + } + return *this; +} + +ACE_INLINE const ::TAO_IIOPEndpointSequence * +TAO_IIOPEndpointSequence_var::operator-> (void) const +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence * +TAO_IIOPEndpointSequence_var::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_var::operator const ::TAO_IIOPEndpointSequence &() const // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_var::operator ::TAO_IIOPEndpointSequence &() // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_var::operator ::TAO_IIOPEndpointSequence &() const // cast +{ + return *this->ptr_; +} + +// variable-size types only +ACE_INLINE +TAO_IIOPEndpointSequence_var::operator ::TAO_IIOPEndpointSequence *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE TAO_IIOP_Endpoint_Info & +TAO_IIOPEndpointSequence_var::operator[] (CORBA::ULong index) +{ + return this->ptr_->operator[] (index); +} + +ACE_INLINE const ::TAO_IIOPEndpointSequence & +TAO_IIOPEndpointSequence_var::in (void) const +{ + return *this->ptr_; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence & +TAO_IIOPEndpointSequence_var::inout (void) +{ + return *this->ptr_; +} + +// mapping for variable size +ACE_INLINE ::TAO_IIOPEndpointSequence *& +TAO_IIOPEndpointSequence_var::out (void) +{ + delete this->ptr_; + this->ptr_ = 0; + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence * +TAO_IIOPEndpointSequence_var::_retn (void) +{ + ::TAO_IIOPEndpointSequence *tmp = this->ptr_; + this->ptr_ = 0; + return tmp; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence * +TAO_IIOPEndpointSequence_var::ptr (void) const +{ + return this->ptr_; +} + +// ************************************************************* +// Inline operations for class TAO_IIOPEndpointSequence_out +// ************************************************************* + +ACE_INLINE +TAO_IIOPEndpointSequence_out::TAO_IIOPEndpointSequence_out (TAO_IIOPEndpointSequence *&p) + : ptr_ (p) +{ + this->ptr_ = 0; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_out::TAO_IIOPEndpointSequence_out (TAO_IIOPEndpointSequence_var &p) // constructor from _var + : ptr_ (p.out ()) +{ + delete this->ptr_; + this->ptr_ = 0; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_out::TAO_IIOPEndpointSequence_out (const ::TAO_IIOPEndpointSequence_out &p) // copy constructor + : ptr_ (ACE_const_cast (TAO_IIOPEndpointSequence_out&, p).ptr_) +{} + +ACE_INLINE ::TAO_IIOPEndpointSequence_out & +TAO_IIOPEndpointSequence_out::operator= (const ::TAO_IIOPEndpointSequence_out &p) +{ + this->ptr_ = ACE_const_cast (TAO_IIOPEndpointSequence_out&, p).ptr_; + return *this; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence_out & +TAO_IIOPEndpointSequence_out::operator= (TAO_IIOPEndpointSequence *p) +{ + this->ptr_ = p; + return *this; +} + +ACE_INLINE +TAO_IIOPEndpointSequence_out::operator ::TAO_IIOPEndpointSequence *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence *& +TAO_IIOPEndpointSequence_out::ptr (void) // ptr +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_IIOPEndpointSequence * +TAO_IIOPEndpointSequence_out::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE TAO_IIOP_Endpoint_Info & +TAO_IIOPEndpointSequence_out::operator[] (CORBA::ULong index) +{ + return this->ptr_->operator[] (index); +} + + +#endif /* end #if !defined */ + +ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &strm, const TAO_IIOP_Endpoint_Info &_tao_aggregate) +{ + if ( + (strm << _tao_aggregate.host.in ()) && + (strm << _tao_aggregate.port) && + (strm << _tao_aggregate.priority) + ) + return 1; + else + return 0; + +} + +ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, TAO_IIOP_Endpoint_Info &_tao_aggregate) +{ + if ( + (strm >> _tao_aggregate.host.out ()) && + (strm >> _tao_aggregate.port) && + (strm >> _tao_aggregate.priority) + ) + return 1; + else + return 0; + +} + + +#if !defined _TAO_CDR_OP_TAO_IIOPEndpointSequence_I_ +#define _TAO_CDR_OP_TAO_IIOPEndpointSequence_I_ + +CORBA::Boolean TAO_Export operator<< ( + TAO_OutputCDR &, + const TAO_IIOPEndpointSequence & + ); +CORBA::Boolean TAO_Export operator>> ( + TAO_InputCDR &, + TAO_IIOPEndpointSequence & + ); + +#endif /* _TAO_CDR_OP_TAO_IIOPEndpointSequence_I_ */ + diff --git a/TAO/tao/uiop_endpoints.cpp b/TAO/tao/uiop_endpoints.cpp new file mode 100644 index 00000000000..0b5194132f3 --- /dev/null +++ b/TAO/tao/uiop_endpoints.cpp @@ -0,0 +1,373 @@ +/* -*- C++ -*- $Id$ */ +// $Id$ +// +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "uiop_endpoints.h" + +#if !defined (__ACE_INLINE__) +#include "uiop_endpoints.i" +#endif /* !defined INLINE */ + +static const CORBA::Long _oc_TAO_UIOP_Endpoint_Info[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 31, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x55494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f3a31), ACE_NTOHL (0x2e300000), // repository ID = IDL:TAO_UIOP_Endpoint_Info:1.0 + 23, ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x55494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f0000), // name = TAO_UIOP_Endpoint_Info + 2, // member count + 17, ACE_NTOHL (0x72656e64), ACE_NTOHL (0x657a766f), ACE_NTOHL (0x75735f70), ACE_NTOHL (0x6f696e74), ACE_NTOHL (0x0), // name = rendezvous_point + CORBA::tk_string, + 0U, // string length + 9, ACE_NTOHL (0x7072696f), ACE_NTOHL (0x72697479), ACE_NTOHL (0x0), // name = priority + CORBA::tk_short, + +}; +static CORBA::TypeCode _tc_TAO_tc_TAO_UIOP_Endpoint_Info (CORBA::tk_struct, sizeof (_oc_TAO_UIOP_Endpoint_Info), (char *) &_oc_TAO_UIOP_Endpoint_Info, 0, sizeof (TAO_UIOP_Endpoint_Info)); +CORBA::TypeCode_ptr _tc_TAO_UIOP_Endpoint_Info = &_tc_TAO_tc_TAO_UIOP_Endpoint_Info; + +void TAO_UIOP_Endpoint_Info::_tao_any_destructor (void *x) +{ + TAO_UIOP_Endpoint_Info *tmp = ACE_static_cast (TAO_UIOP_Endpoint_Info*,x); + delete tmp; +} + + +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + +#if !defined (__TAO_UNBOUNDED_SEQUENCE_TAO_UIOPENDPOINTSEQUENCE_CS_) +#define __TAO_UNBOUNDED_SEQUENCE_TAO_UIOPENDPOINTSEQUENCE_CS_ + + void + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::_allocate_buffer (CORBA::ULong length) + { + TAO_UIOP_Endpoint_Info* tmp = 0; + tmp = _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (length); + + if (this->buffer_ != 0) + { + TAO_UIOP_Endpoint_Info *old = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info *,this->buffer_); + + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp[i] = old[i]; + + if (this->release_) + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::freebuf (old); + + } + this->buffer_ = tmp; + } + + void + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::_deallocate_buffer (void) + { + if (this->buffer_ == 0 || this->release_ == 0) + return; + + TAO_UIOP_Endpoint_Info *tmp = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info *,this->buffer_); + + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::freebuf (tmp); + this->buffer_ = 0; + } + + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::~_TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (void) // Dtor. + { + this->_deallocate_buffer (); + } + + +#endif /* end #if !defined */ + + +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + +#if !defined (_TAO_UIOPENDPOINTSEQUENCE_CS_) +#define _TAO_UIOPENDPOINTSEQUENCE_CS_ + +// ************************************************************* +// TAO_UIOPEndpointSequence +// ************************************************************* + +TAO_UIOPEndpointSequence::TAO_UIOPEndpointSequence (void) +{} +TAO_UIOPEndpointSequence::TAO_UIOPEndpointSequence (CORBA::ULong max) // uses max size + : +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_UIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + (max) +{} +TAO_UIOPEndpointSequence::TAO_UIOPEndpointSequence (CORBA::ULong max, CORBA::ULong length, TAO_UIOP_Endpoint_Info *buffer, CORBA::Boolean release) + : +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_UIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + (max, length, buffer, release) +{} +TAO_UIOPEndpointSequence::TAO_UIOPEndpointSequence (const TAO_UIOPEndpointSequence &seq) // copy ctor + : +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_UIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + (seq) +{} +TAO_UIOPEndpointSequence::~TAO_UIOPEndpointSequence (void) // dtor +{} +void TAO_UIOPEndpointSequence::_tao_any_destructor (void *x) +{ + TAO_UIOPEndpointSequence *tmp = ACE_static_cast (TAO_UIOPEndpointSequence*,x); + delete tmp; +} + + +#endif /* end #if !defined */ + +static const CORBA::Long _oc_TAO_UIOPEndpointSequence[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 33, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x55494f50), ACE_NTOHL (0x456e6470), ACE_NTOHL (0x6f696e74), ACE_NTOHL (0x53657175), ACE_NTOHL (0x656e6365), ACE_NTOHL (0x3a312e30), ACE_NTOHL (0x0), // repository ID = IDL:TAO_UIOPEndpointSequence:1.0 + 25, ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x55494f50), ACE_NTOHL (0x456e6470), ACE_NTOHL (0x6f696e74), ACE_NTOHL (0x53657175), ACE_NTOHL (0x656e6365), ACE_NTOHL (0x0), // name = TAO_UIOPEndpointSequence + CORBA::tk_sequence, // typecode kind + 140, // encapsulation length + TAO_ENCAP_BYTE_ORDER, // byte order + CORBA::tk_struct, // typecode kind + 124, // encapsulation length + TAO_ENCAP_BYTE_ORDER, // byte order + 31, ACE_NTOHL (0x49444c3a), ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x55494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f3a31), ACE_NTOHL (0x2e300000), // repository ID = IDL:TAO_UIOP_Endpoint_Info:1.0 + 23, ACE_NTOHL (0x54414f5f), ACE_NTOHL (0x55494f50), ACE_NTOHL (0x5f456e64), ACE_NTOHL (0x706f696e), ACE_NTOHL (0x745f496e), ACE_NTOHL (0x666f0000), // name = TAO_UIOP_Endpoint_Info + 2, // member count + 17, ACE_NTOHL (0x72656e64), ACE_NTOHL (0x657a766f), ACE_NTOHL (0x75735f70), ACE_NTOHL (0x6f696e74), ACE_NTOHL (0x0), // name = rendezvous_point + CORBA::tk_string, + 0U, // string length + 9, ACE_NTOHL (0x7072696f), ACE_NTOHL (0x72697479), ACE_NTOHL (0x0), // name = priority + CORBA::tk_short, + + + 0U, + +}; +static CORBA::TypeCode _tc_TAO_tc_TAO_UIOPEndpointSequence (CORBA::tk_alias, sizeof (_oc_TAO_UIOPEndpointSequence), (char *) &_oc_TAO_UIOPEndpointSequence, 0, sizeof (TAO_UIOPEndpointSequence)); +CORBA::TypeCode_ptr _tc_TAO_UIOPEndpointSequence = &_tc_TAO_tc_TAO_UIOPEndpointSequence; + +void operator<<= (CORBA::Any &_tao_any, const TAO_UIOP_Endpoint_Info &_tao_elem) // copying +{ + TAO_OutputCDR stream; + stream << _tao_elem; + _tao_any._tao_replace ( + _tc_TAO_UIOP_Endpoint_Info, + TAO_ENCAP_BYTE_ORDER, + stream.begin () + ); +} + +void operator<<= (CORBA::Any &_tao_any, TAO_UIOP_Endpoint_Info *_tao_elem) // non copying +{ + TAO_OutputCDR stream; + stream << *_tao_elem; + _tao_any._tao_replace ( + _tc_TAO_UIOP_Endpoint_Info, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _tao_elem, + TAO_UIOP_Endpoint_Info::_tao_any_destructor + ); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TAO_UIOP_Endpoint_Info *&_tao_elem) +{ + return _tao_any >>= ACE_const_cast(const TAO_UIOP_Endpoint_Info*&,_tao_elem); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const TAO_UIOP_Endpoint_Info *&_tao_elem) +{ + _tao_elem = 0; + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equivalent (_tc_TAO_UIOP_Endpoint_Info, ACE_TRY_ENV)) // not equal + { + return 0; + } + ACE_TRY_CHECK; + if (_tao_any.any_owns_data ()) + { + _tao_elem = ACE_static_cast( + const TAO_UIOP_Endpoint_Info*, + _tao_any.value () + ); + return 1; + } + else + { + TAO_UIOP_Endpoint_Info *tmp; + ACE_NEW_RETURN (tmp, TAO_UIOP_Endpoint_Info, 0); + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *tmp) + { + ((CORBA::Any *)&_tao_any)->_tao_replace ( + _tc_TAO_UIOP_Endpoint_Info, + 1, + ACE_static_cast (void *, tmp), + TAO_UIOP_Endpoint_Info::_tao_any_destructor + ); + _tao_elem = tmp; + return 1; + } + else + { + delete tmp; + } + } + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + return 0; +} + +void operator<<= ( + CORBA::Any &_tao_any, + const TAO_UIOPEndpointSequence &_tao_elem + ) // copying +{ + TAO_OutputCDR stream; + if (stream << _tao_elem) + { + _tao_any._tao_replace ( + _tc_TAO_UIOPEndpointSequence, + TAO_ENCAP_BYTE_ORDER, + stream.begin () + ); + } +} + +void operator<<= (CORBA::Any &_tao_any, TAO_UIOPEndpointSequence *_tao_elem) // non copying +{ + TAO_OutputCDR stream; + stream << *_tao_elem; + _tao_any._tao_replace ( + _tc_TAO_UIOPEndpointSequence, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _tao_elem, + TAO_UIOPEndpointSequence::_tao_any_destructor + ); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TAO_UIOPEndpointSequence *&_tao_elem) +{ + return _tao_any >>= ACE_const_cast( + const TAO_UIOPEndpointSequence*&, + _tao_elem + ); +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const TAO_UIOPEndpointSequence *&_tao_elem) +{ + _tao_elem = 0; + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equivalent (_tc_TAO_UIOPEndpointSequence, ACE_TRY_ENV)) // not equal + { + return 0; + } + ACE_TRY_CHECK; + if (_tao_any.any_owns_data ()) + { + _tao_elem = ACE_static_cast( + const TAO_UIOPEndpointSequence*, + _tao_any.value () + ); + return 1; + } + else + { + TAO_UIOPEndpointSequence *tmp; + ACE_NEW_RETURN (tmp, TAO_UIOPEndpointSequence, 0); + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *tmp) + { + ((CORBA::Any *)&_tao_any)->_tao_replace ( + _tc_TAO_UIOPEndpointSequence, + 1, + ACE_static_cast (void *, tmp), + TAO_UIOPEndpointSequence::_tao_any_destructor + ); + _tao_elem = tmp; + return 1; + } + else + { + delete tmp; + } + } + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + return 0; +} + +CORBA::Boolean operator<< ( + TAO_OutputCDR &strm, + const TAO_UIOPEndpointSequence &_tao_sequence + ) +{ + if (strm << _tao_sequence.length ()) + { + // encode all elements + CORBA::Boolean _tao_marshal_flag = 1; + for (CORBA::ULong i = 0; i < _tao_sequence.length () && _tao_marshal_flag; i++) + { + _tao_marshal_flag = (strm << _tao_sequence[i]); + } + return _tao_marshal_flag; + } + return 0; // error +} + +CORBA::Boolean operator>> ( + TAO_InputCDR &strm, + TAO_UIOPEndpointSequence &_tao_sequence + ) +{ + CORBA::ULong _tao_seq_len; + if (strm >> _tao_seq_len) + { + // set the length of the sequence + _tao_sequence.length (_tao_seq_len); + // If length is 0 we return true. + if (0 >= _tao_seq_len) + return 1; + // retrieve all the elements + CORBA::Boolean _tao_marshal_flag = 1; + for (CORBA::ULong i = 0; i < _tao_sequence.length () && _tao_marshal_flag; i++) + { + _tao_marshal_flag = (strm >> _tao_sequence[i]); + } + return _tao_marshal_flag; + } + return 0; // error +} + diff --git a/TAO/tao/uiop_endpoints.h b/TAO/tao/uiop_endpoints.h new file mode 100644 index 00000000000..34e9de0535b --- /dev/null +++ b/TAO/tao/uiop_endpoints.h @@ -0,0 +1,301 @@ +/* -*- C++ -*- $Id$ */ +// $Id$ +// +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#ifndef _TAO_IDL_UIOP_ENDPOINTSC_H_ +#define _TAO_IDL_UIOP_ENDPOINTSC_H_ + +#include "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Managed_Types.h" +#include "tao/corbafwd.h" +#include "tao/Sequence.h" +#include "tao/Any.h" +#include "tao/Typecode.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_Export + +#if defined (TAO_EXPORT_NESTED_CLASSES) +# if defined (TAO_EXPORT_NESTED_MACRO) +# undef TAO_EXPORT_NESTED_MACRO +# endif /* defined (TAO_EXPORT_NESTED_MACRO) */ +# define TAO_EXPORT_NESTED_MACRO TAO_Export +#endif /* TAO_EXPORT_NESTED_CLASSES */ + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +struct TAO_UIOP_Endpoint_Info; +class TAO_UIOP_Endpoint_Info_var; + +struct TAO_Export TAO_UIOP_Endpoint_Info +{ + +#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8) + typedef TAO_UIOP_Endpoint_Info_var _var_type; +#endif /* ! __GNUC__ || g++ >= 2.8 */ + + static void _tao_any_destructor (void*); + + TAO_String_Manager rendezvous_point; + CORBA::Short priority; +}; + +class TAO_Export TAO_UIOP_Endpoint_Info_var +{ +public: + TAO_UIOP_Endpoint_Info_var (void); // default constructor + TAO_UIOP_Endpoint_Info_var (TAO_UIOP_Endpoint_Info *); + TAO_UIOP_Endpoint_Info_var (const TAO_UIOP_Endpoint_Info_var &); // copy constructor + ~TAO_UIOP_Endpoint_Info_var (void); // destructor + + TAO_UIOP_Endpoint_Info_var &operator= (TAO_UIOP_Endpoint_Info *); + TAO_UIOP_Endpoint_Info_var &operator= (const TAO_UIOP_Endpoint_Info_var &); + TAO_UIOP_Endpoint_Info *operator-> (void); + const TAO_UIOP_Endpoint_Info *operator-> (void) const; + + operator const TAO_UIOP_Endpoint_Info &() const; + operator TAO_UIOP_Endpoint_Info &(); + operator TAO_UIOP_Endpoint_Info &() const; + operator TAO_UIOP_Endpoint_Info *&(); // variable-size types only + + // in, inout, out, _retn + const TAO_UIOP_Endpoint_Info &in (void) const; + TAO_UIOP_Endpoint_Info &inout (void); + TAO_UIOP_Endpoint_Info *&out (void); + TAO_UIOP_Endpoint_Info *_retn (void); + TAO_UIOP_Endpoint_Info *ptr (void) const; + +private: + TAO_UIOP_Endpoint_Info *ptr_; +}; + +class TAO_Export TAO_UIOP_Endpoint_Info_out +{ +public: + TAO_UIOP_Endpoint_Info_out (TAO_UIOP_Endpoint_Info *&); + TAO_UIOP_Endpoint_Info_out (TAO_UIOP_Endpoint_Info_var &); + TAO_UIOP_Endpoint_Info_out (const TAO_UIOP_Endpoint_Info_out &); + TAO_UIOP_Endpoint_Info_out &operator= (const TAO_UIOP_Endpoint_Info_out &); + TAO_UIOP_Endpoint_Info_out &operator= (TAO_UIOP_Endpoint_Info *); + operator TAO_UIOP_Endpoint_Info *&(); + TAO_UIOP_Endpoint_Info *&ptr (void); + TAO_UIOP_Endpoint_Info *operator-> (void); + +private: + TAO_UIOP_Endpoint_Info *&ptr_; + // assignment from T_var not allowed + void operator= (const TAO_UIOP_Endpoint_Info_var &); +}; + +extern TAO_Export CORBA::TypeCode_ptr _tc_TAO_UIOP_Endpoint_Info; + + +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + +#if !defined (__TAO_UNBOUNDED_SEQUENCE_TAO_UIOPENDPOINTSEQUENCE_CH_) +#define __TAO_UNBOUNDED_SEQUENCE_TAO_UIOPENDPOINTSEQUENCE_CH_ + + class TAO_EXPORT_NESTED_MACRO _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence : public TAO_Unbounded_Base_Sequence + { + public: + // = Initialization and termination methods. + + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (void); // Default constructor. + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (CORBA::ULong maximum); + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (CORBA::ULong maximum, + CORBA::ULong length, + TAO_UIOP_Endpoint_Info *data, + CORBA::Boolean release = 0); + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (const _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence &rhs); + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence &operator= (const _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence &rhs); + virtual ~_TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (void); // Dtor. + // = Accessors. + TAO_UIOP_Endpoint_Info &operator[] (CORBA::ULong i); + const TAO_UIOP_Endpoint_Info &operator[] (CORBA::ULong i) const; + // = Static operations. + static TAO_UIOP_Endpoint_Info *allocbuf (CORBA::ULong size); + static void freebuf (TAO_UIOP_Endpoint_Info *buffer); + virtual void _allocate_buffer (CORBA::ULong length); + virtual void _deallocate_buffer (void); + // Implement the TAO_Base_Sequence methods (see Sequence.h) + + TAO_UIOP_Endpoint_Info *get_buffer (CORBA::Boolean orphan = 0); + const TAO_UIOP_Endpoint_Info *get_buffer (void) const; + void replace (CORBA::ULong max, + CORBA::ULong length, + TAO_UIOP_Endpoint_Info *data, + CORBA::Boolean release); + }; + +#endif /* end #if !defined */ + + +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + +#if !defined (_TAO_UIOPENDPOINTSEQUENCE_CH_) +#define _TAO_UIOPENDPOINTSEQUENCE_CH_ + +class TAO_UIOPEndpointSequence; +class TAO_UIOPEndpointSequence_var; + +// ************************************************************* +// TAO_UIOPEndpointSequence +// ************************************************************* + +class TAO_Export TAO_UIOPEndpointSequence : public +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence +#else /* TAO_USE_SEQUENCE_TEMPLATES */ + TAO_Unbounded_Sequence<TAO_UIOP_Endpoint_Info> +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ +{ +public: + TAO_UIOPEndpointSequence (void); // default ctor + TAO_UIOPEndpointSequence (CORBA::ULong max); // uses max size + TAO_UIOPEndpointSequence ( + CORBA::ULong max, + CORBA::ULong length, + TAO_UIOP_Endpoint_Info *buffer, + CORBA::Boolean release=0 + ); + TAO_UIOPEndpointSequence (const TAO_UIOPEndpointSequence &); // copy ctor + ~TAO_UIOPEndpointSequence (void); + static void _tao_any_destructor (void*); + +#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8) + typedef TAO_UIOPEndpointSequence_var _var_type; +#endif /* ! __GNUC__ || g++ >= 2.8 */ + +}; + +#endif /* end #if !defined */ + + +#if !defined (_TAO_UIOPENDPOINTSEQUENCE___VAR_CH_) +#define _TAO_UIOPENDPOINTSEQUENCE___VAR_CH_ + +// ************************************************************* +// class TAO_UIOPEndpointSequence_var +// ************************************************************* + +class TAO_Export TAO_UIOPEndpointSequence_var +{ +public: + TAO_UIOPEndpointSequence_var (void); // default constructor + TAO_UIOPEndpointSequence_var (TAO_UIOPEndpointSequence *); + TAO_UIOPEndpointSequence_var (const TAO_UIOPEndpointSequence_var &); // copy constructor + ~TAO_UIOPEndpointSequence_var (void); // destructor + + TAO_UIOPEndpointSequence_var &operator= (TAO_UIOPEndpointSequence *); + TAO_UIOPEndpointSequence_var &operator= (const TAO_UIOPEndpointSequence_var &); + TAO_UIOPEndpointSequence *operator-> (void); + const TAO_UIOPEndpointSequence *operator-> (void) const; + + operator const TAO_UIOPEndpointSequence &() const; + operator TAO_UIOPEndpointSequence &(); + operator TAO_UIOPEndpointSequence &() const; + operator TAO_UIOPEndpointSequence *&(); // variable-size base types only + + TAO_UIOP_Endpoint_Info &operator[] (CORBA::ULong index); + // in, inout, out, _retn + const TAO_UIOPEndpointSequence &in (void) const; + TAO_UIOPEndpointSequence &inout (void); + TAO_UIOPEndpointSequence *&out (void); + TAO_UIOPEndpointSequence *_retn (void); + TAO_UIOPEndpointSequence *ptr (void) const; + +private: + TAO_UIOPEndpointSequence *ptr_; +}; + + +#endif /* end #if !defined */ + + +#if !defined (_TAO_UIOPENDPOINTSEQUENCE___OUT_CH_) +#define _TAO_UIOPENDPOINTSEQUENCE___OUT_CH_ + +class TAO_Export TAO_UIOPEndpointSequence_out +{ +public: + TAO_UIOPEndpointSequence_out (TAO_UIOPEndpointSequence *&); + TAO_UIOPEndpointSequence_out (TAO_UIOPEndpointSequence_var &); + TAO_UIOPEndpointSequence_out (const TAO_UIOPEndpointSequence_out &); + TAO_UIOPEndpointSequence_out &operator= (const TAO_UIOPEndpointSequence_out &); + TAO_UIOPEndpointSequence_out &operator= (TAO_UIOPEndpointSequence *); + operator TAO_UIOPEndpointSequence *&(); + TAO_UIOPEndpointSequence *&ptr (void); + TAO_UIOPEndpointSequence *operator-> (void); + TAO_UIOP_Endpoint_Info &operator[] (CORBA::ULong index); + +private: + TAO_UIOPEndpointSequence *&ptr_; + // assignment from T_var not allowed + void operator= (const TAO_UIOPEndpointSequence_var &); +}; + + +#endif /* end #if !defined */ + +extern TAO_Export CORBA::TypeCode_ptr _tc_TAO_UIOPEndpointSequence; + +TAO_Export void operator<<= (CORBA::Any &, const TAO_UIOP_Endpoint_Info &); // copying version +TAO_Export void operator<<= (CORBA::Any &, TAO_UIOP_Endpoint_Info*); // noncopying version +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, TAO_UIOP_Endpoint_Info *&); // deprecated +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const TAO_UIOP_Endpoint_Info *&); +TAO_Export void operator<<= (CORBA::Any &, const TAO_UIOPEndpointSequence &); // copying version +TAO_Export void operator<<= (CORBA::Any &, TAO_UIOPEndpointSequence*); // noncopying version +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, TAO_UIOPEndpointSequence *&); // deprecated +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const TAO_UIOPEndpointSequence *&); + +#ifndef __ACE_INLINE__ + +TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &, const TAO_UIOP_Endpoint_Info &); +TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &, TAO_UIOP_Endpoint_Info &); + +#if !defined _TAO_CDR_OP_TAO_UIOPEndpointSequence_H_ +#define _TAO_CDR_OP_TAO_UIOPEndpointSequence_H_ + +TAO_Export CORBA::Boolean operator<< ( + TAO_OutputCDR &, + const TAO_UIOPEndpointSequence & + ); +TAO_Export CORBA::Boolean operator>> ( + TAO_InputCDR &, + TAO_UIOPEndpointSequence & + ); + +#endif /* _TAO_CDR_OP_TAO_UIOPEndpointSequence_H_ */ + + +#endif /* __ACE_INLINE__ */ + + +#if defined (__ACE_INLINE__) +#include "uiop_endpoints.i" +#endif /* defined INLINE */ + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /* ifndef */ diff --git a/TAO/tao/uiop_endpoints.i b/TAO/tao/uiop_endpoints.i new file mode 100644 index 00000000000..8d2582ba556 --- /dev/null +++ b/TAO/tao/uiop_endpoints.i @@ -0,0 +1,596 @@ +/* -*- C++ -*- $Id$ */ +// $Id$ +// +// ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* +// TAO and the TAO IDL Compiler have been developed by the Center for +// Distributed Object Computing at Washington University, St. Louis. +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// ************************************************************* +// Inline operations for class TAO_UIOP_Endpoint_Info_var +// ************************************************************* + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::TAO_UIOP_Endpoint_Info_var (void) // default constructor + : ptr_ (0) +{} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::TAO_UIOP_Endpoint_Info_var (TAO_UIOP_Endpoint_Info *p) + : ptr_ (p) +{} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::TAO_UIOP_Endpoint_Info_var (const ::TAO_UIOP_Endpoint_Info_var &p) // copy constructor +{ + if (p.ptr_) + ACE_NEW (this->ptr_, ::TAO_UIOP_Endpoint_Info (*p.ptr_)); + else + this->ptr_ = 0; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::~TAO_UIOP_Endpoint_Info_var (void) // destructor +{ + delete this->ptr_; +} + +ACE_INLINE TAO_UIOP_Endpoint_Info_var & +TAO_UIOP_Endpoint_Info_var::operator= (TAO_UIOP_Endpoint_Info *p) +{ + delete this->ptr_; + this->ptr_ = p; + return *this; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info_var & +TAO_UIOP_Endpoint_Info_var::operator= (const ::TAO_UIOP_Endpoint_Info_var &p) +{ + if (this != &p) + { + delete this->ptr_; + ACE_NEW_RETURN (this->ptr_, ::TAO_UIOP_Endpoint_Info (*p.ptr_), *this); + } + return *this; +} + +ACE_INLINE const ::TAO_UIOP_Endpoint_Info * +TAO_UIOP_Endpoint_Info_var::operator-> (void) const +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info * +TAO_UIOP_Endpoint_Info_var::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::operator const ::TAO_UIOP_Endpoint_Info &() const // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::operator ::TAO_UIOP_Endpoint_Info &() // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::operator ::TAO_UIOP_Endpoint_Info &() const // cast +{ + return *this->ptr_; +} + +// variable-size types only +ACE_INLINE +TAO_UIOP_Endpoint_Info_var::operator ::TAO_UIOP_Endpoint_Info *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE const ::TAO_UIOP_Endpoint_Info & +TAO_UIOP_Endpoint_Info_var::in (void) const +{ + return *this->ptr_; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info & +TAO_UIOP_Endpoint_Info_var::inout (void) +{ + return *this->ptr_; +} + +// mapping for variable size +ACE_INLINE ::TAO_UIOP_Endpoint_Info *& +TAO_UIOP_Endpoint_Info_var::out (void) +{ + delete this->ptr_; + this->ptr_ = 0; + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info * +TAO_UIOP_Endpoint_Info_var::_retn (void) +{ + ::TAO_UIOP_Endpoint_Info *tmp = this->ptr_; + this->ptr_ = 0; + return tmp; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info * +TAO_UIOP_Endpoint_Info_var::ptr (void) const +{ + return this->ptr_; +} + +// ************************************************************* +// Inline operations for class TAO_UIOP_Endpoint_Info_out +// ************************************************************* + +ACE_INLINE +TAO_UIOP_Endpoint_Info_out::TAO_UIOP_Endpoint_Info_out (::TAO_UIOP_Endpoint_Info *&p) + : ptr_ (p) +{ + this->ptr_ = 0; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_out::TAO_UIOP_Endpoint_Info_out (TAO_UIOP_Endpoint_Info_var &p) // constructor from _var + : ptr_ (p.out ()) +{ + delete this->ptr_; + this->ptr_ = 0; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_out::TAO_UIOP_Endpoint_Info_out (const ::TAO_UIOP_Endpoint_Info_out &p) // copy constructor + : ptr_ (ACE_const_cast (TAO_UIOP_Endpoint_Info_out&, p).ptr_) +{} + +ACE_INLINE TAO_UIOP_Endpoint_Info_out & +TAO_UIOP_Endpoint_Info_out::operator= (const ::TAO_UIOP_Endpoint_Info_out &p) +{ + this->ptr_ = ACE_const_cast (TAO_UIOP_Endpoint_Info_out&, p).ptr_; + return *this; +} + +ACE_INLINE TAO_UIOP_Endpoint_Info_out & +TAO_UIOP_Endpoint_Info_out::operator= (TAO_UIOP_Endpoint_Info *p) +{ + this->ptr_ = p; + return *this; +} + +ACE_INLINE +TAO_UIOP_Endpoint_Info_out::operator ::TAO_UIOP_Endpoint_Info *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info *& +TAO_UIOP_Endpoint_Info_out::ptr (void) // ptr +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOP_Endpoint_Info * +TAO_UIOP_Endpoint_Info_out::operator-> (void) +{ + return this->ptr_; +} + + +#if !defined (TAO_USE_SEQUENCE_TEMPLATES) + +#if !defined (__TAO_UNBOUNDED_SEQUENCE_TAO_UIOPENDPOINTSEQUENCE_CI_) +#define __TAO_UNBOUNDED_SEQUENCE_TAO_UIOPENDPOINTSEQUENCE_CI_ + + // = Static operations. + ACE_INLINE TAO_UIOP_Endpoint_Info * + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (CORBA::ULong size) + // Allocate storage for the sequence. + { + TAO_UIOP_Endpoint_Info *retval = 0; + ACE_NEW_RETURN (retval, TAO_UIOP_Endpoint_Info[size], 0); + return retval; + } + + ACE_INLINE void _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::freebuf (TAO_UIOP_Endpoint_Info *buffer) + // Free the sequence. + { + delete [] buffer; + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (void) // Default constructor. + { + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (CORBA::ULong maximum) // Constructor using a maximum length value. + : TAO_Unbounded_Base_Sequence (maximum, _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (maximum)) + { + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (CORBA::ULong maximum, + CORBA::ULong length, + TAO_UIOP_Endpoint_Info *data, + CORBA::Boolean release) + : TAO_Unbounded_Base_Sequence (maximum, length, data, release) + { + } + + ACE_INLINE + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::_TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence (const _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence &rhs) + // Copy constructor. + : TAO_Unbounded_Base_Sequence (rhs) + { + if (rhs.buffer_ != 0) + { + TAO_UIOP_Endpoint_Info *tmp1 = _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (this->maximum_); + TAO_UIOP_Endpoint_Info * const tmp2 = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info * ACE_CAST_CONST, rhs.buffer_); + + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp1[i] = tmp2[i]; + + this->buffer_ = tmp1; + } + else + { + this->buffer_ = 0; + } + } + + ACE_INLINE _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence & + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::operator= (const _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence &rhs) + // Assignment operator. + { + if (this == &rhs) + return *this; + + if (this->release_) + { + if (this->maximum_ < rhs.maximum_) + { + // free the old buffer + TAO_UIOP_Endpoint_Info *tmp = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info *, this->buffer_); + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::freebuf (tmp); + this->buffer_ = _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (rhs.maximum_); + } + } + else + this->buffer_ = _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (rhs.maximum_); + + TAO_Unbounded_Base_Sequence::operator= (rhs); + + TAO_UIOP_Endpoint_Info *tmp1 = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info *, this->buffer_); + TAO_UIOP_Endpoint_Info * const tmp2 = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info * ACE_CAST_CONST, rhs.buffer_); + + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp1[i] = tmp2[i]; + + return *this; + } + + // = Accessors. + ACE_INLINE TAO_UIOP_Endpoint_Info & + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::operator[] (CORBA::ULong i) + // operator [] + { + ACE_ASSERT (i < this->maximum_); + TAO_UIOP_Endpoint_Info* tmp = ACE_reinterpret_cast(TAO_UIOP_Endpoint_Info*,this->buffer_); + return tmp[i]; + } + + ACE_INLINE const TAO_UIOP_Endpoint_Info & + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::operator[] (CORBA::ULong i) const + // operator [] + { + ACE_ASSERT (i < this->maximum_); + TAO_UIOP_Endpoint_Info * const tmp = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info* ACE_CAST_CONST, this->buffer_); + return tmp[i]; + } + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + + ACE_INLINE TAO_UIOP_Endpoint_Info * + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::get_buffer (CORBA::Boolean orphan) + { + TAO_UIOP_Endpoint_Info *result = 0; + if (orphan == 0) + { + // We retain ownership. + if (this->buffer_ == 0) + { + result = _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::allocbuf (this->length_); + this->buffer_ = result; + this->release_ = 1; + } + else + { + result = ACE_reinterpret_cast (TAO_UIOP_Endpoint_Info*, this->buffer_); + } + } + else // if (orphan == 1) + { + if (this->release_ != 0) + { + // We set the state back to default and relinquish + // ownership. + result = ACE_reinterpret_cast(TAO_UIOP_Endpoint_Info*,this->buffer_); + this->maximum_ = 0; + this->length_ = 0; + this->buffer_ = 0; + this->release_ = 0; + } + } + return result; + } + + ACE_INLINE const TAO_UIOP_Endpoint_Info * + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::get_buffer (void) const + { + return ACE_reinterpret_cast(const TAO_UIOP_Endpoint_Info * ACE_CAST_CONST, this->buffer_); + } + + ACE_INLINE void + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::replace (CORBA::ULong max, + CORBA::ULong length, + TAO_UIOP_Endpoint_Info *data, + CORBA::Boolean release) + { + this->maximum_ = max; + this->length_ = length; + if (this->buffer_ && this->release_ == 1) + { + TAO_UIOP_Endpoint_Info *tmp = ACE_reinterpret_cast(TAO_UIOP_Endpoint_Info*,this->buffer_); + _TAO_Unbounded_Sequence_TAO_UIOPEndpointSequence::freebuf (tmp); + } + this->buffer_ = data; + this->release_ = release; + } + +#endif /* end #if !defined */ + + +#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ + +#if !defined (_TAO_UIOPENDPOINTSEQUENCE_CI_) +#define _TAO_UIOPENDPOINTSEQUENCE_CI_ + +// ************************************************************* +// Inline operations for class TAO_UIOPEndpointSequence_var +// ************************************************************* + +ACE_INLINE +TAO_UIOPEndpointSequence_var::TAO_UIOPEndpointSequence_var (void) // default constructor + : ptr_ (0) +{} + +ACE_INLINE +TAO_UIOPEndpointSequence_var::TAO_UIOPEndpointSequence_var (TAO_UIOPEndpointSequence *p) + : ptr_ (p) +{} + +ACE_INLINE +TAO_UIOPEndpointSequence_var::TAO_UIOPEndpointSequence_var (const ::TAO_UIOPEndpointSequence_var &p) // copy constructor +{ + if (p.ptr_) + ACE_NEW (this->ptr_, ::TAO_UIOPEndpointSequence (*p.ptr_)); + else + this->ptr_ = 0; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_var::~TAO_UIOPEndpointSequence_var (void) // destructor +{ + delete this->ptr_; +} + +ACE_INLINE TAO_UIOPEndpointSequence_var & +TAO_UIOPEndpointSequence_var::operator= (TAO_UIOPEndpointSequence *p) +{ + delete this->ptr_; + this->ptr_ = p; + return *this; +} + +ACE_INLINE TAO_UIOPEndpointSequence_var & +TAO_UIOPEndpointSequence_var::operator= (const ::TAO_UIOPEndpointSequence_var &p) // deep copy +{ + if (this != &p) + { + delete this->ptr_; + ACE_NEW_RETURN (this->ptr_, ::TAO_UIOPEndpointSequence (*p.ptr_), *this); + } + return *this; +} + +ACE_INLINE const ::TAO_UIOPEndpointSequence * +TAO_UIOPEndpointSequence_var::operator-> (void) const +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence * +TAO_UIOPEndpointSequence_var::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_var::operator const ::TAO_UIOPEndpointSequence &() const // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_var::operator ::TAO_UIOPEndpointSequence &() // cast +{ + return *this->ptr_; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_var::operator ::TAO_UIOPEndpointSequence &() const // cast +{ + return *this->ptr_; +} + +// variable-size types only +ACE_INLINE +TAO_UIOPEndpointSequence_var::operator ::TAO_UIOPEndpointSequence *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE TAO_UIOP_Endpoint_Info & +TAO_UIOPEndpointSequence_var::operator[] (CORBA::ULong index) +{ + return this->ptr_->operator[] (index); +} + +ACE_INLINE const ::TAO_UIOPEndpointSequence & +TAO_UIOPEndpointSequence_var::in (void) const +{ + return *this->ptr_; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence & +TAO_UIOPEndpointSequence_var::inout (void) +{ + return *this->ptr_; +} + +// mapping for variable size +ACE_INLINE ::TAO_UIOPEndpointSequence *& +TAO_UIOPEndpointSequence_var::out (void) +{ + delete this->ptr_; + this->ptr_ = 0; + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence * +TAO_UIOPEndpointSequence_var::_retn (void) +{ + ::TAO_UIOPEndpointSequence *tmp = this->ptr_; + this->ptr_ = 0; + return tmp; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence * +TAO_UIOPEndpointSequence_var::ptr (void) const +{ + return this->ptr_; +} + +// ************************************************************* +// Inline operations for class TAO_UIOPEndpointSequence_out +// ************************************************************* + +ACE_INLINE +TAO_UIOPEndpointSequence_out::TAO_UIOPEndpointSequence_out (TAO_UIOPEndpointSequence *&p) + : ptr_ (p) +{ + this->ptr_ = 0; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_out::TAO_UIOPEndpointSequence_out (TAO_UIOPEndpointSequence_var &p) // constructor from _var + : ptr_ (p.out ()) +{ + delete this->ptr_; + this->ptr_ = 0; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_out::TAO_UIOPEndpointSequence_out (const ::TAO_UIOPEndpointSequence_out &p) // copy constructor + : ptr_ (ACE_const_cast (TAO_UIOPEndpointSequence_out&, p).ptr_) +{} + +ACE_INLINE ::TAO_UIOPEndpointSequence_out & +TAO_UIOPEndpointSequence_out::operator= (const ::TAO_UIOPEndpointSequence_out &p) +{ + this->ptr_ = ACE_const_cast (TAO_UIOPEndpointSequence_out&, p).ptr_; + return *this; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence_out & +TAO_UIOPEndpointSequence_out::operator= (TAO_UIOPEndpointSequence *p) +{ + this->ptr_ = p; + return *this; +} + +ACE_INLINE +TAO_UIOPEndpointSequence_out::operator ::TAO_UIOPEndpointSequence *&() // cast +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence *& +TAO_UIOPEndpointSequence_out::ptr (void) // ptr +{ + return this->ptr_; +} + +ACE_INLINE ::TAO_UIOPEndpointSequence * +TAO_UIOPEndpointSequence_out::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE TAO_UIOP_Endpoint_Info & +TAO_UIOPEndpointSequence_out::operator[] (CORBA::ULong index) +{ + return this->ptr_->operator[] (index); +} + + +#endif /* end #if !defined */ + +ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &strm, const TAO_UIOP_Endpoint_Info &_tao_aggregate) +{ + if ( + (strm << _tao_aggregate.rendezvous_point.in ()) && + (strm << _tao_aggregate.priority) + ) + return 1; + else + return 0; + +} + +ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, TAO_UIOP_Endpoint_Info &_tao_aggregate) +{ + if ( + (strm >> _tao_aggregate.rendezvous_point.out ()) && + (strm >> _tao_aggregate.priority) + ) + return 1; + else + return 0; + +} + + +#if !defined _TAO_CDR_OP_TAO_UIOPEndpointSequence_I_ +#define _TAO_CDR_OP_TAO_UIOPEndpointSequence_I_ + +CORBA::Boolean TAO_Export operator<< ( + TAO_OutputCDR &, + const TAO_UIOPEndpointSequence & + ); +CORBA::Boolean TAO_Export operator>> ( + TAO_InputCDR &, + TAO_UIOPEndpointSequence & + ); + +#endif /* _TAO_CDR_OP_TAO_UIOPEndpointSequence_I_ */ + diff --git a/TAO/tao/uiop_endpoints.pidl b/TAO/tao/uiop_endpoints.pidl new file mode 100644 index 00000000000..73eb8e6b167 --- /dev/null +++ b/TAO/tao/uiop_endpoints.pidl @@ -0,0 +1,29 @@ +// $Id$ +// +// This file was used to generate the code in +// iiop_endpoints.* The command used to generate code +// is: +// +// tao_idl +// -Wb,export_macro=TAO_Export \ +// -Wb,export_include="tao/corbafwd.h" \ +// -Wb,pre_include="ace/pre.h" \ +// -Wb,post_include="ace/post.h" \ +// uiop_endpoints.pidl +// + +#ifndef _UIOP_ENDPOINTS_IDL_ +#define _UIOP_ENDPOINTS_IDL_ + +// Endpoint information that goes on the wire. +struct TAO_UIOP_Endpoint_Info +{ + string rendezvous_point; + short priority; +}; + +typedef sequence <TAO_UIOP_Endpoint_Info> TAO_UIOPEndpointSequence; + +#pragma prefix "" + +#endif /* _UIOP_ENDPOINTS_IDL_ */ |