Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CORBA_TypeCode Class Reference

The CORBA TypeCode class. It maintains the in-memory representation of any OMG CORBA IDL data type. More...

#include <Typecode.h>

Collaboration diagram for CORBA_TypeCode:

Collaboration graph
[legend]
List of all members.

Public Types

typedef CORBA_TypeCode_ptr _ptr_type
typedef CORBA_TypeCode_var _var_type
enum  traverse_status { TRAVERSE_STOP, TRAVERSE_CONTINUE }

Public Methods

CORBA::Boolean equal (CORBA::TypeCode_ptr ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Compares two typecodes. Must be identical in every respect. More...

CORBA::Boolean equivalent (CORBA::TypeCode_ptr ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Conforms to CORBA 2.3.1 (99-10-07). More...

CORBA::TCKind kind (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 For all TypeCode kinds, returns the "kind" of the typecode. More...

const char * id (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 For tk_{objref,struct,union,enum,alias,except}. Returns the repository ID, raises BadKind. More...

const char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns name (), raises (BadKind). More...

CORBA::ULong member_count (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns member_count (), raises (BadKind). Useful for tk_struct, tk_union, tk_enum, tk_alias, and tk_except. More...

const char * member_name (CORBA::ULong slot ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Returns member_name (...), raises (BadKind, Bounds); Useful for tk_struct, tk_union, tk_enum, tk_alias, and tk_except. More...

CORBA::TypeCode_ptr member_type (CORBA::ULong slot ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Returns member_type (...), raises (BadKind, Bounds); Useful for tk_struct, tk_union, and tk_except. More...

CORBA::Any_ptr member_label (CORBA::ULong n ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 For tk_union. Returns the label. Raises BadKind, Bounds. More...

CORBA::TypeCode_ptr discriminator_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the discriminator type for tk_union. raises (BadKind). More...

CORBA::Long default_index (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the default slot for the tk_union. Raises (BadKind). More...

CORBA::ULong length (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns length, raises (BadKind). Used for tk_string, tk_sequence, and tk_array. More...

CORBA::TypeCode_ptr content_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the content type (element type). Raises (BadKind); Useful for tk_sequence, tk_array, and tk_alias. More...

CORBA::Visibility member_visibility (CORBA::ULong slot ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Returns the visibility (public/private) of the member at index 'slot'. Raises (BadKind, Bounds). Useful for tk_value only. More...

CORBA::ValueModifier type_modifier (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the value modifier. Raises (BadKind). Useful for tk_value only. More...

CORBA::TypeCode_ptr concrete_base_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the concrete base type. Raises (BadKind); Useful for tk_value only. More...

 CORBA_TypeCode (CORBA::TCKind kind)
 This constructor is used only for built-in TypeCode constants, with no parameters. More...

 CORBA_TypeCode (CORBA::TCKind kind, size_t length, const char *buffer, CORBA::Boolean orb_owns_tc, CORBA::ULong size, CORBA::TypeCode_ptr parent=0)
 ~CORBA_TypeCode (void)
 destructor. More...

CORBA::ULong _incr_refcnt (void)
CORBA::ULong _decr_refcnt (void)
CORBA::Any_ptr parameter (const CORBA::Long slot ACE_ENV_ARG_DECL_WITH_DEFAULTS)
 Deprecated in the CORBA 2.2 spec and missing altogether from 2.3a (98-12-04),. More...

CORBA::ULong param_count (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Deprecated, CORBA 1.2, not fully usable. Returns the number of parameters that the typecode takes. More...


Static Public Methods

CORBA::TypeCode_ptr _duplicate (CORBA::TypeCode_ptr tc)
 Duplicates i.e., increments ref count. More...

CORBA::TypeCode_ptr _nil (void)
 Returns a NULL typecode. More...

void _tao_decode (const CORBA_TypeCode *parent, TAO_InputCDR &cdr, CORBA_TypeCode *&child ACE_ENV_ARG_DECL)
 CDR decoding: the >> operator is not enough because we must also respect the parent/child relationship among TypeCodes. More...

CORBA::Boolean skip_typecode (TAO_InputCDR &stream)
 skip a typecode encoding in a given CDR stream. This is just a helper function. More...


Public Attributes

size_t length_
 length of the encapsulated stream. More...

const char * buffer_
 the encapsulated stream. More...

CORBA::Long byte_order_
 The byte order in the encapsulated stream. More...

CORBA::Long kind_
 the TypeCode kind. More...

CORBA::TypeCode_ptr parent_
const char * tc_base_
const char * root_tc_base_

Static Public Attributes

CORBA::TypeCode_ptr _tc_Bounds
CORBA::TypeCode_ptr _tc_BadKind

Private Methods

CORBA::Boolean equ_common (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
CORBA::Boolean private_equal (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Compares the typecodes. More...

const char * private_id (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 For tk_{objref,struct,union,enum,alias,except}. Returns the repository ID, raises BadKind. More...

const char * private_name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 returns name (), raises (BadKind). More...

CORBA::ULong private_member_count (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 returns member_count (), raises (BadKind). Useful for tk_struct, tk_union, tk_enum, tk_alias, and tk_except. More...

CORBA::TypeCode_ptr private_member_type (CORBA::ULong slot ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 returns member_type (...), raises (BadKind, Bounds); Useful for tk_struct, tk_union, and tk_except. More...

const char * private_member_name (CORBA::ULong slot ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 returns member_name (...), raises (BadKind, Bounds); Useful for tk_union, tk_struct, tk_except, and tk_enum. More...

CORBA::Any_ptr private_member_label (CORBA::ULong n ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 For tk_union. Returns the label. Raises BadKind, Bounds. More...

CORBA::TypeCode_ptr private_discriminator_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 returns the discriminator type for tk_union, and acquires the lock for the wrapped function below. raises (BadKind). More...

CORBA::TypeCode_ptr private_discriminator_type_i (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Acquires no lock so it can be called internally from blocks which have a lock. More...

CORBA::Long private_default_index (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 returns the default slot for the tk_union. Raises (BadKind);. More...

CORBA::Long private_default_index_i (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Acquires no lock so it can be called internally from blocks which have a lock. More...

CORBA::Long private_length (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns length, raises (BadKind). Used for tk_string, tk_sequence, and tk_array. More...

CORBA::TypeCode_ptr private_content_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the content type (element type). Raises (BadKind); Useful for tk_sequence, tk_array, and tk_alias. More...

CORBA::Visibility private_member_visibility (CORBA::ULong slot ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 Returns the visibility (public/private) of the member at index 'slot'. Raises (BadKind, Bounds). Useful for tk_value only. More...

CORBA::ValueModifier private_type_modifier (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the value modifier. Raises (BadKind). Useful for tk_value only. More...

CORBA::TypeCode_ptr private_concrete_base_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const
 Returns the concrete base type. Raises (BadKind). Useful for tk_value only. More...

CORBA::Boolean private_equal_objref (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of objrefs. More...

CORBA::Boolean private_equal_struct (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of structs. More...

CORBA::Boolean private_equal_union (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of unions. More...

CORBA::Boolean private_equal_enum (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of enums. More...

CORBA::Boolean private_equal_string (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of strings. More...

CORBA::Boolean private_equal_wstring (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of wide strings. More...

CORBA::Boolean private_equal_sequence (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of sequences. More...

CORBA::Boolean private_equal_array (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of array. More...

CORBA::Boolean private_equal_alias (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of typedefs. More...

CORBA::Boolean private_equal_except (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of exceptions. More...

CORBA::Boolean private_equal_valuetype (CORBA::TypeCode_ptr tc, CORBA::Boolean equiv_only ACE_ENV_ARG_DECL_WITH_DEFAULTS) const
 test equality for typecodes of exceptions. More...

 CORBA_TypeCode (const CORBA::TypeCode &src)
CORBA_TypeCode & operator= (const CORBA::TypeCode &src)

Private Attributes

CORBA::ULong refcount_
 if refcount reaches 0, free this typecode. More...

TAO_SYNCH_MUTEX refcount_lock_
 Protect the reference count, this is OK because we do no duplicates or releases on the critical path. More...

CORBA::Boolean orb_owns_
 TAO's approach differs from the SunSoft IIOP. Constant typecodes are owned by the ORB and get freed only when the ORB dies. More...

TC_Private_Stateprivate_state_
char * non_aligned_buffer_

Detailed Description

The CORBA TypeCode class. It maintains the in-memory representation of any OMG CORBA IDL data type.

Implements the CORBA::TypeCode interface specified by CORBA 2.0 spec. Typecodes essentially consist of just the CDR octets that get marshaled and unmarshaled, and this code knows how to parse those octets and answer questions CORBA's TypeCode APIs require. NOTE: This isn't well tuned performance-wise. Given how much is variable (byte order, alignment) it's clear tuning has its limits with respect to CDR bytecode interpretation. THREADING NOTE: Typecodes are readonly data structures, and the only mutual exclusion relates to reference counting and construction.

Definition at line 60 of file Typecode.h.


Member Typedef Documentation

typedef CORBA_TypeCode_ptr CORBA_TypeCode::_ptr_type
 

Definition at line 291 of file Typecode.h.

typedef CORBA_TypeCode_var CORBA_TypeCode::_var_type
 

Definition at line 292 of file Typecode.h.


Member Enumeration Documentation

enum CORBA_TypeCode::traverse_status
 

Enumeration values:
TRAVERSE_STOP 
TRAVERSE_CONTINUE 

Definition at line 212 of file Typecode.h.

00213   {
00214     TRAVERSE_STOP,
00215     TRAVERSE_CONTINUE
00216   };


Constructor & Destructor Documentation

CORBA_TypeCode::CORBA_TypeCode CORBA::TCKind    kind
 

This constructor is used only for built-in TypeCode constants, with no parameters.

Definition at line 147 of file Typecode.cpp.

References buffer_, byte_order_, kind, kind_, length_, non_aligned_buffer_, orb_owns_, parent_, private_state_, refcount_, root_tc_base_, and tc_base_.

00148   : length_ (0),
00149     buffer_ (0),
00150     byte_order_ (0),
00151     kind_ (kind),
00152     parent_ (0),
00153     tc_base_ (0),
00154     root_tc_base_ (0),
00155     refcount_ (1),
00156     orb_owns_ (1),
00157     private_state_ (new TC_Private_State (kind)),
00158     non_aligned_buffer_ (0)
00159 {
00160 }

CORBA_TypeCode::CORBA_TypeCode CORBA::TCKind    kind,
size_t    length,
const char *    buffer,
CORBA::Boolean    orb_owns_tc,
CORBA::ULong    size,
CORBA::TypeCode_ptr    parent = 0
 

This constructor is used both for typecode constants and for heap-allocated TypeCodes. The two are distinguished by the orb_owns_tc flag passed in by the creator.

For simple param lists with a single numeric parameter, only 'length' matters.

For complex param lists, or simple param lists for which the parameter is a string or typecode, length _and_ buffer matter.

For typecodes that are precomputed from the encapsulation stream of the parent, even the "parent" argument matters because this implies that all children will share the octet buffers of its parent

Definition at line 162 of file Typecode.cpp.

References ACE_NEW, ACE_ptr_align_binary, buffer_, byte_order_, length, ACE_CDR::MAX_ALIGNMENT, ACE_OS_String::memcpy, parent_, root_tc_base_, and tc_base_.

00168   : length_ (length),
00169     kind_ (kind),
00170     parent_ (parent),
00171     refcount_ (1),
00172     orb_owns_ (orb_owns_tc),
00173     private_state_ (new TC_Private_State (kind)),
00174     non_aligned_buffer_ (0)
00175 {
00176   // The CDR code used to interpret TypeCodes requires in-memory
00177   // alignments to match the "on-the-wire" alignments, simplifying
00178   // algorithms used to marshal/unmarshal.
00179   //
00180   // However, it's often hard to get compilers (in particular) to
00181   // generate data that's so aligned, since C++ doesn't provide
00182   // primitives giving control at that low a level.  Although there
00183   // are ways to get that alignment which work in almost all cases, we
00184   // need to ensure adequate alignment in _all_ cases.
00185   //
00186   // This code exists to ensure such alignment; since the constructor
00187   // is intended only for use by an IDL compiler or ORB code, it's not
00188   // currently a priority to ensure the allocated code is freed.
00189 
00190   // TAO comments:
00191 
00192   // For free standing typecodes, we choose to always make a copy of
00193   // the buffer passed in. That way, our destructor doesn't have to
00194   // deal with the case where the buffer was either allocated in which
00195   // case it must be freed or the case where our buffer just points to
00196   // the buffer passed in.
00197 
00198   if (this->parent_ == 0)
00199     {
00200       // Allocate a buffer to hold the encapsulated stream. We
00201       // allocate extra space since we need a buffer that is aligned
00202       // on a 4 byte word boundary. As a result, it is quite possible
00203       // that we may start accessing the buffer from a position
00204       // shifted to the right in the allocated buffer. As a result,
00205       // during destruction, we do not want part of the allocated heap
00206       // to remain dangling. Hence we save a handle to the original
00207       // allocated buffer.
00208 
00209       // *NOTE* that the buffer parameter is simply our encapsulation. It
00210       // does not contain our TypeCode::kind () and the length. These are
00211       // passed as separate parameters. However, in case of indirected
00212       // offset value for the indirection will effectively point to the
00213       // typecodes, the tk_kind field in our CDR representation. Hence,
00214       // we introduce a new field called tc_base_ which represents the
00215       // start of our CDR representation. The buffer_ data member will
00216       // point to our encapsulation.
00217 
00218       // @@ The typecode buffer contain the encapsulation byte order
00219       // in the first byte...
00220       const CORBA::Octet *ptr =
00221         ACE_reinterpret_cast (const CORBA::Octet *,
00222                               buffer);
00223       this->byte_order_ = *ptr;
00224 
00225       // allocate a buffer which will accomodate our entire encapsulation
00226       // plus 4 bytes for our tk_kind value and 4 bytes for our encapsulation
00227       // length. The extra MAX_ALIGNMENT bytes are necessary to ensure
00228       // that we will get a properly aligned buffer.
00229 
00230       static const size_t lsize = sizeof (CORBA::ULong);
00231       ACE_NEW (this->non_aligned_buffer_,
00232                char [this->length_ + lsize + lsize + ACE_CDR::MAX_ALIGNMENT]);
00233 
00234       char* start = ACE_ptr_align_binary (this->non_aligned_buffer_,
00235                                           ACE_CDR::MAX_ALIGNMENT);
00236 
00237       // length_ is of size_t which, on 64-bit platforms, is 64 bits.
00238       // The value to be copied is expected to be 32-bit.  We will cast
00239       // the value down to a CORBA::ULong and copy that.
00240       CORBA::ULong length = ACE_static_cast (CORBA::ULong, this->length_);
00241 
00242       (void) ACE_OS::memcpy (start, &this->kind_, lsize);
00243       (void) ACE_OS::memcpy (start + lsize, &length, lsize);
00244       (void) ACE_OS::memcpy (start + lsize + lsize, buffer, this->length_);
00245       // we are the topmost level typecode and hence our typecode base is
00246       // the start whereas the buffer_ which represents the encapsulation
00247       // is 8 bytes ahead of the typecode base
00248       this->tc_base_ = start;
00249       // since we do not have any parents, we are the root
00250       this->root_tc_base_ = start;
00251       this->buffer_ = start + lsize + lsize;
00252     }
00253   else
00254     {
00255       // We are a child. We do not allocate a new buffer, but share it
00256       // with our parent. We know that our parent's buffer was
00257       // properly aligned.
00258       const CORBA::Octet *ptr =
00259         ACE_reinterpret_cast (const CORBA::Octet *, buffer);
00260       this->byte_order_ = *ptr;
00261 
00262       this->buffer_ = buffer;
00263       // our typecode base is 8 bytes prior to our encapsulation and our
00264       // root base is the same as that of our parent's
00265       this->tc_base_ = this->buffer_ - 8;
00266       this->root_tc_base_ = parent->root_tc_base_;
00267     }
00268 }

CORBA_TypeCode::~CORBA_TypeCode void   
 

destructor.

Definition at line 273 of file Typecode.cpp.

References buffer_, non_aligned_buffer_, and private_state_.

00274 {
00275   // Delete the original, possibly nonaligned, buffer.
00276   delete [] this->non_aligned_buffer_;
00277   this->non_aligned_buffer_ = 0;
00278 
00279   this->buffer_ = 0;
00280 
00281   // Free up our private state.
00282   delete this->private_state_;
00283   this->private_state_ = 0;
00284 
00285 }

CORBA_TypeCode::CORBA_TypeCode const CORBA::TypeCode   src [private]
 


Member Function Documentation

ACE_INLINE CORBA::ULong CORBA_TypeCode::_decr_refcnt void   
 

Definition at line 12 of file Typecode.i.

References ACE_GUARD_RETURN, refcount_, and TAO_SYNCH_MUTEX.

00013 {
00014   {
00015     ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
00016     this->refcount_--;
00017     if (this->refcount_ != 0)
00018       return this->refcount_;
00019   }
00020   delete this;
00021   return 0;
00022 }

ACE_INLINE CORBA::TypeCode_ptr CORBA_TypeCode::_duplicate CORBA::TypeCode_ptr    tc [static]
 

Duplicates i.e., increments ref count.

Definition at line 25 of file Typecode.i.

Referenced by concrete_base_type, content_type, discriminator_type, and CORBA_TypeCode_var::operator=.

00026 {
00027   if (tc)
00028     tc->_incr_refcnt ();
00029   return tc;
00030 }

ACE_INLINE CORBA::ULong CORBA_TypeCode::_incr_refcnt void   
 

Definition at line 5 of file Typecode.i.

References ACE_GUARD_RETURN, refcount_, and TAO_SYNCH_MUTEX.

00006 {
00007   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
00008   return this->refcount_++;
00009 }

CORBA::TypeCode_ptr CORBA_TypeCode::_nil void    [static]
 

Returns a NULL typecode.

Referenced by CORBA_TypeCode_var::_retn, CORBA_TypeCode_out::CORBA_TypeCode_out, and CORBA_TypeCode_var::out.

void CORBA_TypeCode::_tao_decode const CORBA_TypeCode *    parent,
TAO_InputCDR   cdr,
CORBA_TypeCode *&child    ACE_ENV_ARG_DECL
[static]
 

CDR decoding: the >> operator is not enough because we must also respect the parent/child relationship among TypeCodes.

Referenced by operator>>, private_concrete_base_type, private_content_type, private_discriminator_type_i, and private_member_type.

CORBA::TypeCode_ptr CORBA_TypeCode::concrete_base_type ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns the concrete base type. Raises (BadKind); Useful for tk_value only.

Definition at line 516 of file Typecode.cpp.

References _duplicate, ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, private_concrete_base_type, private_state_, and TC_Private_State::tc_concrete_base_type_known_.

00517 {
00518   if (this->private_state_->tc_concrete_base_type_known_)
00519     {
00520       return CORBA_TypeCode::_duplicate (
00521           this->private_state_->tc_concrete_base_type_
00522           );
00523     }
00524   else
00525     {
00526       CORBA::TypeCode_ptr tmp =
00527         this->private_concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00528       ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
00529 
00530       return CORBA_TypeCode::_duplicate (tmp);
00531     }
00532 }

CORBA::TypeCode_ptr CORBA_TypeCode::content_type ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns the content type (element type). Raises (BadKind); Useful for tk_sequence, tk_array, and tk_alias.

Definition at line 443 of file Typecode.cpp.

References _duplicate, ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, kind_, private_content_type, private_state_, and TC_Private_State::tc_content_type_known_.

Referenced by private_equal_alias, and private_equal_sequence.

00444 {
00445   if (this->kind_ == CORBA::tk_sequence
00446       || this->kind_ == CORBA::tk_array
00447       || this->kind_ == CORBA::tk_alias)
00448     {
00449       if (this->private_state_->tc_content_type_known_)
00450         return CORBA_TypeCode::_duplicate (
00451                    this->private_state_->tc_content_type_
00452                  );
00453       else
00454         {
00455           CORBA::TypeCode_ptr tmp =
00456             this->private_content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00457           ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
00458 
00459           return CORBA_TypeCode::_duplicate (tmp);
00460         }
00461     }
00462   else
00463     {
00464       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (),
00465                         0);
00466     }
00467 
00468 }

CORBA::Long CORBA_TypeCode::default_index ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns the default slot for the tk_union. Raises (BadKind).

Definition at line 411 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, kind_, private_default_index, private_state_, TC_Private_State::tc_default_index_used_, and TC_Private_State::tc_default_index_used_known_.

Referenced by private_equal_union.

00412 {
00413   if (this->kind_ != CORBA::tk_union)
00414     ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0);
00415 
00416   if (this->private_state_->tc_default_index_used_known_)
00417     return this->private_state_->tc_default_index_used_;
00418   else
00419     return this->private_default_index (ACE_ENV_SINGLE_ARG_PARAMETER);
00420 }

CORBA::TypeCode_ptr CORBA_TypeCode::discriminator_type ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns the discriminator type for tk_union. raises (BadKind).

Definition at line 392 of file Typecode.cpp.

References _duplicate, ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, kind_, private_discriminator_type, private_state_, and TC_Private_State::tc_discriminator_type_known_.

Referenced by private_equal_union.

00393 {
00394   if (this->kind_ != CORBA::tk_union)
00395     ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), (CORBA::TypeCode_ptr)0);
00396 
00397   if (this->private_state_->tc_discriminator_type_known_)
00398     return CORBA_TypeCode::_duplicate (
00399                this->private_state_->tc_discriminator_type_
00400              );
00401 
00402   CORBA::TypeCode_ptr type =
00403     this->private_discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00404   ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
00405 
00406   return CORBA_TypeCode::_duplicate (type);
00407 }

CORBA::Boolean CORBA_TypeCode::equ_common CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

equal() and equivalent() must both recurse, but their behavior is somewhat different (as defined in CORBA 2.3). This function allows us to reuse the same code by acting as the point of recursion and by adding the equiv_only flag, to differentiate the behavior where necessary.

Definition at line 806 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, CORBA::is_nil, kind, kind_, and private_equal.

Referenced by equal, and equivalent.

00809 {
00810   // This will catch applications that haven't initialized an ORB.
00811   if (CORBA::is_nil (tc))
00812     {
00813       return 0;
00814     }
00815 
00816   // Are the two pointers the same?
00817   if (this == tc)
00818     {
00819       return 1;
00820     }
00821 
00822   if (equiv_only)
00823     {
00824       CORBA::TypeCode_var rcvr =
00825         CORBA::TypeCode::_duplicate (ACE_const_cast (CORBA_TypeCode *,
00826                                                      this));
00827 
00828       CORBA::Boolean status = (this->kind_ == CORBA::tk_alias);
00829 
00830       while (status)
00831         {
00832           rcvr = rcvr->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00833           ACE_CHECK_RETURN (0);
00834 
00835           status = (rcvr->kind (ACE_ENV_SINGLE_ARG_PARAMETER) == CORBA::tk_alias);
00836           ACE_CHECK_RETURN (0);
00837         }
00838 
00839       CORBA::TCKind kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00840       ACE_CHECK_RETURN (0);
00841       status = (kind == CORBA::tk_alias);
00842 
00843       // Added by Bala to check for leaks as content_type duplicates the
00844       // pointers
00845       CORBA::TypeCode_var tcvar =
00846         CORBA::TypeCode::_duplicate (ACE_const_cast (CORBA_TypeCode *,
00847                                                      tc));
00848 
00849       while (status)
00850         {
00851           tcvar = tcvar->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00852           ACE_CHECK_RETURN (0);
00853 
00854           kind = tcvar->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00855           ACE_CHECK_RETURN (0);
00856           status = (kind == CORBA::tk_alias);
00857         }
00858 
00859       kind = rcvr->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00860       ACE_CHECK_RETURN (0);
00861       CORBA::TCKind other_kind = tcvar->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00862       ACE_CHECK_RETURN (0);
00863 
00864       if (kind != other_kind)
00865         // simple case
00866         return 0;
00867 
00868       // typecode kinds are same
00869       return rcvr->private_equal (tcvar.in (),
00870                                   equiv_only
00871                                    ACE_ENV_ARG_PARAMETER);
00872     }
00873 
00874   CORBA::TCKind kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00875   ACE_CHECK_RETURN (0);
00876   if (this->kind_ != kind)
00877     // simple case
00878     return 0;
00879 
00880   // typecode kinds are same
00881   return this->private_equal (tc,
00882                               equiv_only
00883                                ACE_ENV_ARG_PARAMETER);
00884 }

ACE_INLINE CORBA::Boolean CORBA_TypeCode::equal CORBA::TypeCode_ptr    ACE_ENV_ARG_DECL_WITH_DEFAULTS const
 

Compares two typecodes. Must be identical in every respect.

Definition at line 56 of file Typecode.i.

References ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, and equ_common.

00058 {
00059   return this->equ_common (tc,
00060                            0
00061                             ACE_ENV_ARG_PARAMETER);
00062 }

ACE_INLINE CORBA::Boolean CORBA_TypeCode::equivalent CORBA::TypeCode_ptr    ACE_ENV_ARG_DECL_WITH_DEFAULTS const
 

Conforms to CORBA 2.3.1 (99-10-07).

Definition at line 46 of file Typecode.i.

References ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, and equ_common.

00048 {
00049   return this->equ_common (tc,
00050                            1
00051                             ACE_ENV_ARG_PARAMETER);
00052 }

ACE_INLINE const char * CORBA_TypeCode::id ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

For tk_{objref,struct,union,enum,alias,except}. Returns the repository ID, raises BadKind.

Definition at line 66 of file Typecode.i.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, private_id, private_state_, TC_Private_State::tc_id_, and TC_Private_State::tc_id_known_.

Referenced by private_equal_alias, private_equal_enum, private_equal_except, private_equal_objref, private_equal_struct, private_equal_union, and private_equal_valuetype.

00067 {
00068   // if already precomputed
00069   if (this->private_state_->tc_id_known_)
00070     return this->private_state_->tc_id_;
00071   else
00072     return this->private_id (ACE_ENV_SINGLE_ARG_PARAMETER);
00073 }

ACE_INLINE CORBA::TCKind CORBA_TypeCode::kind ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

For all TypeCode kinds, returns the "kind" of the typecode.

Definition at line 39 of file Typecode.i.

References ACE_ENV_SINGLE_ARG_DECL_NOT_USED, and kind_.

Referenced by CORBA_TypeCode, equ_common, and skip_typecode.

00040 {
00041   return (CORBA::TCKind) this->kind_;
00042 }

CORBA::ULong CORBA_TypeCode::length ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns length, raises (BadKind). Used for tk_string, tk_sequence, and tk_array.

Definition at line 424 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, kind_, private_length, private_state_, TC_Private_State::tc_length_, and TC_Private_State::tc_length_known_.

Referenced by CORBA_TypeCode, private_equal_sequence, private_equal_string, and private_equal_wstring.

00425 {
00426   // a switch stmt, unfortunately, doesn't get inlined
00427   if (this->kind_ == CORBA::tk_sequence
00428       || this->kind_ == CORBA::tk_array
00429       || this->kind_ == CORBA::tk_string
00430       || this->kind_ == CORBA::tk_wstring)
00431     {
00432       if (this->private_state_->tc_length_known_)
00433         return this->private_state_->tc_length_;
00434       else
00435         return this->private_length (ACE_ENV_SINGLE_ARG_PARAMETER);
00436     }
00437   else
00438     ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0);
00439 }

ACE_INLINE CORBA::ULong CORBA_TypeCode::member_count ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns member_count (), raises (BadKind). Useful for tk_struct, tk_union, tk_enum, tk_alias, and tk_except.

Definition at line 92 of file Typecode.i.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, private_member_count, private_state_, TC_Private_State::tc_member_count_, and TC_Private_State::tc_member_count_known_.

Referenced by private_equal_enum, private_equal_except, private_equal_struct, private_equal_union, private_member_label, private_member_name, private_member_type, and private_member_visibility.

00093 {
00094   // if already precomputed
00095   if (this->private_state_->tc_member_count_known_)
00096     return this->private_state_->tc_member_count_;
00097   else
00098     return this->private_member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
00099 }

CORBA::Any_ptr CORBA_TypeCode::member_label CORBA::ULong   ACE_ENV_ARG_DECL_WITH_DEFAULTS const
 

For tk_union. Returns the label. Raises BadKind, Bounds.

const char * CORBA_TypeCode::member_name CORBA::ULong slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS const
 

Returns member_name (...), raises (BadKind, Bounds); Useful for tk_struct, tk_union, tk_enum, tk_alias, and tk_except.

Definition at line 329 of file Typecode.cpp.

References ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, private_member_name, private_state_, TC_Private_State::tc_member_count_, TC_Private_State::tc_member_count_known_, TC_Private_State::tc_member_name_list_, and TC_Private_State::tc_member_name_list_known_.

Referenced by private_equal_enum, private_equal_except, private_equal_struct, and private_equal_union.

00331 {
00332   if (this->private_state_->tc_member_count_known_
00333       && this->private_state_->tc_member_name_list_known_)
00334     {
00335       if (slot < this->private_state_->tc_member_count_)
00336         {
00337           return this->private_state_->tc_member_name_list_[slot];
00338         }
00339       else
00340         {
00341           ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
00342                             0);
00343         }
00344     }
00345   else
00346     {
00347       return this->private_member_name (slot
00348                                          ACE_ENV_ARG_PARAMETER);
00349     }
00350 }

CORBA::TypeCode_ptr CORBA_TypeCode::member_type CORBA::ULong slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS const
 

Returns member_type (...), raises (BadKind, Bounds); Useful for tk_struct, tk_union, and tk_except.

Definition at line 294 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, private_state_, TC_Private_State::tc_member_count_, TC_Private_State::tc_member_count_known_, and TC_Private_State::tc_member_type_list_known_.

Referenced by private_equal_except, private_equal_struct, private_equal_union, and private_member_type.

00296 {
00297   CORBA::TypeCode_ptr typecode = 0;
00298 
00299   if (this->private_state_->tc_member_count_known_
00300       && this->private_state_->tc_member_type_list_known_)
00301     {
00302       if (slot < this->private_state_->tc_member_count_)
00303         {
00304           typecode = CORBA::TypeCode::_duplicate (
00305                          this->private_state_->tc_member_type_list_[slot]
00306                        );
00307         }
00308       else
00309         {
00310           ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
00311                             0);
00312         }
00313     }
00314   else
00315     {
00316       typecode = CORBA::TypeCode::_duplicate (
00317                      this->private_member_type (slot
00318                                                 ACE_ENV_ARG_PARAMETER)
00319                    );
00320       ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
00321     }
00322 
00323   return typecode;
00324 }

CORBA::Visibility CORBA_TypeCode::member_visibility CORBA::ULong slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS const
 

Returns the visibility (public/private) of the member at index 'slot'. Raises (BadKind, Bounds). Useful for tk_value only.

Definition at line 471 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, private_member_visibility, private_state_, TC_Private_State::tc_member_count_, TC_Private_State::tc_member_count_known_, TC_Private_State::tc_member_visibility_list_, and TC_Private_State::tc_member_visibility_list_known_.

00473 {
00474   if (this->private_state_->tc_member_count_known_
00475       && this->private_state_->tc_member_visibility_list_known_)
00476     {
00477       if (slot < this->private_state_->tc_member_count_)
00478         {
00479           return this->private_state_->tc_member_visibility_list_[slot];
00480         }
00481       else
00482         {
00483           ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
00484                             0);
00485         }
00486     }
00487   else
00488     {
00489       CORBA::Visibility v =
00490         this->private_member_visibility (slot
00491                                          ACE_ENV_ARG_PARAMETER);
00492       ACE_CHECK_RETURN (CORBA::PRIVATE_MEMBER);
00493 
00494       return v;
00495     }
00496 }

ACE_INLINE const char * CORBA_TypeCode::name ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns name (), raises (BadKind).

Definition at line 77 of file Typecode.i.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, private_name, private_state_, TC_Private_State::tc_name_, and TC_Private_State::tc_name_known_.

Referenced by private_equal_alias, private_equal_enum, private_equal_except, private_equal_objref, private_equal_struct, private_equal_union, and private_equal_valuetype.

00078 {
00079   // if already precomputed
00080   if (this->private_state_->tc_name_known_)
00081     return this->private_state_->tc_name_;
00082   else
00083     return this->private_name (ACE_ENV_SINGLE_ARG_PARAMETER);
00084 }

CORBA_TypeCode& CORBA_TypeCode::operator= const CORBA::TypeCode   src [private]
 

CORBA::ULong CORBA_TypeCode::param_count ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Deprecated, CORBA 1.2, not fully usable. Returns the number of parameters that the typecode takes.

Definition at line 3149 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_THROW_RETURN, kind_, ACE_InputCDR::read_ulong, ACE_InputCDR::skip_string, and skip_typecode.

03150 {
03151   switch (this->kind_)
03152     {
03153     default:
03154       return 0;
03155 
03156     case CORBA::tk_string:
03157     case CORBA::tk_wstring:
03158       return 1;
03159 
03160     case CORBA::tk_objref:
03161     case CORBA::tk_sequence:
03162     case CORBA::tk_array:
03163       return 2;
03164 
03165     case CORBA::tk_alias:
03166       return 3;
03167 
03168     case CORBA::tk_except:
03169     case CORBA::tk_struct:
03170       {
03171         CORBA::ULong members;
03172         TAO_InputCDR stream (this->buffer_+4, this->length_-4,
03173                              this->byte_order_);
03174 
03175         // skip rest of header (type ID and name) and collect the
03176         // number of struct members
03177         if (!stream.skip_string ()                  // ID
03178             || !stream.skip_string ()       // struct name
03179             || !stream.read_ulong (members))
03180           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
03181 
03182         return 3 + 2 * members;
03183       }
03184 
03185     case CORBA::tk_enum:
03186       {
03187         CORBA::ULong members;
03188         TAO_InputCDR stream (this->buffer_+4, this->length_-4,
03189                              this->byte_order_);
03190 
03191         // skip rest of header (type ID and name) and collect the
03192         // number of struct members
03193         if (!stream.skip_string ()                      // ID
03194             || !stream.skip_string ()           // typedef name
03195             || !stream.read_ulong (members))
03196           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
03197 
03198         return 3 + members;
03199       }
03200 
03201     case CORBA::tk_union:
03202       {
03203         CORBA::ULong members;
03204         TAO_InputCDR stream (this->buffer_+4, this->length_-4,
03205                              this->byte_order_);
03206 
03207         // skip rest of header (type ID, name, etc...) and collect the
03208         // number of struct members
03209         if (!stream.skip_string ()                    // ID
03210             || !stream.skip_string ()                 // struct name
03211             || !this->skip_typecode (stream)          // discriminant TC
03212             || !stream.read_ulong (members)           // default used
03213             || !stream.read_ulong (members))          // real member count
03214           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
03215 
03216         return 5 + 3 * members;
03217       }
03218     }
03219 }

CORBA::Any_ptr CORBA_TypeCode::parameter const CORBA::Long slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS
 

Deprecated in the CORBA 2.2 spec and missing altogether from 2.3a (98-12-04),.

Definition at line 3222 of file Typecode.cpp.

References ACE_ENV_ARG_DECL, ACE_THROW_RETURN, and TAO_DEFAULT_MINOR_CODE.

03224 {
03225   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
03226                                          CORBA::COMPLETED_NO),
03227                     0);
03228 }

CORBA::TypeCode_ptr CORBA_TypeCode::private_concrete_base_type ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

Returns the concrete base type. Raises (BadKind). Useful for tk_value only.

Definition at line 2844 of file Typecode.cpp.

References _tao_decode, ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, kind_, private_state_, ACE_InputCDR::skip_long, ACE_InputCDR::skip_string, TAO_SYNCH_MUTEX, TC_Private_State::tc_concrete_base_type_, and TC_Private_State::tc_concrete_base_type_known_.

Referenced by concrete_base_type.

02845 {
02846   if (this->kind_ != CORBA::tk_value)
02847     {
02848       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (),
02849                         0);
02850     }
02851 
02852   // Double checked locking...
02853   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02854                     this->private_state_->mutex_,
02855                     0);
02856 
02857   if (this->private_state_->tc_concrete_base_type_known_)
02858     {
02859       return this->private_state_->tc_concrete_base_type_;
02860     }
02861 
02862   // Set up an encapsulation.
02863   TAO_InputCDR stream (this->buffer_+4,
02864                        this->length_-4,
02865                        this->byte_order_);
02866 
02867   // Skip rest of header (type ID, name, etc) and collect the
02868   // number of value members.
02869   // @@@ (JP) When the IDL compiler is updated to create typecodes
02870   // using a CDR stream, ValueModifier will have to be changed to
02871   // skip_short.
02872   if (!stream.skip_string ()          // ID
02873       || !stream.skip_string ()       // Name
02874       || !stream.skip_long ())        // ValueModifier
02875     {
02876       ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02877                         0);
02878     }
02879 
02880   // Retrieve the concrete base typecode.
02881   CORBA_TypeCode::_tao_decode (this,
02882                                stream,
02883                                this->private_state_->tc_concrete_base_type_
02884                                ACE_ENV_ARG_PARAMETER);
02885   ACE_CHECK_RETURN (0);
02886 
02887   this->private_state_->tc_concrete_base_type_known_ = 1;
02888   return this->private_state_->tc_concrete_base_type_;
02889 }

CORBA::TypeCode_ptr CORBA_TypeCode::private_content_type ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

Returns the content type (element type). Raises (BadKind); Useful for tk_sequence, tk_array, and tk_alias.

Definition at line 2671 of file Typecode.cpp.

References _tao_decode, ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, private_state_, ACE_InputCDR::skip_string, TAO_SYNCH_MUTEX, TC_Private_State::tc_content_type_, and TC_Private_State::tc_content_type_known_.

Referenced by content_type.

02672 {
02673   TAO_InputCDR stream (this->buffer_+4, this->length_-4,
02674                        this->byte_order_);
02675   switch (kind_)
02676     {
02677     case CORBA::tk_sequence:
02678     case CORBA::tk_array:
02679       {
02680         // Double checked locking...
02681         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02682                           this->private_state_->mutex_, 0);
02683         if (this->private_state_->tc_content_type_known_)
02684           return this->private_state_->tc_content_type_;
02685 
02686         // retrieve the content type
02687         CORBA_TypeCode::_tao_decode (this,
02688                                      stream,
02689                                      this->private_state_->tc_content_type_
02690                                       ACE_ENV_ARG_PARAMETER);
02691         ACE_CHECK_RETURN (0);
02692 
02693         this->private_state_->tc_content_type_known_ = 1;
02694         return this->private_state_->tc_content_type_;
02695       }
02696       ACE_NOTREACHED (break);
02697 
02698     case CORBA::tk_alias:
02699       {
02700         // Double checked locking...
02701         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02702                           this->private_state_->mutex_, 0);
02703         if (this->private_state_->tc_content_type_known_)
02704           return this->private_state_->tc_content_type_;
02705 
02706         if (!stream.skip_string ()  // typeID
02707             || !stream.skip_string ()) // name
02708           ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0);
02709 
02710         CORBA_TypeCode::_tao_decode (this,
02711                                      stream,
02712                                      this->private_state_->tc_content_type_
02713                                      ACE_ENV_ARG_PARAMETER);
02714         ACE_CHECK_RETURN (0);
02715 
02716         this->private_state_->tc_content_type_known_ = 1;
02717         return this->private_state_->tc_content_type_;
02718       }
02719       /*NOTREACHED*/
02720 
02721     default:
02722       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0);
02723     }
02724   ACE_NOTREACHED (return 0);
02725 }

CORBA::Long CORBA_TypeCode::private_default_index ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

returns the default slot for the tk_union. Raises (BadKind);.

Definition at line 2582 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD_RETURN, private_default_index_i, and TAO_SYNCH_MUTEX.

Referenced by default_index.

02585 {
02586   // Double checked locking...
02587   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02588                     this->private_state_->mutex_, 0);
02589 
02590   return this->private_default_index_i (ACE_ENV_SINGLE_ARG_PARAMETER);
02591 }

CORBA::Long CORBA_TypeCode::private_default_index_i ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

Acquires no lock so it can be called internally from blocks which have a lock.

Definition at line 2594 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_THROW_RETURN, private_state_, ACE_InputCDR::read_long, ACE_InputCDR::skip_string, skip_typecode, TC_Private_State::tc_default_index_used_, and TC_Private_State::tc_default_index_used_known_.

Referenced by private_default_index.

02597 {
02598   if (this->private_state_->tc_default_index_used_known_)
02599     return this->private_state_->tc_default_index_used_;
02600 
02601   TAO_InputCDR stream (this->buffer_+4, this->length_-4,
02602                        this->byte_order_);
02603 
02604   // skip ID and name, and then get the discriminant TC
02605 
02606   if (!stream.skip_string ()                  // type ID, hidden
02607       || !stream.skip_string ()               // typedef name
02608       || !this->skip_typecode (stream)        // skip discriminant
02609       || !stream.read_long (this->private_state_->tc_default_index_used_))
02610     ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
02611 
02612   this->private_state_->tc_default_index_used_known_ = 1;
02613   return this->private_state_->tc_default_index_used_;
02614 }

CORBA::TypeCode_ptr CORBA_TypeCode::private_discriminator_type ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

returns the discriminator type for tk_union, and acquires the lock for the wrapped function below. raises (BadKind).

Definition at line 2543 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD_RETURN, private_discriminator_type_i, and TAO_SYNCH_MUTEX.

Referenced by discriminator_type.

02546 {
02547   // Double checked locking...
02548   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02549                     this->private_state_->mutex_, 0);
02550 
02551   return this->private_discriminator_type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
02552 }

CORBA::TypeCode_ptr CORBA_TypeCode::private_discriminator_type_i ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

Acquires no lock so it can be called internally from blocks which have a lock.

Definition at line 2555 of file Typecode.cpp.

References _tao_decode, ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_DECL, ACE_THROW_RETURN, private_state_, ACE_InputCDR::skip_string, TC_Private_State::tc_discriminator_type_, and TC_Private_State::tc_discriminator_type_known_.

Referenced by private_discriminator_type, private_member_label, private_member_name, and private_member_type.

02558 {
02559   if (this->private_state_->tc_discriminator_type_known_)
02560     return this->private_state_->tc_discriminator_type_;
02561 
02562   TAO_InputCDR stream (this->buffer_+4, this->length_-4,
02563                        this->byte_order_);
02564 
02565   // skip ID and name, and then get the discriminant TC
02566 
02567   if (!stream.skip_string ()      // type ID, hidden
02568       || !stream.skip_string ())  // typedef name
02569     ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
02570 
02571   CORBA_TypeCode::_tao_decode (this,
02572                                stream,
02573                                this->private_state_->tc_discriminator_type_
02574                                 ACE_ENV_ARG_PARAMETER);
02575   ACE_CHECK_RETURN (0);
02576 
02577   this->private_state_->tc_discriminator_type_known_ = 1;
02578   return this->private_state_->tc_discriminator_type_;
02579 }

CORBA::Boolean CORBA_TypeCode::private_equal CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

Compares the typecodes.

Definition at line 890 of file Typecode.cpp.

References ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, kind_, private_equal_alias, private_equal_array, private_equal_enum, private_equal_except, private_equal_objref, private_equal_sequence, private_equal_string, private_equal_struct, private_equal_union, private_equal_valuetype, and private_equal_wstring.

Referenced by equ_common.

00893 {
00894   // We come in here only if the typecode kinds of both are same
00895   // Handle each complex typecode separately.
00896   switch (this->kind_)
00897     {
00898     case CORBA::tk_null:
00899     case CORBA::tk_void:
00900     case CORBA::tk_short:
00901     case CORBA::tk_ushort:
00902     case CORBA::tk_long:
00903     case CORBA::tk_ulong:
00904     case CORBA::tk_float:
00905     case CORBA::tk_double:
00906     case CORBA::tk_longlong:
00907     case CORBA::tk_ulonglong:
00908     case CORBA::tk_longdouble:
00909     case CORBA::tk_boolean:
00910     case CORBA::tk_octet:
00911     case CORBA::tk_char:
00912     case CORBA::tk_wchar:
00913     case CORBA::tk_TypeCode:
00914     case CORBA::tk_Principal:
00915     case CORBA::tk_any:
00916       // all these are simple typecodes and the comparison is based
00917       // solely on the kind_ field
00918       return 1;
00919     case CORBA::tk_objref:
00920       return this->private_equal_objref (tc,
00921                                          equiv_only
00922                                           ACE_ENV_ARG_PARAMETER);
00923     case CORBA::tk_struct:
00924       return this->private_equal_struct (tc,
00925                                          equiv_only
00926                                           ACE_ENV_ARG_PARAMETER);
00927     case CORBA::tk_union:
00928       return this->private_equal_union (tc,
00929                                         equiv_only
00930                                          ACE_ENV_ARG_PARAMETER);
00931     case CORBA::tk_enum:
00932       return this->private_equal_enum (tc,
00933                                        equiv_only
00934                                         ACE_ENV_ARG_PARAMETER);
00935     case CORBA::tk_string:
00936       return this->private_equal_string (tc,
00937                                          equiv_only
00938                                           ACE_ENV_ARG_PARAMETER);
00939     case CORBA::tk_wstring:
00940       return this->private_equal_wstring (tc,
00941                                           equiv_only
00942                                            ACE_ENV_ARG_PARAMETER);
00943     case CORBA::tk_sequence:
00944       return this->private_equal_sequence (tc,
00945                                            equiv_only
00946                                             ACE_ENV_ARG_PARAMETER);
00947     case CORBA::tk_array:
00948       return this->private_equal_array (tc,
00949                                         equiv_only
00950                                          ACE_ENV_ARG_PARAMETER);
00951     case CORBA::tk_alias:
00952       return this->private_equal_alias (tc,
00953                                         equiv_only
00954                                          ACE_ENV_ARG_PARAMETER);
00955     case CORBA::tk_except:
00956       return this->private_equal_except (tc,
00957                                          equiv_only
00958                                           ACE_ENV_ARG_PARAMETER);
00959     case CORBA::tk_value:
00960       return this->private_equal_valuetype (tc,
00961                                             equiv_only
00962                                             ACE_ENV_ARG_PARAMETER);
00963 
00964     case ~0u: // indirection
00965       {
00966         // indirection offset must be same
00967         return 1;
00968       }
00969       ACE_NOTREACHED (break);
00970     default:
00971       return 0;
00972     }
00973 }

CORBA::Boolean CORBA_TypeCode::private_equal_alias CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of typedefs.

Definition at line 1463 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, content_type, id, name, ACE_OS_String::strcmp, and ACE_OS_String::strlen.

Referenced by private_equal.

01466 {
01467   // for structs the repoID and names are optional. However, if provided,
01468   // we must compare them
01469   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01470   ACE_CHECK_RETURN (0);
01471 
01472   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01473   ACE_CHECK_RETURN (0);
01474 
01475   const char *my_name = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01476   ACE_CHECK_RETURN (0);
01477 
01478   const char *tc_name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01479   ACE_CHECK_RETURN (0);
01480 
01481   // compare repoIDs if they exist
01482   if (ACE_OS::strlen (my_id) > 1 && ACE_OS::strlen (tc_id) > 1)
01483     if (ACE_OS::strcmp (my_id, tc_id)) // not same
01484       return 0;
01485 
01486   // compare names if they exist
01487   if (ACE_OS::strlen (my_name) > 1 && ACE_OS::strlen (tc_name) > 1)
01488     if (ACE_OS::strcmp (my_name, tc_name)) // not same
01489       return 0;
01490 
01491   // now compare element typecodes
01492   CORBA::TypeCode_var my_elem = this->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
01493   ACE_CHECK_RETURN (0);
01494 
01495   CORBA::TypeCode_var tc_elem = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
01496   ACE_CHECK_RETURN (0);
01497 
01498   return my_elem->equ_common (tc_elem.in (),
01499                               equiv_only
01500                                ACE_ENV_ARG_PARAMETER);
01501 }

CORBA::Boolean CORBA_TypeCode::private_equal_array CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of array.

Definition at line 1452 of file Typecode.cpp.

References ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, and private_equal_sequence.

Referenced by private_equal.

01455 {
01456   // exactly like sequence
01457   return this->private_equal_sequence (tc,
01458                                        equiv_only
01459                                         ACE_ENV_ARG_PARAMETER);
01460 }

CORBA::Boolean CORBA_TypeCode::private_equal_enum CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of enums.

Definition at line 1306 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, id, member_count, member_name, name, ACE_OS_String::strcmp, and ACE_OS_String::strlen.

Referenced by private_equal.

01309 {
01310   // For enums the repoID and names are optional. However, if provided, we
01311   // must compare them
01312   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01313   ACE_CHECK_RETURN (0);
01314 
01315   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01316   ACE_CHECK_RETURN (0);
01317 
01318   // compare repoIDs if they exist
01319   if (ACE_OS::strlen (my_id) > 1 && ACE_OS::strlen (tc_id) > 1)
01320     {
01321       if (ACE_OS::strcmp (my_id, tc_id)) // not same
01322         {
01323           return 0;
01324         }
01325       else
01326         {
01327           // Equality of repoIDs is sufficient for equivalence.
01328           if (equiv_only)
01329             return 1;
01330         }
01331     }
01332 
01333   // Skipped by equivalent().
01334   if (!equiv_only)
01335     {
01336       const char *my_name = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01337       ACE_CHECK_RETURN (0);
01338 
01339       const char *tc_name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01340       ACE_CHECK_RETURN (0);
01341 
01342       // Compare names if they exist.
01343       if (ACE_OS::strlen (my_name) > 1
01344           && ACE_OS::strlen (tc_name) > 1
01345           && ACE_OS::strcmp (my_name,
01346                              tc_name)) // not same
01347         return 0;
01348     }
01349 
01350   // check if the member count is same
01351   CORBA::ULong my_count = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01352   ACE_CHECK_RETURN (0);
01353 
01354   CORBA::ULong tc_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01355   ACE_CHECK_RETURN (0);
01356 
01357   if (my_count != tc_count)
01358     return 0; // number of members don't match
01359 
01360   for (CORBA::ULong i=0; i < my_count; i++)
01361     {
01362       // Check if member names are same - skipped by equivalent().
01363       if (!equiv_only)
01364         {
01365           const char *my_member_name = this->member_name (i
01366                                                            ACE_ENV_ARG_PARAMETER);
01367           ACE_CHECK_RETURN (0);
01368 
01369           const char *tc_member_name = tc->member_name (i
01370                                                          ACE_ENV_ARG_PARAMETER);
01371           ACE_CHECK_RETURN (0);
01372 
01373           if (ACE_OS::strlen (my_member_name) > 1
01374               && ACE_OS::strlen (tc_member_name) > 1
01375               && ACE_OS::strcmp (my_member_name,
01376                                  tc_member_name)) // not same
01377             return 0;
01378         }
01379     }
01380 
01381   return 1; // success
01382 }

CORBA::Boolean CORBA_TypeCode::private_equal_except CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of exceptions.

Definition at line 1504 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, id, member_count, member_name, member_type, name, ACE_OS_String::strcmp, and ACE_OS_String::strlen.

Referenced by private_equal.

01507 {
01508   // exactly similar to structs, except that the repository ID is mandatory
01509 
01510   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01511   ACE_CHECK_RETURN (0);
01512 
01513   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01514   ACE_CHECK_RETURN (0);
01515 
01516   if (ACE_OS::strcmp (my_id, tc_id))
01517     {
01518       return 0; // failed
01519     }
01520   else
01521     {
01522       // Equality of repoIDs is sufficient for equivalence.
01523       if (equiv_only)
01524         return 1;
01525     }
01526 
01527   // Now compare names. They may be optional - skipped by equivalent().
01528   if (!equiv_only)
01529     {
01530       const char *my_name = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01531       ACE_CHECK_RETURN (0);
01532 
01533       const char *tc_name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01534       ACE_CHECK_RETURN (0);
01535 
01536       // Compare names if they exist.
01537       if (ACE_OS::strlen (my_name) > 1
01538           && ACE_OS::strlen (tc_name) > 1
01539           && ACE_OS::strcmp (my_name,
01540                              tc_name)) // not same
01541         return 0;
01542     }
01543 
01544   // check if the member count is same
01545   CORBA::ULong my_count = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01546   ACE_CHECK_RETURN (0);
01547 
01548   CORBA::ULong tc_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01549   ACE_CHECK_RETURN (0);
01550 
01551   if (my_count != tc_count)
01552     return 0; // number of members don't match
01553 
01554   for (CORBA::ULong i=0; i < my_count; i++)
01555     {
01556       // Check if member names are same - skipped by equivalent().
01557       if (!equiv_only)
01558         {
01559           const char *my_member_name = this->member_name (i
01560                                                            ACE_ENV_ARG_PARAMETER);
01561           ACE_CHECK_RETURN (0);
01562 
01563           const char *tc_member_name = tc->member_name (i
01564                                                          ACE_ENV_ARG_PARAMETER);
01565           ACE_CHECK_RETURN (0);
01566 
01567           if (ACE_OS::strlen (my_member_name) > 1
01568               && ACE_OS::strlen (tc_member_name) > 1
01569               && ACE_OS::strcmp (my_member_name,
01570                                  tc_member_name)) // not same
01571             return 0;
01572         }
01573 
01574       // now compare the typecodes of the members
01575       CORBA::TypeCode_var my_member_tc = this->member_type (i ACE_ENV_ARG_PARAMETER);
01576       ACE_CHECK_RETURN (0);
01577 
01578       CORBA::TypeCode_var tc_member_tc = tc->member_type (i ACE_ENV_ARG_PARAMETER);
01579       ACE_CHECK_RETURN (0);
01580 
01581       CORBA::Boolean flag = my_member_tc->equ_common (tc_member_tc.in (),
01582                                                       equiv_only
01583                                                        ACE_ENV_ARG_PARAMETER);
01584       ACE_CHECK_RETURN (0);
01585 
01586       if (!flag)
01587         return 0;
01588     }
01589 
01590   return 1; // success
01591 }

CORBA::Boolean CORBA_TypeCode::private_equal_objref CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of objrefs.

Definition at line 976 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, id, name, ACE_OS_String::strcmp, and ACE_OS_String::strlen.

Referenced by private_equal.

00981 {
00982   // compare the repoID and name, of which the name is optional as per GIOP
00983   // spec. However, the repoID is mandatory.
00984   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
00985   ACE_CHECK_RETURN (0);
00986 
00987   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
00988   ACE_CHECK_RETURN (0);
00989 
00990   if (!ACE_OS::strcmp (my_id, tc_id))
00991     {
00992       // Equality of repoIDs is sufficient for equivalence.
00993       if (equiv_only)
00994         {
00995           return 1;
00996         }
00997       // Name check is skipped by equivalent().
00998       else
00999         {
01000           // same repository IDs. Now check their names
01001           const char *myname = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01002           ACE_CHECK_RETURN (0);
01003 
01004           const char *tcname = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01005           ACE_CHECK_RETURN (0);
01006 
01007           if ((ACE_OS::strlen (myname) > 1) &&
01008               (ACE_OS::strlen (tcname) > 1))
01009             {
01010               // both of them specify names, compare them
01011               if (!ACE_OS::strcmp (myname, tcname))
01012                 return 1; // success
01013               else
01014                 return 0; // failed
01015             }
01016           return 1; // success
01017         }
01018     }
01019   return 0; // failed
01020 }

CORBA::Boolean CORBA_TypeCode::private_equal_sequence CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of sequences.

Definition at line 1419 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, content_type, and length.

Referenced by private_equal, and private_equal_array.

01424 {
01425   // this involves comparing the typecodes of the element type as well
01426   // as the bounds
01427   CORBA::TypeCode_var my_elem = this->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
01428   ACE_CHECK_RETURN (0);
01429 
01430   CORBA::TypeCode_var tc_elem = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
01431   ACE_CHECK_RETURN (0);
01432 
01433   CORBA::Boolean status = my_elem->equ_common (tc_elem.in (),
01434                                                equiv_only
01435                                                 ACE_ENV_ARG_PARAMETER);
01436   ACE_CHECK_RETURN (0);
01437 
01438   if (!status)
01439     return 0;
01440 
01441   // now check if bounds are same
01442   CORBA::ULong my_len = this->length (ACE_ENV_SINGLE_ARG_PARAMETER);
01443   ACE_CHECK_RETURN (0);
01444 
01445   CORBA::ULong tc_len = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
01446   ACE_CHECK_RETURN (0);
01447 
01448   return (my_len == tc_len);
01449 }

CORBA::Boolean CORBA_TypeCode::private_equal_string CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of strings.

Definition at line 1385 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, and length.

Referenced by private_equal.

01390 {
01391   // compare the lengths
01392   CORBA::ULong my_len = this->length (ACE_ENV_SINGLE_ARG_PARAMETER);
01393   ACE_CHECK_RETURN (0);
01394 
01395   CORBA::ULong tc_len = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
01396   ACE_CHECK_RETURN (0);
01397 
01398   return (my_len == tc_len);
01399 }

CORBA::Boolean CORBA_TypeCode::private_equal_struct CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of structs.

Definition at line 1023 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, id, member_count, member_name, member_type, name, parent_, root_tc_base_, ACE_OS_String::strcmp, ACE_OS_String::strlen, and tc_base_.

Referenced by private_equal.

01028 {
01029   // For structs the repoID and names are optional. However, if provided,
01030   // we must compare them
01031   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01032   ACE_CHECK_RETURN (0);
01033 
01034   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01035   ACE_CHECK_RETURN (0);
01036 
01037   // compare repoIDs if they exist
01038   if (ACE_OS::strlen (my_id) > 1 && ACE_OS::strlen (tc_id) > 1)
01039     {
01040       if (ACE_OS::strcmp (my_id, tc_id)) // not same
01041         {
01042           return 0;
01043         }
01044       else
01045         {
01046           // Equality of repoIDs is sufficient for equivalence.
01047           if (equiv_only)
01048             return 1;
01049         }
01050     }
01051 
01052   // Skipped by equivalent().
01053   if (!equiv_only)
01054     {
01055       const char *my_name = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01056       ACE_CHECK_RETURN (0);
01057 
01058       const char *tc_name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01059       ACE_CHECK_RETURN (0);
01060 
01061       // Compare names if they exist.
01062       if (ACE_OS::strlen (my_name) > 1
01063           && ACE_OS::strlen (tc_name) > 1
01064           && ACE_OS::strcmp (my_name, tc_name)) // not same
01065         return 0;
01066     }
01067 
01068   // Check if the member count is same.
01069   CORBA::ULong my_count = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01070   ACE_CHECK_RETURN (0);
01071 
01072   CORBA::ULong tc_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01073   ACE_CHECK_RETURN (0);
01074 
01075   if (my_count != tc_count)
01076     return 0; // number of members don't match
01077 
01078   // The checks below tell if we have a recursive struct.
01079   CORBA::TypeCode_ptr par = this->parent_;
01080   if (par != 0)
01081     {
01082       if (this->tc_base_ == this->root_tc_base_)
01083         return 1;
01084 
01085       CORBA::TypeCode_ptr tc_par = tc->parent_;
01086       if (tc_par)
01087         {
01088           CORBA::TypeCode_ptr gpar = par->parent_;
01089           CORBA::TypeCode_ptr tc_gpar = tc_par->parent_;
01090           if (gpar != 0
01091               && tc_gpar != 0
01092               && this->tc_base_ == gpar->tc_base_
01093               && tc->tc_base_ == tc_gpar->tc_base_)
01094             return 1;
01095         }
01096     }
01097 
01098   for (CORBA::ULong i = 0; i < my_count; i++)
01099     {
01100       // Skipped by equivalent().
01101       if (!equiv_only)
01102         {
01103           const char *my_member_name =
01104             this->member_name (i ACE_ENV_ARG_PARAMETER);
01105           ACE_CHECK_RETURN (0);
01106 
01107           const char *tc_member_name =
01108             tc->member_name (i ACE_ENV_ARG_PARAMETER);
01109           ACE_CHECK_RETURN (0);
01110 
01111           if (ACE_OS::strlen (my_member_name) > 1
01112               && ACE_OS::strlen (tc_member_name) > 1
01113               && ACE_OS::strcmp (my_member_name,
01114                                  tc_member_name)) // not same
01115             {
01116               return 0;
01117             }
01118         }
01119 
01120       // now compare the typecodes of the members
01121       CORBA::TypeCode_var my_member_tc = this->member_type (i
01122                                                             ACE_ENV_ARG_PARAMETER);
01123       ACE_CHECK_RETURN (0);
01124 
01125       CORBA::TypeCode_var tc_member_tc = tc->member_type (i
01126                                                           ACE_ENV_ARG_PARAMETER);
01127       ACE_CHECK_RETURN (0);
01128 
01129       // One of our members may be recursive, but not through us.
01130       if (my_member_tc->parent_ != 0
01131           && my_member_tc->parent_ == tc_member_tc->parent_
01132           && my_member_tc->tc_base_ == tc_member_tc->tc_base_
01133           && my_member_tc->root_tc_base_ == tc_member_tc->root_tc_base_)
01134         {
01135           continue;
01136         }
01137 
01138       CORBA::Boolean flag =
01139         my_member_tc->equ_common (tc_member_tc.in (),
01140                                   equiv_only
01141                                   ACE_ENV_ARG_PARAMETER);
01142       ACE_CHECK_RETURN (0);
01143 
01144       if (!flag)
01145         {
01146           return 0;
01147         }
01148     }
01149 
01150   return 1; // success
01151 }

CORBA::Boolean CORBA_TypeCode::private_equal_union CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of unions.

Definition at line 1154 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, default_index, discriminator_type, id, member_count, member_name, member_type, name, parent_, root_tc_base_, ACE_OS_String::strcmp, ACE_OS_String::strlen, and tc_base_.

Referenced by private_equal.

01157 {
01158   // For unions the repoID and names are optional. However, if provided, we
01159   // must compare them
01160   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01161   ACE_CHECK_RETURN (0);
01162 
01163   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01164   ACE_CHECK_RETURN (0);
01165 
01166   // compare repoIDs if they exist
01167   if (ACE_OS::strlen (my_id) > 1 && ACE_OS::strlen (tc_id) > 1)
01168     {
01169       if (ACE_OS::strcmp (my_id, tc_id)) // not same
01170         {
01171           return 0;
01172         }
01173       else
01174         {
01175           // Equality of repoIDs is sufficient for equivalence.
01176           if (equiv_only)
01177             return 1;
01178         }
01179     }
01180 
01181   // Skipped by equivalent().
01182   if (!equiv_only)
01183     {
01184       const char *my_name = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01185       ACE_CHECK_RETURN (0);
01186 
01187       const char *tc_name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01188       ACE_CHECK_RETURN (0);
01189 
01190       // Compare names if they exist.
01191       if (ACE_OS::strlen (my_name) > 1
01192           && ACE_OS::strlen (tc_name) > 1
01193           && ACE_OS::strcmp (my_name,
01194                              tc_name)) // not same
01195         return 0;
01196     }
01197 
01198   // check if the discriminant type is same
01199   CORBA::TypeCode_var my_discrim =
01200     this->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER);
01201   ACE_CHECK_RETURN (0);
01202 
01203   CORBA::TypeCode_var tc_discrim =
01204     tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER);
01205   ACE_CHECK_RETURN (0);
01206 
01207   CORBA::Boolean status = my_discrim->equ_common (tc_discrim.in (),
01208                                                   equiv_only
01209                                                    ACE_ENV_ARG_PARAMETER);
01210   ACE_CHECK_RETURN (0);
01211 
01212   if (!status)
01213     return 0;
01214 
01215   // check the default used
01216   CORBA::Long my_default = this->default_index (ACE_ENV_SINGLE_ARG_PARAMETER);
01217   ACE_CHECK_RETURN (0);
01218 
01219   CORBA::Long tc_default = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER);
01220   ACE_CHECK_RETURN (0);
01221 
01222   if (my_default != tc_default)
01223     return 0;
01224 
01225   // check if the member count is same
01226   CORBA::ULong my_count = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01227   ACE_CHECK_RETURN (0);
01228 
01229   CORBA::ULong tc_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01230   ACE_CHECK_RETURN (0);
01231 
01232   if (my_count != tc_count)
01233     return 0; // number of members don't match
01234 
01235   // The checks below indicate that we have a recursive union.
01236   CORBA::TypeCode_ptr par = this->parent_;
01237   if (par != 0)
01238     {
01239       if (this->tc_base_ == this->root_tc_base_)
01240         return 1;
01241 
01242       CORBA::TypeCode_ptr tc_par = tc->parent_;
01243       if (tc_par)
01244         {
01245           CORBA::TypeCode_ptr gpar = par->parent_;
01246           CORBA::TypeCode_ptr tc_gpar = tc_par->parent_;
01247           if (gpar != 0
01248               && tc_gpar != 0
01249               && this->tc_base_ == gpar->tc_base_
01250               && tc->tc_base_ == tc_gpar->tc_base_)
01251             return 1;
01252         }
01253     }
01254 
01255   for (CORBA::ULong i = 0; i < my_count; i++)
01256     {
01257       // First check if labels are same.
01258 
01259       // Check if member names are same - skipped by equivalent().
01260       if (!equiv_only)
01261         {
01262           const char *my_member_name = this->member_name (i
01263                                                            ACE_ENV_ARG_PARAMETER);
01264           ACE_CHECK_RETURN (0);
01265 
01266           const char *tc_member_name = tc->member_name (i
01267                                                          ACE_ENV_ARG_PARAMETER);
01268           ACE_CHECK_RETURN (0);
01269 
01270           if (ACE_OS::strlen (my_member_name) > 1
01271               && ACE_OS::strlen (tc_member_name) > 1
01272               && ACE_OS::strcmp (my_member_name,
01273                                  tc_member_name)) // not same
01274             return 0;
01275         }
01276 
01277       // now compare the typecodes of the members
01278       CORBA::TypeCode_var my_member_tc = this->member_type (i
01279                                                              ACE_ENV_ARG_PARAMETER);
01280       ACE_CHECK_RETURN (0);
01281 
01282       CORBA::TypeCode_var tc_member_tc = tc->member_type (i
01283                                                            ACE_ENV_ARG_PARAMETER);
01284       ACE_CHECK_RETURN (0);
01285 
01286       // One of our members may be recursive, but not through us.
01287       if (my_member_tc->parent_ != 0
01288           && my_member_tc->parent_ == tc_member_tc->parent_
01289           && my_member_tc->tc_base_ == tc_member_tc->tc_base_
01290           && my_member_tc->root_tc_base_ == tc_member_tc->root_tc_base_)
01291         continue;
01292 
01293       CORBA::Boolean flag = my_member_tc->equ_common (tc_member_tc.in (),
01294                                                       equiv_only
01295                                                        ACE_ENV_ARG_PARAMETER);
01296       ACE_CHECK_RETURN (0);
01297 
01298       if (!flag)
01299         return 0;
01300     }
01301 
01302   return 1; // success
01303 }

CORBA::Boolean CORBA_TypeCode::private_equal_valuetype CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of exceptions.

Definition at line 1596 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, id, name, ACE_OS_String::strcmp, and ACE_OS_String::strlen.

Referenced by private_equal.

01601 {
01602   // compare the repoID and name, of which the name is optional as per GIOP
01603   // spec. However, the repoID is mandatory.
01604   const char *my_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01605   ACE_CHECK_RETURN (0);
01606 
01607   const char *tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
01608   ACE_CHECK_RETURN (0);
01609 
01610   if (!ACE_OS::strcmp (my_id, tc_id))
01611     {
01612       // Equality of repoIDs is sufficient for equivalence.
01613       if (equiv_only)
01614         {
01615           return 1;
01616         }
01617       // Name check is skipped by equivalent().
01618       else
01619         {
01620           // same repository IDs. Now check their names
01621           const char *myname = this->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01622           ACE_CHECK_RETURN (0);
01623 
01624           const char *tcname = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
01625           ACE_CHECK_RETURN (0);
01626 
01627           if ((ACE_OS::strlen (myname) > 1) &&
01628               (ACE_OS::strlen (tcname) > 1))
01629             {
01630               // both of them specify names, compare them
01631               if (!ACE_OS::strcmp (myname, tcname))
01632                 return 1; // success
01633               else
01634                 return 0; // failed
01635             }
01636           return 1; // success
01637         }
01638     }
01639   return 0; // failed
01640 }

CORBA::Boolean CORBA_TypeCode::private_equal_wstring CORBA::TypeCode_ptr    tc,
CORBA::Boolean equiv_only    ACE_ENV_ARG_DECL_WITH_DEFAULTS
const [private]
 

test equality for typecodes of wide strings.

Definition at line 1402 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, and length.

Referenced by private_equal.

01407 {
01408   // compare the lengths
01409   CORBA::ULong my_len = this->length (ACE_ENV_SINGLE_ARG_PARAMETER);
01410   ACE_CHECK_RETURN (0);
01411 
01412   CORBA::ULong tc_len = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
01413   ACE_CHECK_RETURN (0);
01414 
01415   return (my_len == tc_len);
01416 }

const char * CORBA_TypeCode::private_id ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

For tk_{objref,struct,union,enum,alias,except}. Returns the repository ID, raises BadKind.

Definition at line 1650 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, buffer_, kind_, private_state_, TAO_SYNCH_MUTEX, TC_Private_State::tc_id_, and TC_Private_State::tc_id_known_.

Referenced by id.

01651 {
01652   switch (this->kind_)
01653     {
01654       // These are all complex typecodes, which have as their first
01655       // parameter (number zero) a repository/type ID string encoded
01656       // per CDR rules.  That means we can just return a pointer to
01657       // that string directly!
01658 
01659     case CORBA::tk_objref:
01660     case CORBA::tk_struct:
01661     case CORBA::tk_union:
01662     case CORBA::tk_enum:
01663     case CORBA::tk_alias:
01664     case CORBA::tk_except:
01665     case CORBA::tk_value:
01666       {
01667         // Double checked locking...
01668         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
01669                           this->private_state_->mutex_, 0);
01670         if (this->private_state_->tc_id_known_)
01671           return this->private_state_->tc_id_;
01672 
01673         this->private_state_->tc_id_known_ = 1;
01674         this->private_state_->tc_id_ = (ACE_const_cast (char *, buffer_)
01675                                         + 4    // skip byte order
01676                                         // flag and padding
01677                                         + 4);  // skip (strlen + 1)
01678         return this->private_state_->tc_id_; // this is OK because
01679                                              // strings in the CDR stream
01680                                              // are NULL terminated
01681       }
01682     // No other typecodes ever have type IDs
01683     default:
01684       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0);
01685     }
01686 }

CORBA::Long CORBA_TypeCode::private_length ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

Returns length, raises (BadKind). Used for tk_string, tk_sequence, and tk_array.

Definition at line 2617 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, kind_, private_state_, ACE_InputCDR::read_ulong, skip_typecode, TAO_SYNCH_MUTEX, TC_Private_State::tc_length_, and TC_Private_State::tc_length_known_.

Referenced by length.

02618 {
02619   TAO_InputCDR stream (this->buffer_+4, this->length_-4,
02620                        this->byte_order_);
02621   switch (this->kind_)
02622     {
02623     case CORBA::tk_sequence:
02624     case CORBA::tk_array:
02625       {
02626         // Double checked locking...
02627         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02628                           this->private_state_->mutex_, 0);
02629         if (this->private_state_->tc_length_known_)
02630           return this->private_state_->tc_length_;
02631 
02632         // skip the typecode of the element and get the bounds
02633         if (!this->skip_typecode (stream) // skip typecode
02634             || !stream.read_ulong (this->private_state_->tc_length_))
02635           ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0);
02636         else
02637           {
02638             this->private_state_->tc_length_known_ = 1;
02639             return this->private_state_->tc_length_;
02640           }
02641       }
02642       ACE_NOTREACHED (break);
02643 
02644     case CORBA::tk_string:
02645     case CORBA::tk_wstring:
02646       {
02647         // Double checked locking...
02648         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02649                           this->private_state_->mutex_, 0);
02650         if (this->private_state_->tc_length_known_)
02651           return this->private_state_->tc_length_;
02652 
02653         if (stream.read_ulong (this->private_state_->tc_length_))
02654           {
02655             this->private_state_->tc_length_known_ = 1;
02656             return this->private_state_->tc_length_;
02657           }
02658         else
02659           ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0);
02660       }
02661       ACE_NOTREACHED (break);
02662 
02663     default:
02664       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (),
02665                         0);
02666     }
02667   ACE_NOTREACHED (return 0);
02668 }

CORBA::ULong CORBA_TypeCode::private_member_count ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

returns member_count (), raises (BadKind). Useful for tk_struct, tk_union, tk_enum, tk_alias, and tk_except.

Definition at line 1744 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, private_state_, ACE_InputCDR::read_ulong, ACE_InputCDR::skip_bytes, ACE_InputCDR::skip_long, ACE_InputCDR::skip_string, skip_typecode, TAO_SYNCH_MUTEX, TC_Private_State::tc_member_count_, and TC_Private_State::tc_member_count_known_.

Referenced by member_count.

01745 {
01746   switch (kind_)
01747     {
01748     case CORBA::tk_alias:
01749       return 1;
01750 
01751     case CORBA::tk_enum:
01752     case CORBA::tk_except:
01753     case CORBA::tk_struct:
01754       {
01755         // Double checked locking...
01756         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
01757                           guard,
01758                           this->private_state_->mutex_,
01759                           0);
01760         if (this->private_state_->tc_member_count_known_)
01761           return this->private_state_->tc_member_count_;
01762 
01763         CORBA::ULong members;
01764         // setup an encapsulation
01765         TAO_InputCDR stream (this->buffer_+4,
01766                              this->length_-4,
01767                              this->byte_order_);
01768 
01769         // skip rest of header (type ID and name) and collect the
01770         // number of struct members
01771         if (!stream.skip_string ()          // ID
01772             || !stream.skip_string ()       // struct name
01773             || !stream.read_ulong (members))
01774           {
01775             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01776                               0);
01777           }
01778 
01779         this->private_state_->tc_member_count_known_ = 1;
01780         this->private_state_->tc_member_count_ = members;
01781         return this->private_state_->tc_member_count_;
01782       }
01783     case CORBA::tk_union:
01784       {
01785         // Double checked locking...
01786         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
01787                           guard,
01788                           this->private_state_->mutex_,
01789                           0);
01790         if (this->private_state_->tc_member_count_known_)
01791           {
01792             return this->private_state_->tc_member_count_;
01793           }
01794 
01795         CORBA::ULong members;
01796         // setup an encapsulation
01797         TAO_InputCDR stream (this->buffer_+4,
01798                              this->length_-4,
01799                              this->byte_order_);
01800 
01801         // skip rest of header (type ID, name, etc...) and collect the
01802         // number of struct members
01803         if (!stream.skip_string ()                    // ID
01804             || !stream.skip_string ()                 // struct name
01805             || !this->skip_typecode (stream)          // discriminant TC
01806             || !stream.read_ulong (members)           // default used
01807             || !stream.read_ulong (members))          // real member count
01808           {
01809             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01810                               0);
01811           }
01812 
01813         this->private_state_->tc_member_count_known_ = 1;
01814         this->private_state_->tc_member_count_ = members;
01815         return this->private_state_->tc_member_count_;
01816       }
01817     case CORBA::tk_value:
01818       {
01819         // Double checked locking...
01820         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
01821                           guard,
01822                           this->private_state_->mutex_,
01823                           0);
01824         if (this->private_state_->tc_member_count_known_)
01825           {
01826             return this->private_state_->tc_member_count_;
01827           }
01828 
01829         CORBA::ULong members;
01830         // setup an encapsulation
01831         TAO_InputCDR stream (this->buffer_+4,
01832                              this->length_-4,
01833                              this->byte_order_);
01834 
01835         // skip rest of header (type ID, name, etc) and collect the
01836         // number of value members
01837         CORBA::ULong tc_kind_holder;
01838         CORBA::TCKind tc_kind;
01839 
01840         // @@@ (JP) When the IDL compiler is updated to create typecodes
01841         // using a CDR stream, ValueModifier will have to be changed to
01842         // skip_short.
01843         if (!stream.skip_string ()          // ID
01844             || !stream.skip_string ()       // Name
01845             || !stream.skip_long ()         // ValueModifier
01846             || !stream.read_ulong (tc_kind_holder)) // Base's TCKind
01847           {
01848             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01849                               0);
01850           }
01851 
01852         tc_kind = ACE_static_cast (CORBA::TCKind, tc_kind_holder);
01853 
01854 
01855         // The tc_kind can be either tk_null or tk_value.
01856         // In the latter case we should skip encapsulation or
01857         // indirection - whatever comes in.
01858         CORBA::ULong encap_length;
01859 
01860         if (tc_kind != CORBA::tk_null)
01861           {
01862             if (!stream.read_ulong (encap_length))
01863               {
01864                 ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01865                                   0);
01866               }
01867 
01868             if (tc_kind_holder != 0xffffffff) // check for indirection
01869               {
01870                 if (!stream.skip_bytes (encap_length))
01871                   {
01872                     ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01873                                       0);
01874                   }
01875               }
01876           }
01877 
01878         // Now read member count.
01879         if (!stream.read_ulong (members))
01880           {
01881             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01882                               0);
01883           }
01884 
01885         this->private_state_->tc_member_count_known_ = 1;
01886         this->private_state_->tc_member_count_ = members;
01887         return this->private_state_->tc_member_count_;
01888       }
01889     default:
01890       ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01891                         0);
01892     }
01893 
01894   ACE_NOTREACHED (return 0);
01895 }

