~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/tao/Profile.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- C++ -*-
2
 
 
3
 
//=============================================================================
4
 
/**
5
 
 *  @file   Profile.h
6
 
 *
7
 
 *  Profile.h,v 1.51 2003/10/28 18:29:19 bala Exp
8
 
 *
9
 
 *  @author Fred Kuhns <fredk@cs.wustl.edu>
10
 
 */
11
 
//=============================================================================
12
 
 
13
 
#ifndef TAO_PROFILE_H
14
 
#define TAO_PROFILE_H
15
 
 
16
 
#include /**/ "ace/pre.h"
17
 
 
18
 
#include "tao/Tagged_Components.h"
19
 
 
20
 
#if !defined (ACE_LACKS_PRAGMA_ONCE)
21
 
# pragma once
22
 
#endif /* ACE_LACKS_PRAGMA_ONCE */
23
 
 
24
 
#include "tao/GIOP_Message_Version.h"
25
 
#include "tao/Refcounted_ObjectKey.h"
26
 
 
27
 
class ACE_Lock;
28
 
class TAO_MProfile;
29
 
class TAO_Stub;
30
 
class TAO_Endpoint;
31
 
class TAO_ORB_Core;
32
 
 
33
 
namespace CORBA
34
 
{
35
 
  /// Forward declaration of PolicyList
36
 
  class PolicyList;
37
 
 
38
 
  class TypeCode;
39
 
  typedef TypeCode *TypeCode_ptr;
40
 
}
41
 
 
42
 
/**
43
 
 * @class TAO_Profile
44
 
 *
45
 
 * @brief Defines the Profile interface
46
 
 *
47
 
 * An abstract base class for representing object location
48
 
 * information.  This is based on the CORBA IOR definitions.
49
 
 */
50
 
class TAO_Export TAO_Profile
51
 
{
52
 
public:
53
 
 
54
 
  /// Constructor
55
 
  TAO_Profile (CORBA::ULong tag,
56
 
               TAO_ORB_Core *orb_core,
57
 
               const TAO_GIOP_Message_Version &version);
58
 
 
59
 
  /// If you have a virtual method you need a virtual dtor.
60
 
  virtual ~TAO_Profile (void);
61
 
 
62
 
  /**
63
 
   * @name Non virtual methods for the profile classes.
64
 
  */
65
 
 
66
 
  //@{
67
 
  /// The tag, each concrete class will have a specific tag value.
68
 
  CORBA::ULong tag (void) const;
69
 
 
70
 
  /// Return a pointer to this profile's version.  This object
71
 
  /// maintains ownership.
72
 
  const TAO_GIOP_Message_Version &version (void) const;
73
 
 
74
 
  /// Get a pointer to the TAO_ORB_Core.
75
 
  TAO_ORB_Core *orb_core (void) const;
76
 
 
77
 
  /// Increase the reference count by one on this object.
78
 
  CORBA::ULong _incr_refcnt (void);
79
 
 
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);
83
 
 
84
 
  /// Keep a pointer to the forwarded profile
85
 
  void forward_to (TAO_MProfile *mprofiles);
86
 
 
87
 
  /// MProfile accessor
88
 
  TAO_MProfile* forward_to (void);
89
 
 
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);
94
 
 
95
 
  /// Add the given tagged component to the profile.
96
 
  void add_tagged_component (const IOP::TaggedComponent &component
97
 
                             ACE_ENV_ARG_DECL);
98
 
 
99
 
  /**
100
 
   * Return the current addressing mode for this profile.
101
 
   * In almost all cases, this is TAO_Target_Specification::Key_Addr.
102
 
   */
103
 
  CORBA::Short addressing_mode (void) const;
104
 
 
105
 
  /// @@ deprecated. return a reference to the Object Key.
106
 
  const TAO::ObjectKey &object_key (void) const;
107
 
 
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;
111
 
  //@}
112
 
 
113
 
 
114
 
  /**
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.
118
 
   */
119
 
  //@{
120
 
  /// Encode this profile in a stream, i.e. marshal it.
121
 
  virtual int encode (TAO_OutputCDR &stream) const;
122
 
 
123
 
  /// Initialize this object using the given CDR octet string.
124
 
  virtual int decode (TAO_InputCDR& cdr);
125
 
 
126
 
  /**
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
132
 
   * 1.2.
133
 
   */
134
 
  IOP::TaggedProfile *create_tagged_profile (void);
135
 
 
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
139
 
                         ACE_ENV_ARG_DECL);
140
 
 
141
 
  /// Accessor for the client exposed policies of this profile.
