3
//=============================================================================
7
* Profile.h,v 1.51 2003/10/28 18:29:19 bala Exp
9
* @author Fred Kuhns <fredk@cs.wustl.edu>
11
//=============================================================================
16
#include /**/ "ace/pre.h"
18
#include "tao/Tagged_Components.h"
20
#if !defined (ACE_LACKS_PRAGMA_ONCE)
22
#endif /* ACE_LACKS_PRAGMA_ONCE */
24
#include "tao/GIOP_Message_Version.h"
25
#include "tao/Refcounted_ObjectKey.h"
35
/// Forward declaration of PolicyList
39
typedef TypeCode *TypeCode_ptr;
45
* @brief Defines the Profile interface
47
* An abstract base class for representing object location
48
* information. This is based on the CORBA IOR definitions.
50
class TAO_Export TAO_Profile
55
TAO_Profile (CORBA::ULong tag,
56
TAO_ORB_Core *orb_core,
57
const TAO_GIOP_Message_Version &version);
59
/// If you have a virtual method you need a virtual dtor.
60
virtual ~TAO_Profile (void);
63
* @name Non virtual methods for the profile classes.
67
/// The tag, each concrete class will have a specific tag value.
68
CORBA::ULong tag (void) const;
70
/// Return a pointer to this profile's version. This object
71
/// maintains ownership.
72
const TAO_GIOP_Message_Version &version (void) const;
74
/// Get a pointer to the TAO_ORB_Core.
75
TAO_ORB_Core *orb_core (void) const;
77
/// Increase the reference count by one on this object.
78
CORBA::ULong _incr_refcnt (void);
80
/// Decrement the object's reference count. When this count goes to
81
/// 0 this object will be deleted.
82
CORBA::ULong _decr_refcnt (void);
84
/// Keep a pointer to the forwarded profile
85
void forward_to (TAO_MProfile *mprofiles);
88
TAO_MProfile* forward_to (void);
90
/// Access the tagged components, notice that they they could be
91
/// empty (or ignored) for non-GIOP protocols (and even for GIOP-1.0)
92
const TAO_Tagged_Components& tagged_components (void) const;
93
TAO_Tagged_Components& tagged_components (void);
95
/// Add the given tagged component to the profile.
96
void add_tagged_component (const IOP::TaggedComponent &component
100
* Return the current addressing mode for this profile.
101
* In almost all cases, this is TAO_Target_Specification::Key_Addr.
103
CORBA::Short addressing_mode (void) const;
105
/// @@ deprecated. return a reference to the Object Key.
106
const TAO::ObjectKey &object_key (void) const;
108
/// Obtain the object key, return 0 if the profile cannot be parsed.
109
/// The memory is owned by the caller!
110
TAO::ObjectKey *_key (void) const;
115
* @name Template methods that needs to be implemented by the
116
* concrete classes. Some of the methods may be overridden only
117
* under specila circumstances.
120
/// Encode this profile in a stream, i.e. marshal it.
121
virtual int encode (TAO_OutputCDR &stream) const;
123
/// Initialize this object using the given CDR octet string.
124
virtual int decode (TAO_InputCDR& cdr);
127
* This method is used to get the IOP::TaggedProfile. The profile
128
* information that is received from the server side would have
129
* already been decoded. So this method will just make a
130
* IOP::TaggedProfile struct from the existing information and
131
* return the reference to that. This method is necessary for GIOP
134
IOP::TaggedProfile *create_tagged_profile (void);
136
/// This method sets the client exposed policies, i.e., the ones
137
/// propagated in the IOR, for this profile.
138
virtual void policies (CORBA::PolicyList *policy_list
141
/// Accessor for the client exposed policies of this profile.
142
virtual CORBA::PolicyList& policies (ACE_ENV_SINGLE_ARG_DECL);
144
/// Sets the TAO_Stub to which this profile is associated.
145
virtual void the_stub (TAO_Stub *stub);
147
/// Gets the TAO_MProfile that holds the TAO_Profile instance.
148
virtual TAO_Stub* the_stub (void);
150
/// Returns true if this profile can specify multicast endpoints.
151
virtual int supports_multicast (void) const;
154
* Set the addressing mode if a remote servant replies with
155
* an addressing mode exception. If this profile doesn't
156
* support a particular addressing mode, this method needs to
157
* be overridden signal the appropriate error.
159
* ** RACE CONDITION NOTE **
161
* Currently, getting and setting the addressing mode is not
162
* protected by a mutex. Theoretically, this could cause a race
163
* condition if one thread sends a request, then gets an exception
164
* from the remote servant to change the addressing mode, and then
165
* another thread sends a different request to the same servant
166
* using the wrong addressing mode. The result of this is that
167
* we'll get another address change exception. (Annoying, but not
170
* In practice at the current time, the above theoretical case
171
* never happens since the target specification always uses the
172
* object key except for MIOP requests. Remote ORBs can't respond
173
* to MIOP requests even to send exceptions, so even in this case,
174
* the race condition can't happen.
176
* Therefore, for the time being, there is no lock to protect the
177
* addressing mode. Given that the addressing mode is checked in
178
* the critical path, this decision seems like a good thing.
180
virtual void addressing_mode (CORBA::Short addr_mode
185
/// The object key delimiter.
186
virtual char object_key_delimiter (void) const = 0;
188
/// Initialize this object using the given input string.
189
/// Supports URL style of object references
190
virtual void parse_string (const char *string
193
/// Return a string representation for this profile. Client must
194
/// deallocate memory. Only one endpoint is included into the
196
virtual char* to_string (ACE_ENV_SINGLE_ARG_DECL) = 0;
199
* Encodes this profile's endpoints into a tagged component.
200
* This is done only if RTCORBA is enabled, since currently this is
201
* the only case when we have more than one endpoint per profile.
203
virtual int encode_endpoints (void) = 0;
206
* Return pointer to this profile's endpoint. If the profile
207
* contains more than one endpoint, i.e., a list, the method returns
208
* the head of the list.
210
virtual TAO_Endpoint *endpoint (void) = 0;
212
/// Return how many endpoints this profile contains.
213
virtual CORBA::ULong endpoint_count (void) const = 0;
215
/// Verify profile equivalance.
217
* Two profiles are equivalent @e iff their tag, object_key, version
218
* and all endpoints are the same.
220
* @see do_is_equivalent_i()
221
* @see is_equivalent_hook()
223
* @return @c true if this profile is equivalent to @c other_profile.
225
CORBA::Boolean is_equivalent (const TAO_Profile* other_profile);
227
/// Return a hash value for this object.
228
virtual CORBA::ULong hash (CORBA::ULong max
229
ACE_ENV_ARG_DECL) = 0;
235
* @name Protected template methods.
238
/// Decode the protocol specific profile details.
239
virtual int decode_profile (TAO_InputCDR &cdr) = 0;
241
/// Creates an encapsulation of the ProfileBody struct in the <cdr>
242
virtual void create_profile_body (TAO_OutputCDR &cdr) const = 0;
245
* Helper for <decode>. Decodes endpoints from a tagged component.
246
* Decode only if RTCORBA is enabled. Furthermore, we may not find
247
* TAO_TAG_ENDPOINTS component, e.g., if we are talking to nonRT
248
* version of TAO or some other ORB. This is not an error, and we
249
* must proceed. Return 0 on success and -1 on failure.
251
virtual int decode_endpoints (void) = 0;
253
/// Protocol specific implementation of parse_string ()
254
virtual void parse_string_i (const char *string
255
ACE_ENV_ARG_DECL) = 0;
258
/// To be used by inherited classes
259
TAO_Profile (CORBA::ULong tag,
260
TAO_ORB_Core *orb_core,
261
const TAO::ObjectKey &key,
262
const TAO_GIOP_Message_Version &version);
264
/// Helper method that encodes the endpoints for RTCORBA as
265
/// tagged_components.
266
void set_tagged_components (TAO_OutputCDR &cdr);
268
/// Profile equivalence template method invoked on subclasses.
270
* TAO_Profile subclasses must implement this template method so
271
* that they can apply their own definition of profile equivalence.
273
virtual CORBA::Boolean do_is_equivalent (const TAO_Profile * other) = 0;
275
/// Allow services to apply their own definition of "equivalence."
277
* This method differs from the @c do_is_equivalent() template
278
* method in that it has a default implementation that may or not be
279
* applicable to all TAO_Profile subclasses.
281
virtual CORBA::Boolean is_equivalent_hook (const TAO_Profile * other);
283
CORBA::ULong hash_service_i (CORBA::ULong m);
287
/// this object keeps ownership of this object
288
TAO_MProfile *forward_to_i (void);
290
/// Verify that the current ORB's configuration supports tagged
291
/// components in IORs.
292
void verify_orb_configuration (ACE_ENV_SINGLE_ARG_DECL);
294
/// Verify that the given profile supports tagged components,
295
/// i.e. is not a GIOP 1.0 profile.
296
void verify_profile_version (ACE_ENV_SINGLE_ARG_DECL);
298
// Profiles should not be copied!
299
ACE_UNIMPLEMENTED_FUNC (TAO_Profile (const TAO_Profile&))
300
ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Profile&))
304
/// IIOP version number.
305
TAO_GIOP_Message_Version version_;
307
/// The tagged components
308
TAO_Tagged_Components tagged_components_;
310
/// Flag indicating whether the lazy decoding of the client exposed
311
/// policies has taken place.
312
CORBA::Boolean are_policies_parsed_;
314
/// Pointer to the TAO_Stub to which this profile is related.
317
/// Client exposed policies of this profile.
318
CORBA::PolicyList *policy_list_;
320
// NOTE: In this implementation it is assumed that the <policy_list>
321
// is exactly the same for each profile.
322
// So to save memory, each TAO_Profile has a pointer to the same
323
// PolicyList object. The life cycle of this object is managed
324
// by the TAO_MProfile class.
326
/// The current addressing mode.
327
/// This may be changed if a remote server sends back an address mode
329
CORBA::Short addressing_mode_;
331
/// Our tagged profile
332
IOP::TaggedProfile *tagged_profile_;
334
/// object_key associated with this profile.
335
TAO::Refcounted_ObjectKey *ref_object_key_;
338
/// IOP protocol tag.
341
/// Pointer to the ORB core
342
TAO_ORB_Core *orb_core_;
344
/// the TAO_MProfile which contains the profiles for the forwarded
346
TAO_MProfile* forward_to_;
348
/// Mutex to protect reference count.
349
ACE_Lock *refcount_lock_;
351
/// Number of outstanding references to this object.
352
CORBA::ULong refcount_;
355
// A helper class to handle the various kinds of octet sequences used
358
typedef TAO_Unbounded_Sequence<CORBA::Octet> TAO_opaque;
360
TAO_Export CORBA::Boolean
361
operator<< (TAO_OutputCDR&, const TAO_opaque&);
363
TAO_Export CORBA::Boolean
364
operator>> (TAO_InputCDR&, TAO_opaque&);
367
* @class TAO_Unknown_Profile
369
* @brief A TAO_Profile class to handle foreign profiles.
371
* The CORBA spec implies that ORBs must be prepared to save and
372
* pass around profiles for protocols it does not recognize. It is
373
* not mandatory to *use* those profiles but they shouldn't be
375
* This class stores the information required to marshal and
376
* demarshal an unknown profile, but simply returns an error if
377
* any of the TAO internal methods are invoked.
379
class TAO_Export TAO_Unknown_Profile : public TAO_Profile
382
/// Create the profile
383
TAO_Unknown_Profile (CORBA::ULong tag,
384
TAO_ORB_Core *orb_core);
386
// = The TAO_Profile methods look above
387
virtual void parse_string (const char *string
389
virtual char object_key_delimiter (void) const;
390
virtual char* to_string (ACE_ENV_SINGLE_ARG_DECL);
391
virtual int decode (TAO_InputCDR& cdr);
392
virtual int encode (TAO_OutputCDR &stream) const;
393
virtual int encode_endpoints (void);
394
virtual const TAO::ObjectKey &object_key (void) const;
395
virtual TAO::ObjectKey *_key (void) const;
396
virtual TAO_Endpoint *endpoint (void);
397
virtual CORBA::ULong endpoint_count (void) const;
398
virtual CORBA::ULong hash (CORBA::ULong max
401
virtual int decode_profile (TAO_InputCDR &cdr);
402
virtual int decode_endpoints (void);
406
virtual CORBA::Boolean do_is_equivalent (const TAO_Profile* other_profile);
407
virtual CORBA::Boolean is_equivalent_hook (const TAO_Profile* other_profile);
410
virtual void create_profile_body (TAO_OutputCDR &encap) const;
412
virtual void parse_string_i (const char *string
418
#if defined (__ACE_INLINE__)
419
# include "Profile.i"
420
#endif /* __ACE_INLINE__ */
422
#include /**/ "ace/post.h"
424
#endif /* TAO_PROFILE_H */