CORBA::Any_ptr CORBA_TypeCode::private_member_label CORBA::ULong   ACE_ENV_ARG_DECL_WITH_DEFAULTS const [private]
 

For tk_union. Returns the label. Raises BadKind, Bounds.

Definition at line 2377 of file Typecode.cpp.

References ACE_CDR_BYTE_ORDER, ACE_CHECK_RETURN, ACE_DEBUG, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR, ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_TEXT, ACE_THROW_RETURN, ACE_OutputCDR::begin, ACE_Allocator::instance, kind_, LM_DEBUG, LM_ERROR, ACE_CDR::MAX_ALIGNMENT, member_count, TAO_Marshal_Object::perform_append, TAO_Marshal_Object::perform_skip, private_discriminator_type_i, private_state_, ACE_InputCDR::rd_ptr, ACE_InputCDR::read_ulong, ACE_InputCDR::skip_string, skip_typecode, TAO_SYNCH_MUTEX, TC_Private_State::tc_member_label_list_, TC_Private_State::tc_member_label_list_known_, and ACE_OutputCDR::write_octet.

02379 {
02380   // this function is only applicable to the CORBA::tk_union TC
02381   if (this->kind_ != CORBA::tk_union)
02382     ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0);
02383 
02384   TAO_InputCDR stream (this->buffer_+4,
02385                        this->length_-4,
02386                        this->byte_order_);
02387 
02388   // skip ID and name
02389   if (!stream.skip_string ()       // type ID, hidden
02390       || !stream.skip_string ()    // typedef name
02391       || !this->skip_typecode (stream))  // skip discriminant typecode
02392     ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0);
02393 
02394       // skip default used, and get member count
02395   CORBA::ULong member_count;
02396 
02397   if (!stream.read_ulong (member_count)      // default used
02398       || !stream.read_ulong (member_count))  // member count
02399     {
02400       ACE_DEBUG ((LM_DEBUG,
02401                   ACE_TEXT ("TypeCode::private_member_label -- ")
02402                   ACE_TEXT ("error reading from stream")));
02403     ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
02404     }
02405 
02406   // Double checked locking...
02407   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02408                     this->private_state_->mutex_, 0);
02409   if (this->private_state_->tc_member_label_list_known_)
02410     if (n < member_count)
02411       return this->private_state_->tc_member_label_list_[n];
02412     else
02413       ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0);
02414 
02415   // member labels are of type Any. However, the actual types are
02416   // restricted to simple types
02417 
02418 
02419   // @@EXC@@ We should use Auto_Ptr_Array to make this exception
02420   // safe.
02421   CORBA::Any_ptr* label_list;
02422   ACE_NEW_THROW_EX (label_list,
02423                     CORBA::Any_ptr [member_count],
02424                     CORBA::NO_MEMORY ());
02425   ACE_CHECK_RETURN (0);
02426 
02427   // get the discriminant TC
02428   CORBA::TypeCode_ptr disc_tc =
02429     this->private_discriminator_type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
02430   ACE_CHECK_RETURN (0);
02431 
02432   for (CORBA::ULong i = 0; i < member_count; i++)
02433     {
02434       // Create an any from the portion of the CDR stream created
02435       // above.....
02436 
02437       // @@ This code assumes that the stream is a single message
02438       //    block, this is perfectly OK [the stream is created from a
02439       //    single buffer], but we may need to change this if the
02440       //    stream creation changes. [Carlos]
02441       TAO_InputCDR temp (stream);
02442 
02443       char *begin = stream.rd_ptr ();
02444       int retval =
02445         TAO_Marshal_Object::perform_skip (disc_tc,
02446                                           &temp
02447                                            ACE_ENV_ARG_PARAMETER);
02448       ACE_CHECK_RETURN (0);
02449 
02450       if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE)
02451         {
02452           return 0;
02453         }
02454 
02455       char* end = temp.rd_ptr ();
02456 
02457       // We need to allocate more memory than in the original
02458       // stream, first to guarantee that the buffer is aligned in
02459       // memory and next because the realignment may introduce
02460       // extra padding. 2*MAX_ALIGNMENT should be enough.
02461       // @@EXC@@ This doesn't seem to be exception safe.
02462       TAO_OutputCDR out (end - begin + 2 * ACE_CDR::MAX_ALIGNMENT,
02463                          ACE_CDR_BYTE_ORDER,
02464                          ACE_Allocator::instance (),
02465                          ACE_Allocator::instance (),
02466                          ACE_Allocator::instance ());
02467 
02468       CORBA::TypeCode_ptr label_tc;
02469 
02470       // If we are computing the label for the default index,
02471       // the label must contain an octet value of 0.
02472       if (i == (ACE_static_cast (CORBA::ULong,
02473                                  this->private_default_index_i ())))
02474         {
02475           label_tc = CORBA::_tc_octet;
02476 
02477           if (out.write_octet (ACE_static_cast (CORBA::Octet, 0)) == 0)
02478             {
02479               return 0;
02480             }
02481 
02482           retval =
02483             TAO_Marshal_Object::perform_skip (disc_tc,
02484                                               &stream
02485                                                ACE_ENV_ARG_PARAMETER);
02486           ACE_CHECK_RETURN (0);
02487 
02488           if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE)
02489             {
02490               return 0;
02491             }
02492         }
02493       else
02494         {
02495           label_tc = disc_tc;
02496 
02497           retval =
02498             TAO_Marshal_Object::perform_append (label_tc,
02499                                                 &stream,
02500                                                 &out
02501                                                  ACE_ENV_ARG_PARAMETER);
02502           ACE_CHECK_RETURN (0);
02503 
02504           if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE)
02505             {
02506               return 0;
02507             }
02508         }
02509 
02510       ACE_NEW_THROW_EX (label_list[i],
02511                         CORBA::Any (label_tc,
02512                                     0,
02513                                     ACE_CDR_BYTE_ORDER,
02514                                     out.begin ()),
02515                         CORBA::NO_MEMORY ());
02516       ACE_CHECK_RETURN (0);
02517 
02518       if (stream.skip_string () == 0
02519           || this->skip_typecode (stream) == 0)
02520         {
02521           if (TAO_debug_level > 0)
02522             ACE_ERROR ((LM_ERROR,
02523                         ACE_TEXT ("TypeCode::private_member_label ")
02524                         ACE_TEXT ("error getting typecode for member %d\n"),
02525                         i));
02526           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02527                             0);
02528         }
02529     }
02530 
02531   this->private_state_->tc_member_label_list_ = label_list;
02532   this->private_state_->tc_member_label_list_known_ = 1;
02533 
02534   // If caller asked for the label for a nonexistent member, they get
02535   // an error report!
02536   if (n >= member_count)
02537     ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0);
02538 
02539   return this->private_state_->tc_member_label_list_[n];
02540 }

