Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / IIOP_Profile.h
bloba619734ccb8c8350e001370f2202df8e180f819b
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file IIOP_Profile.h
7 * IIOP profile specific processing.
9 * @author Fred Kuhns <fredk@cs.wustl.edu>
11 //=============================================================================
14 #ifndef TAO_IIOP_PROFILE_H
15 #define TAO_IIOP_PROFILE_H
17 #include /**/ "ace/pre.h"
19 #include "tao/orbconf.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
27 #include "tao/Profile.h"
28 #include "tao/IIOP_Endpoint.h"
30 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
32 // TAO IIOP_Profile concrete Profile definitions
33 /**
34 * @class TAO_IIOP_Profile
36 * @brief This class defines the protocol specific attributes required
37 * for locating ORBs over a TCP/IP network.
39 * This class defines the IIOP profile as specified in the CORBA
40 * specification.
42 class TAO_Export TAO_IIOP_Profile : public TAO_Profile
44 public:
45 static const char object_key_delimiter_;
47 /// Return the char string prefix.
48 static const char *prefix ();
50 /// Profile constructor, same as above except the object_key has
51 /// already been marshaled.
52 TAO_IIOP_Profile (const ACE_INET_Addr &addr,
53 const TAO::ObjectKey &object_key,
54 const TAO_GIOP_Message_Version &version,
55 TAO_ORB_Core *orb_core);
57 /// Profile constructor, this is the most efficient since it
58 /// doesn't require any address resolution processing.
59 TAO_IIOP_Profile (const char *host,
60 CORBA::UShort port,
61 const TAO::ObjectKey &object_key,
62 const ACE_INET_Addr &addr,
63 const TAO_GIOP_Message_Version &version,
64 TAO_ORB_Core *orb_core);
66 /// Profile constructor, default.
67 TAO_IIOP_Profile (TAO_ORB_Core *orb_core);
69 /**
70 * Add @a endp to this profile's list of endpoints (it is inserted
71 * at the end of the list). This profiles takes ownership of
72 * @a endp.
74 void add_endpoint (TAO_IIOP_Endpoint *endp);
76 /**
77 * Remove @a endp from this profile's list of endpoints and free the
78 * @a endp memory.
79 * This method assumes @a endp is in this profile's endpoint list.
81 void remove_endpoint (TAO_IIOP_Endpoint *endp);
83 virtual void remove_generic_endpoint (TAO_Endpoint *ep);
85 /// Add an endpoint when the specific endpoint type is unknown
86 virtual void add_generic_endpoint (TAO_Endpoint *ep);
88 /// The object key delimiter that IIOP uses or expects.
89 virtual char object_key_delimiter () const;
91 /// Template methods. Please see Profile.h for documentation.
92 virtual char * to_string () const;
94 /// Encode endpoints for RT profiles, using a single TAO_TAG_ENDPOINT
95 /// component.
96 virtual int encode_endpoints ();
98 /// Encode alternate endpoints for non-RT profiles, using multiple
99 /// TAG_ALTERNATE_IIOP_ADDRESS components, one endpoint per component
100 virtual int encode_alternate_endpoints ();
101 virtual TAO_Endpoint *endpoint ();
103 /// Since SSLIOP_Profile derives from IIOP_Profile, but SSLIOP_Endpoint
104 /// does not derive from IIOP_Endpoint, it is necessary to have a way
105 /// of always getting the IIOP_Endpoint using a generic interface
106 /// regardless of the final type of the profile.
107 virtual TAO_Endpoint *base_endpoint ();
109 virtual CORBA::ULong endpoint_count () const;
110 virtual CORBA::ULong hash (CORBA::ULong max);
112 protected:
113 /// Destructor is to be called only through <_decr_refcnt>.
114 ~TAO_IIOP_Profile ();
117 * Helper method for encode_endpoints to deal with RT requests.
119 * Encodes this profile's endpoints into a tagged component.
120 * This is done only if RTCORBA is enabled, since currently this is
121 * the only case when we have more than one endpoint per profile.
122 * Returns 0 on success and -1 on failure.
124 * Endpoints are transmitted using TAO-proprietory tagged component.
125 * Component tag is TAO_TAG_ENDPOINTS and component data is an
126 * encapsulation of a sequence of structs, each representing a
127 * single endpoint. Data format is specified in iiop_endpoins.pidl.
129 int encode_endpoints_for_rt ();
131 /// Template methods. Please see Profile.h for the documentation.
132 virtual int decode_profile (TAO_InputCDR &cdr);
133 virtual int decode_endpoints ();
134 virtual void parse_string_i (const char *string);
135 virtual void create_profile_body (TAO_OutputCDR &cdr) const;
136 virtual CORBA::Boolean do_is_equivalent (const TAO_Profile *other_profile);
138 protected:
140 * Head of this profile's list of endpoints. This endpoint is not
141 * dynamically allocated because a profile always contains at least
142 * one endpoint.
144 * Currently, a profile contains more than one endpoint, i.e.,
145 * list contains more than just the head, only for two cases
146 * (1) when RTCORBA is enabled and
147 * (2) the ORB is initialized with -ORBPreferredInterfaces option.
148 * However, in the near future, this will be used in for mode as
149 * well, e.g., to support TAG_ALTERNATE_IIOP_ADDRESS feature.
151 * This is probably as good a place to discuss how the list of
152 * endpoints is used for #2. If the ORB is configured to use
153 * preferred interfaces for invocation, TAO creates an endpoint per
154 * preferred interface. To be clear, every tuple
155 * <destination:target> will have an endpoint. What TAO essentially
156 * does is that creates it multiple endpoints so that the invocation
157 * code path can use existing iterating techniques to try one
158 * preferred interface after another (if the first did not work). If
159 * the ORB is configured with -ORBEnforcePreferredInterface set to
160 * false in addition to the ORBPreferredInterfaces option , TAO
161 * creates another endpoint with the preferred bit set to null, so
162 * that the invocation code can fall back to a TCP stack returned
163 * local address.
164 * Addressing info of the default endpoint, i.e., head of the list,
165 * is transmitted using standard IIOP ProfileBody components. See
166 * <encode_endpoints> method documentation above for how the rest of
167 * the endpoint list is transmitted.
169 TAO_IIOP_Endpoint endpoint_;
171 /// For efficient insertion at the end of the list
172 TAO_IIOP_Endpoint *last_endpoint_;
174 /// Number of endpoints in the list headed by <endpoint_>.
175 CORBA::ULong count_;
178 TAO_END_VERSIONED_NAMESPACE_DECL
180 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */
182 #include /**/ "ace/post.h"
184 #endif /* TAO_IIOP_PROFILE_H */