142
 
  virtual CORBA::PolicyList&  policies (ACE_ENV_SINGLE_ARG_DECL);
143
 
 
144
 
  /// Sets the TAO_Stub to which this profile is associated.
145
 
  virtual void the_stub (TAO_Stub *stub);
146
 
 
147
 
  /// Gets the TAO_MProfile that holds the TAO_Profile instance.
148
 
  virtual TAO_Stub* the_stub (void);
149
 
 
150
 
  /// Returns true if this profile can specify multicast endpoints.
151
 
  virtual int supports_multicast (void) const;
152
 
 
153
 
  /**
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.
158
 
   *
159
 
   * ** RACE CONDITION NOTE **
160
 
   *
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
168
 
   * that bad.)
169
 
   *
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.
175
 
   *
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.
179
 
   */
180
 
  virtual void addressing_mode (CORBA::Short addr_mode
181
 
                                ACE_ENV_ARG_DECL);
182
 
 
183
 
 
184
 
 
185
 
  /// The object key delimiter.
186
 
  virtual char object_key_delimiter (void) const = 0;
187
 
 
188
 
  /// Initialize this object using the given input string.
189
 
  /// Supports URL style of object references
190
 
  virtual void parse_string (const char *string
191
 
                             ACE_ENV_ARG_DECL);
192
 
 
193
 
  /// Return a string representation for this profile.  Client must
194
 
  /// deallocate memory. Only one endpoint is included into the
195
 
  /// string.
196
 
  virtual char* to_string (ACE_ENV_SINGLE_ARG_DECL) = 0;
197
 
 
198
 
  /**
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.
202
 
   */
203
 
  virtual int encode_endpoints (void) = 0;
204
 
 
205
 
  /**
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.
209
 
   */
210
 
  virtual TAO_Endpoint *endpoint (void) = 0;
211
 
 
212
 
  /// Return how many endpoints this profile contains.
213
 
  virtual CORBA::ULong endpoint_count (void) const = 0;
214
 
 
215
 
  /// Verify profile equivalance.
216
 
  /**
217
 
   * Two profiles are equivalent @e iff their tag, object_key, version
218
 
   * and all endpoints are the same.
219
 
   *
220
 
   * @see do_is_equivalent_i()
221
 
   * @see is_equivalent_hook()
222
 
   *
223
 
   * @return @c true if this profile is equivalent to @c other_profile.  
224
 
   */
225
 
  CORBA::Boolean is_equivalent (const TAO_Profile* other_profile);
226
 
 
227
 
  /// Return a hash value for this object.
228
 
  virtual CORBA::ULong hash (CORBA::ULong max
229
 
                             ACE_ENV_ARG_DECL) = 0;
230
 
  //@}
231
 
 
232
 
protected:
233
 
 
234
 
  /**
235
 
   * @name Protected template methods.
236
 
   */
237
 
  //@{
238
 
  /// Decode the protocol specific profile details.
239
 
  virtual int decode_profile (TAO_InputCDR &cdr) = 0;
240
 
 
241
 
  /// Creates an encapsulation of the ProfileBody struct in the <cdr>
242
 
  virtual void create_profile_body (TAO_OutputCDR &cdr) const = 0;
243
 
 
244
 
  /**
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.
250
 
   */
251
 
  virtual int decode_endpoints (void) = 0;
252
 
 
253
 
  /// Protocol specific implementation of parse_string ()
254
 
  virtual void parse_string_i (const char *string
255
 
                               ACE_ENV_ARG_DECL) = 0;
256
 
  //@}
257
 
 
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);
263
 
 
264
 
  /// Helper method that encodes the endpoints for RTCORBA as
265
 
  /// tagged_components.
266
 
  void set_tagged_components (TAO_OutputCDR &cdr);
267
 
 
268
 
  /// Profile equivalence template method invoked on subclasses.
269
 
  /**
270
 
   * TAO_Profile subclasses must implement this template method so
271
 
   * that they can apply their own definition of profile equivalence.
272
 
   */
273
 
  virtual CORBA::Boolean do_is_equivalent (const TAO_Profile * other) = 0;
274
 
 
275
 
  /// Allow services to apply their own definition of "equivalence."
276
 
  /**
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.
280
 
   */
281
 
  virtual CORBA::Boolean is_equivalent_hook (const TAO_Profile * other);
282
 
 
283
 
  CORBA::ULong hash_service_i (CORBA::ULong m);
284
 
 
285
 
private:
286
 
 
287
 
  /// this object keeps ownership of this object
288
 
  TAO_MProfile *forward_to_i (void);