const char * CORBA_TypeCode::private_member_name CORBA::ULong slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS const [private]
 

returns member_name (...), raises (BadKind, Bounds); Useful for tk_union, tk_struct, tk_except, and tk_enum.

Definition at line 2222 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_THROW_RETURN, member_count, TAO_Marshal_Object::perform_skip, private_discriminator_type_i, private_state_, ACE_InputCDR::read_string, ACE_InputCDR::read_ulong, ACE_InputCDR::skip_string, skip_typecode, TAO_SYNCH_MUTEX, TC_Private_State::tc_member_name_list_, and TC_Private_State::tc_member_name_list_known_.

Referenced by member_name.

02224 {
02225   CORBA::ULong temp, mcount;
02226 
02227   // Build the de-encapsulating CDR stream, bypassing the stringent
02228   // alignment tests (we're a bit looser in what we need here, and we
02229   // _know_ we're OK).  Then skip the byte order code.
02230   TAO_InputCDR stream (this->buffer_+4, this->length_-4,
02231                        this->byte_order_);
02232   CORBA::TypeCode_var tc = 0;
02233 
02234   mcount = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
02235   // out of bounds
02236   ACE_CHECK_RETURN ((char *)0);
02237 
02238   // Double checked locking...
02239   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02240                     this->private_state_->mutex_, 0);
02241 
02242   if (this->private_state_->tc_member_name_list_known_)
02243     if (slot < mcount)
02244       return this->private_state_->tc_member_name_list_[slot];
02245     else
02246       ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0);
02247 
02248   // the first time in. Precompute and store names of all members
02249   // Allocate a list to hold the member names
02250   ACE_NEW_THROW_EX (this->private_state_->tc_member_name_list_,
02251                     char* [mcount],
02252                     CORBA::NO_MEMORY ());
02253   ACE_CHECK_RETURN (0);
02254   // this->private_state_->tc_member_name_list_ = new char* [mcount];
02255 
02256   if (this->private_state_->tc_member_name_list_ == 0)
02257       // no memory for the member_list
02258       ACE_THROW_RETURN (CORBA::NO_MEMORY (), (char *)0);
02259 
02260   switch (kind_)
02261     {
02262     case CORBA::tk_enum:
02263       {
02264         // skip the id, name, and member_count part
02265         if (!stream.skip_string ()     // type ID, hidden
02266             || !stream.skip_string ()     // enum name
02267             || !stream.read_ulong (temp)) // member count
02268           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), (char *)0);
02269 
02270         // compute the typecodes for all the members and
02271         // return the required one.
02272         for (CORBA::ULong i = 0; i < mcount; i++)
02273           // now read this name
02274           if (!stream.read_string (
02275                       this->private_state_->tc_member_name_list_ [i]
02276                       ))
02277             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), (char *)0);
02278 
02279         this->private_state_->tc_member_name_list_known_ = 1;
02280 
02281         if (slot < mcount)
02282           return this->private_state_->tc_member_name_list_[slot];
02283         else
02284           ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), (char *)0);
02285       }
02286       ACE_NOTREACHED (break;)
02287 
02288     case CORBA::tk_except:
02289     case CORBA::tk_struct:              // index from 0
02290       {
02291         // skip the id, name, and member_count part
02292         if (!stream.skip_string ()        // type ID, hidden
02293             || !stream.skip_string ()     // struct/except name
02294             || !stream.read_ulong (temp)) // member count
02295           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), (char *)0);
02296 
02297         // compute the typecodes for all the members and
02298           // return the required one.
02299         for (CORBA::ULong i = 0; i < mcount; i++)
02300           {
02301             if (!stream.read_string (
02302                    this->private_state_->tc_member_name_list_ [i]
02303                    )
02304               || !this->skip_typecode (stream))
02305             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
02306           }
02307 
02308         this->private_state_->tc_member_name_list_known_ = 1;
02309 
02310         if (slot < mcount)
02311           return this->private_state_->tc_member_name_list_[slot];
02312         else
02313           ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), (char *)0);
02314 
02315       }
02316       ACE_NOTREACHED (break;)
02317 
02318     case CORBA::tk_union:            // index from 0
02319       {
02320         // skip the id, name, and discrimant type part
02321         if (!stream.skip_string ()             // type ID, hidden
02322             || !stream.skip_string ()          // typedef name
02323             || !this->skip_typecode (stream))  // skip discriminant typecode
02324           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), (char *)0);
02325         else if (!stream.read_ulong (temp)     // default used
02326                  || !stream.read_ulong (temp)) // member count
02327           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
02328         else
02329           {
02330             // get the typecode for the discriminator
02331             CORBA::TypeCode_ptr disc_tc =
02332               this->private_discriminator_type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
02333             // compute the name for all the members and return the
02334             // required one
02335             ACE_CHECK_RETURN (0);
02336 
02337             for (CORBA::ULong i = 0; i < mcount; i++)
02338               {
02339                 // the ith entry will have the name of the ith member
02340                 CORBA::TypeCode::traverse_status status =
02341                   TAO_Marshal_Object::perform_skip (disc_tc,
02342                                                     &stream
02343                                                      ACE_ENV_ARG_PARAMETER);
02344                 ACE_CHECK_RETURN (0);
02345 
02346                 if (status != CORBA::TypeCode::TRAVERSE_CONTINUE)
02347                   ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), 0);
02348 
02349                 // skip typecode for member
02350                 if (!stream.read_string (
02351                          this->private_state_->tc_member_name_list_ [i]
02352                        )
02353                     || (!this->skip_typecode (stream))) // skip typecode
02354                   ACE_THROW_RETURN ( CORBA::BAD_TYPECODE (), 0);
02355               }
02356 
02357             this->private_state_->tc_member_name_list_known_ = 1;
02358 
02359             if (slot < mcount)
02360               return this->private_state_->tc_member_name_list_[slot];
02361             else
02362               ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), (char *)0);
02363 
02364           }
02365       }
02366       ACE_NOTREACHED (break;)
02367 
02368     default:
02369       // bad kind
02370       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), (char *)0);
02371     }
02372   ACE_NOTREACHED (return (char *)0;)
02373 }

