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

TAO_Marshal_Union Class Reference

TAO_Marshal_Union. More...

#include <Marshal.h>

Inheritance diagram for TAO_Marshal_Union:

Inheritance graph
[legend]
Collaboration diagram for TAO_Marshal_Union:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Marshal_Union (void)
virtual CORBA::TypeCode::traverse_status skip (CORBA::TypeCode_ptr tc, TAO_InputCDR *context ACE_ENV_ARG_DECL)
 skip operation. More...

virtual CORBA::TypeCode::traverse_status append (CORBA::TypeCode_ptr tc, TAO_InputCDR *src, TAO_OutputCDR *dest ACE_ENV_ARG_DECL)
 append operation. More...


Detailed Description

TAO_Marshal_Union.

marshal a union

Definition at line 255 of file Marshal.h.


Constructor & Destructor Documentation

ACE_INLINE TAO_Marshal_Union::TAO_Marshal_Union void   
 

Definition at line 39 of file Marshal.i.

00040 {
00041 }


Member Function Documentation

CORBA::TypeCode::traverse_status TAO_Marshal_Union::append CORBA::TypeCode_ptr    tc,
TAO_InputCDR   src,
TAO_OutputCDR *dest    ACE_ENV_ARG_DECL
[virtual]
 

append operation.

Implements TAO_Marshal_Object.

Definition at line 379 of file append.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, TAO_Marshal_Object::perform_append, ACE_InputCDR::read_boolean, ACE_InputCDR::read_char, ACE_InputCDR::read_long, ACE_InputCDR::read_short, ACE_InputCDR::read_ulong, ACE_InputCDR::read_ushort, and ACE_InputCDR::read_wchar.

Referenced by TAO_Marshal_Object::perform_append.