289
 
 
290
 
  /// Verify that the current ORB's configuration supports tagged
291
 
  /// components in IORs.
292
 
  void verify_orb_configuration (ACE_ENV_SINGLE_ARG_DECL);
293
 
 
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);
297
 
 
298
 
  // Profiles should not be copied!
299
 
  ACE_UNIMPLEMENTED_FUNC (TAO_Profile (const TAO_Profile&))
300
 
  ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Profile&))
301
 
 
302
 
protected:
303
 
 
304
 
  /// IIOP version number.
305
 
  TAO_GIOP_Message_Version version_;
306
 
 
307
 
  /// The tagged components
308
 
  TAO_Tagged_Components tagged_components_;
309
 
 
310
 
  /// Flag indicating whether the lazy decoding of the client exposed
311
 
  /// policies has taken place.
312
 
  CORBA::Boolean are_policies_parsed_;
313
 
 
314
 
  /// Pointer to the TAO_Stub to which this profile is related.
315
 
  TAO_Stub *stub_;
316
 
 
317
 
  /// Client exposed policies of this profile.
318
 
  CORBA::PolicyList *policy_list_;
319
 
 
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.
325
 
 
326
 
  /// The current addressing mode.
327
 
  /// This may be changed if a remote server sends back an address mode
328
 
  /// exception.
329
 
  CORBA::Short addressing_mode_;
330
 
 
331
 
  /// Our tagged profile
332
 
  IOP::TaggedProfile *tagged_profile_;
333
 
 
334
 
  /// object_key associated with this profile.
335
 
  TAO::Refcounted_ObjectKey *ref_object_key_;
336
 
 
337
 
private:
338
 
  /// IOP protocol tag.
339
 
  CORBA::ULong tag_;
340
 
 
341
 
  /// Pointer to the ORB core
342
 
  TAO_ORB_Core *orb_core_;
343
 
 
344
 
  /// the TAO_MProfile which contains the profiles for the forwarded
345
 
  /// object.
346
 
  TAO_MProfile* forward_to_;
347
 
 
348
 
  /// Mutex to protect reference count.
349
 
  ACE_Lock *refcount_lock_;
350
 
 
351
 
  /// Number of outstanding references to this object.
352
 
  CORBA::ULong refcount_;
353
 
};
354
 
 
355
 
// A helper class to handle the various kinds of octet sequences used
356
 
// inside the ORB.
357
 
 
358
 
typedef TAO_Unbounded_Sequence<CORBA::Octet> TAO_opaque;
359
 
 
360
 
TAO_Export CORBA::Boolean
361
 
operator<< (TAO_OutputCDR&, const TAO_opaque&);
362
 
 
363
 
TAO_Export CORBA::Boolean
364
 
operator>> (TAO_InputCDR&, TAO_opaque&);
365
 
 
366
 
/**
367
 
 * @class TAO_Unknown_Profile
368
 
 *
369
 
 * @brief A TAO_Profile class to handle foreign profiles.
370
 
 *
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
374
 
 * dropped.
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.
378
 
 */
379
 
class TAO_Export TAO_Unknown_Profile : public TAO_Profile
380
 
{
381
 
public:
382
 
  /// Create the profile
383
 
  TAO_Unknown_Profile (CORBA::ULong tag,
384
 
                       TAO_ORB_Core *orb_core);
385
 
 
386
 
  // = The TAO_Profile methods look above
387
 
  virtual void parse_string (const char *string
388
 
                             ACE_ENV_ARG_DECL);
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
399
 
                             ACE_ENV_ARG_DECL);
400
 
 
401
 
  virtual int decode_profile (TAO_InputCDR &cdr);
402
 
  virtual int decode_endpoints (void);
403
 
 
404
 
protected:
405
 
 
406
 
  virtual CORBA::Boolean do_is_equivalent (const TAO_Profile* other_profile);
407
 
  virtual CORBA::Boolean is_equivalent_hook (const TAO_Profile* other_profile);
408
 
 
409
 
private:
410
 
  virtual void create_profile_body (TAO_OutputCDR &encap) const;
411
 
 
412
 
  virtual void parse_string_i (const char *string
413
 
                               ACE_ENV_ARG_DECL);
414
 
private:
415
 
  TAO_opaque body_;
416
 
};
417
 
 
418
 
#if defined (__ACE_INLINE__)
419
 
# include "Profile.i"
420
 
#endif /* __ACE_INLINE__ */
421
 
 
422
 
#include /**/ "ace/post.h"
423
 
 
424
 
#endif  /* TAO_PROFILE_H */