CORBA::TypeCode_ptr CORBA_TypeCode::private_member_type CORBA::ULong slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS const [private]
 

returns member_type (...), raises (BadKind, Bounds); Useful for tk_struct, tk_union, and tk_except.

Definition at line 1902 of file Typecode.cpp.

References _tao_decode, ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_THROW_RETURN, member_count, member_type, TAO_Marshal_Object::perform_skip, private_discriminator_type_i, private_state_, ACE_InputCDR::read_ulong, ACE_InputCDR::skip_bytes, ACE_InputCDR::skip_long, ACE_InputCDR::skip_string, skip_typecode, ACE_InputCDR::skip_ulong, TAO_SYNCH_MUTEX, TC_Private_State::tc_member_type_list_, and TC_Private_State::tc_member_type_list_known_.

01904 {
01905   CORBA::ULong temp, mcount;
01906 
01907   // Build the de-encapsulating CDR stream, bypassing the stringent
01908   // alignment tests (we're a bit looser in what we need here, and we
01909   // _know_ we're OK).  Then skip the byte order code.
01910   TAO_InputCDR stream (this->buffer_+4,
01911                        this->length_-4,
01912                        this->byte_order_);
01913   CORBA::TypeCode_var tc = 0;
01914 
01915   switch (kind_)
01916     {
01917     case CORBA::tk_except:
01918     case CORBA::tk_struct:              // index from 0
01919       mcount = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01920       ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
01921 
01922       {
01923         // Double checked locking...
01924         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
01925                           guard,
01926                           this->private_state_->mutex_,
01927                           CORBA::TypeCode::_nil ());
01928         if (this->private_state_->tc_member_type_list_known_)
01929           {
01930             if (slot < mcount)
01931               {
01932                 return  this->private_state_->tc_member_type_list_[slot];
01933               }
01934             else
01935               {
01936                 ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
01937                                   CORBA::TypeCode::_nil ());
01938               }
01939           }
01940 
01941         // the first time in. Precompute and store types of all members
01942 
01943         // Allocate a list to hold the member typecodes
01944         ACE_NEW_THROW_EX (this->private_state_->tc_member_type_list_,
01945                           CORBA::TypeCode_ptr[mcount],
01946                           CORBA::NO_MEMORY ());
01947         ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
01948 
01949         // skip the id, name, and member_count part
01950         if (!stream.skip_string ()        // type ID, hidden
01951             || !stream.skip_string ()     // typedef name
01952             || !stream.read_ulong (temp))  // member count
01953           {
01954             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01955                               CORBA::TypeCode::_nil ());
01956           }
01957 
01958         // compute the typecodes for all the members and
01959         // return the required one.
01960         for (CORBA::ULong i = 0; i < mcount; ++i)
01961           // the ith entry will have the typecode of the ith guy
01962           {
01963             if (!stream.skip_string ())  // skip the name
01964               {
01965                 ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
01966                                   CORBA::TypeCode::_nil ());
01967               }
01968 
01969             CORBA::TypeCode_ptr& member_type =
01970               this->private_state_->tc_member_type_list_[i];
01971             CORBA_TypeCode::_tao_decode (this,
01972                                          stream,
01973                                          member_type
01974                                          ACE_ENV_ARG_PARAMETER);
01975             ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
01976           }
01977 
01978         this->private_state_->tc_member_type_list_known_ = 1;
01979 
01980         if (slot < mcount)
01981           {
01982             return this->private_state_->tc_member_type_list_[slot];
01983           }
01984         else
01985           {
01986             ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
01987                               CORBA::TypeCode::_nil ());
01988           }
01989       }
01990 
01991       ACE_NOTREACHED (break;)
01992 
01993     case CORBA::tk_union:            // index from 0
01994       mcount = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
01995       ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
01996 
01997       {
01998         // Double checked locking...
01999         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
02000                           guard,
02001                           this->private_state_->mutex_,
02002                           CORBA::TypeCode::_nil ());
02003         if (this->private_state_->tc_member_type_list_known_)
02004           {
02005             if (slot < mcount)
02006               {
02007                 return  this->private_state_->tc_member_type_list_[slot];
02008               }
02009             else
02010               {
02011                 ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
02012                                   CORBA::TypeCode::_nil ());
02013               }
02014           }
02015 
02016         // the first time in. Precompute and store types of all members
02017         ACE_NEW_THROW_EX (this->private_state_->tc_member_type_list_,
02018                           CORBA::TypeCode_ptr[mcount],
02019                           CORBA::NO_MEMORY ());
02020         ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02021 
02022         // skip the id, name, and discrimant type part
02023         if (!stream.skip_string ()              // type ID, hidden
02024             || !stream.skip_string ()           // typedef name
02025             || !this->skip_typecode (stream))   // skip discriminant typecode
02026           {
02027             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02028                               CORBA::TypeCode::_nil ());
02029           }
02030         else if (!stream.read_ulong (temp)      // default used
02031                  || !stream.read_ulong (temp))  // member count
02032           {
02033             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02034                               CORBA::TypeCode::_nil ());
02035           }
02036 
02037         // get the typecode for the discriminator
02038         CORBA::TypeCode_ptr disc_tc =
02039           this->private_discriminator_type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
02040         // compute the typecodes for all the members and return the
02041         // required one
02042         ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02043 
02044         for (CORBA::ULong i = 0; i < mcount; i++)
02045           // the ith entry will have the typecode of the ith guy
02046           {
02047             // skip member label
02048             CORBA::TypeCode::traverse_status status =
02049               TAO_Marshal_Object::perform_skip (disc_tc,
02050                                                 &stream
02051                                                 ACE_ENV_ARG_PARAMETER);
02052             ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02053 
02054             if (status != CORBA::TypeCode::TRAVERSE_CONTINUE
02055                 || !stream.skip_string ())  // skip the name
02056               {
02057                 ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02058                                   CORBA::TypeCode::_nil ());
02059               }
02060 
02061             CORBA::TypeCode_ptr& member_type =
02062               this->private_state_->tc_member_type_list_[i];
02063             CORBA_TypeCode::_tao_decode (this,
02064                                          stream,
02065                                          member_type
02066                                          ACE_ENV_ARG_PARAMETER);
02067             ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02068           }
02069 
02070         this->private_state_->tc_member_type_list_known_ = 1;
02071 
02072         if (slot < mcount)
02073           {
02074             return this->private_state_->tc_member_type_list_[slot];
02075           }
02076         else
02077           {
02078             ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
02079                               CORBA::TypeCode::_nil ());
02080           }
02081       }
02082 
02083       ACE_NOTREACHED (break);
02084 
02085     case CORBA::tk_value:
02086       mcount = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
02087       ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02088 
02089       {
02090         // Double checked locking...
02091         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
02092                           guard,
02093                           this->private_state_->mutex_,
02094                           CORBA::TypeCode::_nil ());
02095 
02096         if (this->private_state_->tc_member_type_list_known_)
02097         {
02098           if (slot < mcount)
02099             {
02100               return  this->private_state_->tc_member_type_list_[slot];
02101             }
02102           else
02103             {
02104               ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
02105                                 CORBA::TypeCode::_nil ());
02106             }
02107         }
02108 
02109         // the first time in. Precompute and store types of all members
02110 
02111         // Allocate a list to hold the member typecodes
02112         ACE_NEW_THROW_EX (this->private_state_->tc_member_type_list_,
02113                           CORBA::TypeCode_ptr [mcount],
02114                           CORBA::NO_MEMORY ());
02115 
02116         ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02117 
02118         // skip rest of header (type ID, name, etc) and collect the
02119         // number of value members
02120         CORBA::ULong tc_kind_holder;
02121         CORBA::TCKind tc_kind;
02122 
02123         // @@@ (JP) When the IDL compiler is updated to create typecodes
02124         // using a CDR stream, ValueModifier will have to be changed to
02125         // skip_short.
02126         if (!stream.skip_string ()          // ID
02127             || !stream.skip_string ()       // Name
02128             || !stream.skip_long ()         // ValueModifier
02129             || !stream.read_ulong (tc_kind_holder)) // Base's TCKind
02130           {
02131             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02132                               CORBA::TypeCode::_nil ());
02133           }
02134 
02135         tc_kind = ACE_static_cast (CORBA::TCKind, tc_kind_holder);
02136 
02137         // The tc_kind can be either tk_null or tk_value.
02138         // In the latter case we should skip encapsulation or
02139         // indirection - whatever comes in.
02140         CORBA::ULong encap_length;
02141 
02142         if (tc_kind != CORBA::tk_null)
02143           {
02144             if (!stream.read_ulong (encap_length))
02145               {
02146                 ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02147                                   CORBA::TypeCode::_nil ());
02148               }
02149 
02150             if (tc_kind_holder != 0xffffffff) // check for indirection
02151               {
02152                 if (!stream.skip_bytes (encap_length))
02153                   {
02154                     ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02155                                       CORBA::TypeCode::_nil ());
02156                   }
02157               }
02158           }
02159 
02160         // Now skip member count.
02161         if (!stream.skip_ulong ())
02162           {
02163             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02164                               CORBA::TypeCode::_nil ());
02165           }
02166 
02167         // compute the typecodes for all the members and
02168         // return the required one.
02169         for (CORBA::ULong i = 0; i < mcount; i++)
02170           // the ith entry will have the typecode of the ith guy
02171           {
02172             if (!stream.skip_string ())  // skip the name
02173               {
02174                 ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02175                                   CORBA::TypeCode::_nil ());
02176               }
02177 
02178             CORBA::TypeCode_ptr& member_type =
02179               this->private_state_->tc_member_type_list_[i];
02180             CORBA_TypeCode::_tao_decode (this,
02181                                          stream,
02182                                          member_type
02183                                          ACE_ENV_ARG_PARAMETER);
02184             ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
02185 
02186             // @@@ (JP) When the IDL compiler is updated to create typecodes
02187             // using a CDR stream, this will have to be changed to
02188             // skip_short.
02189             if (!stream.skip_long ())  // skip member visibility
02190               {
02191                 ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02192                                   CORBA::TypeCode::_nil ());
02193               }
02194           }
02195 
02196         this->private_state_->tc_member_type_list_known_ = 1;
02197 
02198         if (slot < mcount)
02199           {
02200             return this->private_state_->tc_member_type_list_[slot];
02201           }
02202         else
02203           {
02204             ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
02205                               CORBA::TypeCode::_nil ());
02206           }
02207       }
02208 
02209       ACE_NOTREACHED (break;)
02210 
02211     default:
02212       // bad kind
02213       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (),
02214                         CORBA::TypeCode::_nil ());
02215     }
02216 }