00383 {
00384   CORBA::TypeCode_var discrim_tc =
00385     tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00386   ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00387 
00388   CORBA::ULong kind =
00389     discrim_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00390   ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00391 
00392   // Save the discriminator value in a temporary variable...
00393   CORBA::Short short_v;
00394   CORBA::UShort ushort_v;
00395   CORBA::Long long_v;
00396   CORBA::ULong ulong_v;
00397   CORBA::ULong enum_v;
00398   CORBA::Char char_v;
00399   CORBA::WChar wchar_v;
00400   CORBA::Boolean boolean_v;
00401 
00402   switch (kind)
00403     {
00404     case CORBA::tk_short:
00405       {
00406         if (!src->read_short (short_v)
00407             || !dest->write_short (short_v))
00408           return CORBA::TypeCode::TRAVERSE_STOP;
00409       }
00410       break;
00411 
00412     case CORBA::tk_ushort:
00413       {
00414         if (!src->read_ushort (ushort_v)
00415             || !dest->write_ushort (ushort_v))
00416           return CORBA::TypeCode::TRAVERSE_STOP;
00417       }
00418       break;
00419 
00420     case CORBA::tk_long:
00421       {
00422         if (!src->read_long (long_v)
00423             || !dest->write_long (long_v))
00424           return CORBA::TypeCode::TRAVERSE_STOP;
00425       }
00426       break;
00427 
00428     case CORBA::tk_ulong:
00429       {
00430         if (!src->read_ulong (ulong_v)
00431             || !dest->write_ulong (ulong_v))
00432           return CORBA::TypeCode::TRAVERSE_STOP;
00433       }
00434       break;
00435 
00436     case CORBA::tk_enum:
00437       {
00438         if (!src->read_ulong (enum_v)
00439             || !dest->write_ulong (enum_v))
00440           return CORBA::TypeCode::TRAVERSE_STOP;
00441       }
00442       break;
00443 
00444     case CORBA::tk_char:
00445       {
00446         if (!src->read_char (char_v)
00447             || !dest->write_char (char_v))
00448           return CORBA::TypeCode::TRAVERSE_STOP;
00449       }
00450       break;
00451 
00452     case CORBA::tk_wchar:
00453       {
00454         if (!src->read_wchar (wchar_v)
00455             || !dest->write_wchar (wchar_v))
00456           return CORBA::TypeCode::TRAVERSE_STOP;
00457       }
00458       break;
00459 
00460     case CORBA::tk_boolean:
00461       {
00462         if (!src->read_boolean (boolean_v)
00463             || !dest->write_boolean (boolean_v))
00464           return CORBA::TypeCode::TRAVERSE_STOP;
00465       }
00466       break;
00467 
00468     default:
00469       return CORBA::TypeCode::TRAVERSE_STOP;
00470     }
00471 
00472   CORBA::ULong member_count =
00473     tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
00474   ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00475 
00476   const CORBA::ULong null_member = ~ACE_static_cast (CORBA::ULong, 0U);
00477 
00478   CORBA::ULong current_member = null_member;
00479   CORBA::ULong default_member = null_member;
00480 
00481   for (CORBA::ULong i = 0;
00482        i != member_count && current_member == null_member;
00483        ++i)
00484     {
00485       CORBA::Any_var any = tc->member_label (i
00486                                               ACE_ENV_ARG_PARAMETER);
00487       ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00488 
00489       CORBA::Octet o;
00490       if ((any >>= CORBA::Any::to_octet (o)) && o == 0)
00491         {
00492           CORBA::ULong default_index =
00493             tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER);
00494           ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00495 
00496           if (i != default_index)
00497             ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
00498                               CORBA::TypeCode::TRAVERSE_STOP);
00499           // Found the default branch, save its position and continue
00500           // trying to find the current value...
00501           default_member = i;
00502           continue;
00503         }
00504 
00505       switch (kind)
00506         {
00507         case CORBA::tk_short:
00508           {
00509             CORBA::Short d;
00510             if ((any >>= d) && d == short_v)
00511               current_member = i;
00512           }
00513           break;
00514 
00515         case CORBA::tk_ushort:
00516           {
00517             CORBA::UShort d;
00518             if ((any >>= d) && d == ushort_v)
00519               current_member = i;
00520           }
00521           break;
00522 
00523         case CORBA::tk_long:
00524           {
00525             CORBA::Long d;
00526             if ((any >>= d) && d == long_v)
00527               current_member = i;
00528           }
00529           break;
00530 
00531         case CORBA::tk_ulong:
00532           {
00533             CORBA::ULong d;
00534             if ((any >>= d) && d == ulong_v)
00535               current_member = i;
00536           }
00537           break;
00538 
00539         case CORBA::tk_enum:
00540           {
00541             CORBA::ULong d;
00542 
00543             // Create an special Any to handle this case.
00544             CORBA::Any tmp;
00545             tmp._tao_replace (CORBA::_tc_ulong,
00546                               any->_tao_byte_order (),
00547                               any->_tao_get_cdr ());
00548             if ((tmp >>= d) && d == enum_v)
00549               current_member = i;
00550           }
00551           break;
00552 
00553         case CORBA::tk_char:
00554           {
00555             CORBA::Char d;
00556             if ((any >>= CORBA::Any::to_char (d)) && d == char_v)
00557               current_member = i;
00558           }
00559           break;
00560 
00561         case CORBA::tk_wchar:
00562           {
00563             CORBA::WChar d;
00564             if ((any >>= CORBA::Any::to_wchar (d)) && d == wchar_v)
00565               current_member = i;
00566           }
00567           break;
00568 
00569         case CORBA::tk_boolean:
00570           {
00571             CORBA::Boolean d;
00572             if ((any >>= CORBA::Any::to_boolean (d)) && d == boolean_v)
00573               current_member = i;
00574           }
00575           break;
00576 
00577         default:
00578           return CORBA::TypeCode::TRAVERSE_STOP;
00579         }
00580     }
00581 
00582   if (current_member == null_member)
00583     {
00584       // Cannot find the current member, check if there is a
00585       // default...
00586       if (default_member != null_member)
00587         {
00588           // Good, use the default to append...
00589           CORBA::TypeCode_var member_tc =
00590             tc->member_type (default_member ACE_ENV_ARG_PARAMETER);
00591           ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00592           return TAO_Marshal_Object::perform_append (member_tc.in (),
00593                                                      src,
00594                                                      dest
00595                                                       ACE_ENV_ARG_PARAMETER);
00596         }
00597 
00598       // If we're here, we have an implicit default case, and we
00599       // should just return without appending anything, since no
00600       // union member was marshaled in the first place.
00601       return CORBA::TypeCode::TRAVERSE_CONTINUE;
00602     }
00603 
00604   // If we found the member successfully then just use that one...
00605   CORBA::TypeCode_var member_tc =
00606     tc->member_type (current_member ACE_ENV_ARG_PARAMETER);
00607   ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP);
00608   return TAO_Marshal_Object::perform_append (member_tc.in (),
00609                                              src,
00610                                              dest
00611                                               ACE_ENV_ARG_PARAMETER);
00612 }

virtual CORBA::TypeCode::traverse_status TAO_Marshal_Union::skip CORBA::TypeCode_ptr    tc,
TAO_InputCDR *context    ACE_ENV_ARG_DECL
[virtual]
 

skip operation.

Implements TAO_Marshal_Object.


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