CORBA::Visibility CORBA_TypeCode::private_member_visibility CORBA::ULong slot    ACE_ENV_ARG_DECL_WITH_DEFAULTS const [private]
 

Returns the visibility (public/private) of the member at index 'slot'. Raises (BadKind, Bounds). Useful for tk_value only.

Definition at line 2728 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_THROW_RETURN, kind_, member_count, private_state_, ACE_InputCDR::read_short, ACE_InputCDR::skip_long, ACE_InputCDR::skip_string, skip_typecode, ACE_InputCDR::skip_ulong, TAO_SYNCH_MUTEX, TC_Private_State::tc_member_visibility_list_, and TC_Private_State::tc_member_visibility_list_known_.

Referenced by member_visibility.

02730 {
02731   if (this->kind_ != CORBA::tk_value)
02732     {
02733       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (),
02734                         CORBA::PRIVATE_MEMBER);
02735     }
02736 
02737   CORBA::ULong mcount = this->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
02738   ACE_CHECK_RETURN (CORBA::PRIVATE_MEMBER);
02739 
02740   if (slot >= mcount)
02741     {
02742       ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
02743                         CORBA::PRIVATE_MEMBER);
02744     }
02745 
02746   // Double checked locking...
02747   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02748                     this->private_state_->mutex_,
02749                     0);
02750 
02751   if (this->private_state_->tc_member_visibility_list_known_)
02752     {
02753       return this->private_state_->tc_member_visibility_list_[slot];
02754     }
02755 
02756   // Set up an encapsulation.
02757   TAO_InputCDR stream (this->buffer_+4,
02758                        this->length_-4,
02759                        this->byte_order_);
02760 
02761   // Skip rest of header (type ID, name, etc) and collect the
02762   // number of value members.
02763   // @@@ (JP) When the IDL compiler is updated to create typecodes
02764   // using a CDR stream, ValueModifier will have to be changed to
02765   // skip_short.
02766   if (!stream.skip_string ()              // ID
02767       || !stream.skip_string ()           // Name
02768       || !stream.skip_long ()             // ValueModifier
02769       || !this->skip_typecode (stream)    // Concrete base typecode
02770       || !stream.skip_ulong ())           // Member count
02771     {
02772       ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02773                         0);
02774     }
02775 
02776   ACE_NEW_THROW_EX (this->private_state_->tc_member_visibility_list_,
02777                     CORBA::Visibility[mcount],
02778                     CORBA::NO_MEMORY ());
02779   ACE_CHECK_RETURN (CORBA::PRIVATE_MEMBER);
02780 
02781   CORBA::Visibility tmp = CORBA::PRIVATE_MEMBER;
02782 
02783   for (CORBA::ULong i = 0; i < mcount; ++i)
02784     {
02785       if (!stream.skip_string ()              // Member name
02786           || !this->skip_typecode (stream)    // Member TypeCode
02787           || !stream.read_short (tmp))        // Read the member visibility
02788         {
02789           ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02790                             0);
02791         }
02792 
02793       this->private_state_->tc_member_visibility_list_[i] = tmp;
02794     }
02795 
02796   this->private_state_->tc_member_visibility_list_known_ = 1;
02797   return this->private_state_->tc_member_visibility_list_[slot];
02798 }

const char * CORBA_TypeCode::private_name ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

returns name (), raises (BadKind).

Definition at line 1690 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, kind_, private_state_, ACE_InputCDR::read_string, ACE_InputCDR::skip_string, TAO_SYNCH_MUTEX, TC_Private_State::tc_name_, and TC_Private_State::tc_name_known_.

Referenced by name.

01691 {
01692   switch (this->kind_)
01693     {
01694       // These are all complex typecodes, which have as their second
01695       // parameter (number one) a name string encoded per CDR rules.
01696       // That means we can just return a pointer to that string
01697       // directly!
01698 
01699     case CORBA::tk_objref:
01700     case CORBA::tk_struct:
01701     case CORBA::tk_union:
01702     case CORBA::tk_enum:
01703     case CORBA::tk_alias:
01704     case CORBA::tk_except:
01705     case CORBA::tk_value:
01706       {
01707         // Double checked locking...
01708         ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
01709                           this->private_state_->mutex_, 0);
01710         if (this->private_state_->tc_name_known_)
01711           return this->private_state_->tc_name_;
01712 
01713         // setup an encapsulation.
01714         TAO_InputCDR stream (this->buffer_ + 4,
01715                              this->length_ - 4,
01716                              this->byte_order_);
01717 
01718         // skip the typecode ID
01719         if (stream.skip_string ())  // ID
01720           {
01721             this->private_state_->tc_name_known_ = 1;
01722 
01723             // "Read" the string without copying.
01724             stream.read_string (this->private_state_->tc_name_);
01725 
01726             return this->private_state_->tc_name_;
01727           }
01728         else
01729           ACE_THROW_RETURN (CORBA::INTERNAL (), (char*)0);
01730       }
01731     // No other typecodes ever have type IDs.
01732     default:
01733       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), (char*)0);
01734     }
01735   ACE_NOTREACHED (return 0);
01736 }

CORBA::ValueModifier CORBA_TypeCode::private_type_modifier ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const [private]
 

Returns the value modifier. Raises (BadKind). Useful for tk_value only.

Definition at line 2801 of file Typecode.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, kind_, private_state_, ACE_InputCDR::read_short, ACE_InputCDR::skip_string, TAO_SYNCH_MUTEX, TC_Private_State::tc_type_modifier_, and TC_Private_State::tc_type_modifier_known_.

Referenced by type_modifier.

02802 {
02803   if (this->kind_ != CORBA::tk_value)
02804     {
02805       ACE_THROW_RETURN (CORBA::TypeCode::BadKind (),
02806                         0);
02807     }
02808 
02809   // Double checked locking...
02810   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard,
02811                     this->private_state_->mutex_,
02812                     0);
02813 
02814   if (this->private_state_->tc_type_modifier_known_)
02815     {
02816       return this->private_state_->tc_type_modifier_;
02817     }
02818 
02819   // Set up an encapsulation.
02820   TAO_InputCDR stream (this->buffer_+4,
02821                        this->length_-4,
02822                        this->byte_order_);
02823 
02824   // Skip rest of header (type ID, name, etc) and collect the
02825   // number of value members.
02826   if (!stream.skip_string ()          // ID
02827       || !stream.skip_string ())      // Name
02828     {
02829       ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02830                         0);
02831     }
02832 
02833   if (!stream.read_short (this->private_state_->tc_type_modifier_))
02834     {
02835       ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
02836                         0);
02837     }
02838 
02839   this->private_state_->tc_type_modifier_known_ = 1;
02840   return this->private_state_->tc_type_modifier_;
02841 }

CORBA::Boolean CORBA_TypeCode::skip_typecode TAO_InputCDR   stream [static]
 

skip a typecode encoding in a given CDR stream. This is just a helper function.

Definition at line 537 of file Typecode.cpp.

References kind, ACE_InputCDR::read_ulong, and ACE_InputCDR::skip_bytes.

Referenced by param_count, private_default_index_i, private_length, private_member_count, private_member_label, private_member_name, private_member_type, and private_member_visibility.

00538 {
00539   CORBA::ULong kind;
00540   CORBA::ULong temp;
00541 
00542   if (stream.read_ulong (kind)
00543       && (kind < CORBA::TC_KIND_COUNT || kind == ~0u))
00544     {
00545 
00546       switch (kind)
00547         {
00548           // Most TypeCodes have empty parameter lists, nothing to skip
00549         default:
00550           break;
00551 
00552           // Some have single integer parameters, easy to skip.  Some have
00553           // preallocated constants that could be used.
00554         case CORBA::tk_string:
00555         case CORBA::tk_wstring:
00556         case ~0u:
00557           return (stream.read_ulong (temp) != 0);
00558 
00559           // The rest have "complex" parameter lists that are
00560           // encoded as bulk octets ... just skip them.
00561         case CORBA::tk_objref:
00562         case CORBA::tk_struct:
00563         case CORBA::tk_union:
00564         case CORBA::tk_enum:
00565         case CORBA::tk_sequence:
00566         case CORBA::tk_array:
00567         case CORBA::tk_alias:
00568         case CORBA::tk_except:
00569         case CORBA::tk_value:
00570           return (stream.read_ulong (temp) != 0
00571                   && stream.skip_bytes (temp) != 0);
00572         }
00573 
00574       return 1;
00575     }
00576   else
00577     return 0;
00578 }

CORBA::ValueModifier CORBA_TypeCode::type_modifier ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    const
 

Returns the value modifier. Raises (BadKind). Useful for tk_value only.

Definition at line 499 of file Typecode.cpp.

References ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_DECL, ACE_ENV_SINGLE_ARG_PARAMETER, private_state_, private_type_modifier, TC_Private_State::tc_type_modifier_, and TC_Private_State::tc_type_modifier_known_.

00500 {
00501   if (this->private_state_->tc_type_modifier_known_)
00502     {
00503       return this->private_state_->tc_type_modifier_;
00504     }
00505   else
00506     {
00507       CORBA::ValueModifier vm =
00508         this->private_type_modifier (ACE_ENV_SINGLE_ARG_PARAMETER);
00509       ACE_CHECK_RETURN (CORBA::VM_NONE);
00510 
00511       return vm;
00512     }
00513 }


Member Data Documentation

CORBA::TypeCode_ptr CORBA_TypeCode::_tc_BadKind [static]
 

Definition at line 103 of file Typecode.h.

CORBA::TypeCode_ptr CORBA_TypeCode::_tc_Bounds [static]
 

Definition at line 102 of file Typecode.h.

const char* CORBA_TypeCode::buffer_
 

the encapsulated stream.

Definition at line 257 of file Typecode.h.

Referenced by CORBA_TypeCode, private_id, and ~CORBA_TypeCode.

CORBA::Long CORBA_TypeCode::byte_order_
 

The byte order in the encapsulated stream.

Definition at line 260 of file Typecode.h.

Referenced by CORBA_TypeCode.

CORBA::Long CORBA_TypeCode::kind_
 

the TypeCode kind.

Definition at line 263 of file Typecode.h.

Referenced by content_type, CORBA_TypeCode, default_index, discriminator_type, equ_common, kind, length, param_count, private_concrete_base_type, private_equal, private_id, private_length, private_member_label, private_member_visibility, private_name, and private_type_modifier.

size_t CORBA_TypeCode::length_
 

length of the encapsulated stream.

Definition at line 254 of file Typecode.h.

Referenced by CORBA_TypeCode.

char* CORBA_TypeCode::non_aligned_buffer_ [private]
 

Original buffer that may possibly be non-aligned. We still need a handle to the allocated memory so that all of it can be freed by the destructor.

Definition at line 485 of file Typecode.h.

Referenced by CORBA_TypeCode, and ~CORBA_TypeCode.

CORBA::Boolean CORBA_TypeCode::orb_owns_ [private]
 

TAO's approach differs from the SunSoft IIOP. Constant typecodes are owned by the ORB and get freed only when the ORB dies.

Definition at line 456 of file Typecode.h.

Referenced by CORBA_TypeCode.

CORBA::TypeCode_ptr CORBA_TypeCode::parent_
 

Indirected typecodes share "buffer" with a parent, and hold a reference to that parent to ensure its memory is not freed inappropriately.

Definition at line 270 of file Typecode.h.

Referenced by CORBA_TypeCode, private_equal_struct, and private_equal_union.

TC_Private_State* CORBA_TypeCode::private_state_ [private]
 

maintains precomputed state. We need a separate class that maintains the precomputed state since most of the TypeCode class operations keep the state of the object constant. However, for the purpose of precomputation, we need to update the state. We cannot update state directly in the TypeCode class as that defeats the constness. However, we can keep an object in our typecode class that remains constant, but we can update its state.

Definition at line 472 of file Typecode.h.

Referenced by concrete_base_type, content_type, CORBA_TypeCode, default_index, discriminator_type, id, length, member_count, member_name, member_type, member_visibility, name, private_concrete_base_type, private_content_type, private_default_index_i, private_discriminator_type_i, private_id, private_length, private_member_count, private_member_label, private_member_name, private_member_type, private_member_visibility, private_name, private_type_modifier, type_modifier, and ~CORBA_TypeCode.

CORBA::ULong CORBA_TypeCode::refcount_ [private]
 

if refcount reaches 0, free this typecode.

Definition at line 448 of file Typecode.h.

Referenced by _decr_refcnt, _incr_refcnt, and CORBA_TypeCode.

TAO_SYNCH_MUTEX CORBA_TypeCode::refcount_lock_ [private]
 

Protect the reference count, this is OK because we do no duplicates or releases on the critical path.

Definition at line 452 of file Typecode.h.

const char* CORBA_TypeCode::root_tc_base_
 

base of the topmost level typecode. Applicable only if I have any parents, else it is the same as tc_base. This helps in case we have indirections and we need to traverse beyond encapsulation boundaries.

Definition at line 284 of file Typecode.h.

Referenced by CORBA_TypeCode, private_equal_struct, and private_equal_union.

const char* CORBA_TypeCode::tc_base_
 

my typecode base. Notice that the buffer_ member points to my encapsulation. However, for indirected typecodes, the offsets will point to my tk_kind field which should be pointed to be tc_base_

Definition at line 277 of file Typecode.h.

Referenced by CORBA_TypeCode, private_equal_struct, and private_equal_union.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:01:59 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002