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

CDR.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // $Id: CDR.cpp,v 1.1.1.3.40.2 2003/04/10 14:04:02 phil Exp $
00003 
00004 // Portions of this file are:
00005 // Copyright 1994-1995 by Sun Microsystems Inc.
00006 // All Rights Reserved
00007 
00008 // CDR:         Encode/Decode basic machine data types
00009 //
00010 // Implementation of OMG "Common Data Representation" (CDR) ... there
00011 // are one routine each for byte/halfword/word/doubleword put/get,
00012 // which adjust to establish "natural" alignment (the bulk of the
00013 // code) and then put or get with byteswapping as needed.
00014 //
00015 // The implementation knows that native data formats are conformant
00016 // with OMG-IDL's (and hence CDR's) size requirements, and relies on
00017 // the fact that (for example) CORBA_Long is always four bytes long
00018 // even if the environment's "int" is a different size.
00019 //
00020 //      char, octet                       8 bits (1 byte)
00021 //      short, unsigned short            16 bits (2 bytes)
00022 //      long, unsigned long, float       32 bits (4 bytes)
00023 //      double, (unsigned) long long     64 bits (8 bytes)
00024 //      long double                     128 bits (16 bytes)
00025 //
00026 // Moreover, this "knows" that the native 'char' represents ISO
00027 // Latin/1 characters (an ASCII superset addressing Western European
00028 // characters) and that "double" and "float" comply with the IEEE
00029 // standards. (The "long double" may not be a native data type,
00030 // though.)
00031 //
00032 // THREADING NOTE: "CDR" is a data structure which must be protected
00033 // by external critical sections.
00034 
00035 #include "tao/Timeprobe.h"
00036 #include "tao/CDR.h"
00037 #include "tao/ORB_Core.h"
00038 #include "tao/Environment.h"
00039 
00040 #if !defined (__ACE_INLINE__)
00041 # include "tao/CDR.i"
00042 #endif /* ! __ACE_INLINE__ */
00043 
00044 
00045 ACE_RCSID(tao, CDR, "$Id: CDR.cpp,v 1.1.1.3.40.2 2003/04/10 14:04:02 phil Exp $")
00046 
00047 #if defined (ACE_ENABLE_TIMEPROBES)
00048 
00049 static const char *TAO_CDR_Timeprobe_Description[] =
00050 {
00051   "OutputCDR::ctor[1] - enter",
00052   "OutputCDR::ctor[1] - leave",
00053   "OutputCDR::ctor[2] - enter",
00054   "OutputCDR::ctor[2] - leave",
00055   "OutputCDR::ctor[3] - enter",
00056   "OutputCDR::ctor[3] - leave"
00057 };
00058 
00059 enum
00060 {
00061   TAO_OUTPUT_CDR_CTOR1_ENTER = 2000,
00062   TAO_OUTPUT_CDR_CTOR1_LEAVE,
00063   TAO_OUTPUT_CDR_CTOR2_ENTER,
00064   TAO_OUTPUT_CDR_CTOR2_LEAVE,
00065   TAO_OUTPUT_CDR_CTOR3_ENTER,
00066   TAO_OUTPUT_CDR_CTOR3_LEAVE
00067 };
00068 
00069 // Setup Timeprobes
00070 ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_CDR_Timeprobe_Description,
00071                                   TAO_OUTPUT_CDR_CTOR1_ENTER);
00072 
00073 #endif /* ACE_ENABLE_TIMEPROBES */
00074 
00075 TAO_OutputCDR::TAO_OutputCDR (size_t size,
00076                               int byte_order,
00077                               ACE_Allocator *buffer_allocator,
00078                               ACE_Allocator *data_block_allocator,
00079                               ACE_Allocator* message_block_allocator,
00080                               size_t memcpy_tradeoff,
00081                               ACE_CDR::Octet major_version,
00082                               ACE_CDR::Octet minor_version)
00083   :  ACE_OutputCDR (size,
00084                     byte_order,
00085                     buffer_allocator,
00086                     data_block_allocator,
00087                     message_block_allocator,
00088                     memcpy_tradeoff,
00089                     major_version,
00090                     minor_version)
00091 {
00092   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER);
00093 }
00094 
00095 TAO_OutputCDR::TAO_OutputCDR (char *data,
00096                               size_t size,
00097                               int byte_order,
00098                               ACE_Allocator *buffer_allocator,
00099                               ACE_Allocator *data_block_allocator,
00100                               ACE_Allocator* message_block_allocator,
00101                               size_t memcpy_tradeoff,
00102                               ACE_CDR::Octet major_version,
00103                               ACE_CDR::Octet minor_version)
00104   :  ACE_OutputCDR (data,
00105                     size,
00106                     byte_order,
00107                     buffer_allocator,
00108                     data_block_allocator,
00109                     message_block_allocator,
00110                     memcpy_tradeoff,
00111                     major_version,
00112                     minor_version)
00113 {
00114   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER);
00115 }
00116 
00117 TAO_OutputCDR::TAO_OutputCDR (ACE_Message_Block *data,
00118                               int byte_order,
00119                               size_t memcpy_tradeoff,
00120                               ACE_CDR::Octet major_version,
00121                               ACE_CDR::Octet minor_version)
00122   :  ACE_OutputCDR (data,
00123                     byte_order,
00124                     memcpy_tradeoff,
00125                     major_version,
00126                     minor_version)
00127 {
00128   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER);
00129 }
00130 
00131 
00132 void
00133 TAO_OutputCDR::throw_stub_exception (int error_num ACE_ENV_ARG_DECL)
00134 {
00135   switch (error_num)
00136     {
00137     case 0 :
00138       break;
00139     case EINVAL : // wchar from a GIOP 1.0
00140       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO));
00141       ACE_NOTREACHED(break);
00142     case ERANGE : // untranslatable character
00143       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1, CORBA::COMPLETED_NO));
00144       ACE_NOTREACHED(break);
00145     case EACCES : // wchar but no codeset
00146       ACE_THROW(CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO));
00147       ACE_NOTREACHED(break);
00148     default :
00149       ACE_THROW (CORBA::MARSHAL ());
00150     }
00151 }
00152 
00153 void
00154 TAO_OutputCDR::throw_skel_exception (int error_num ACE_ENV_ARG_DECL)
00155 {
00156   switch (error_num)
00157     {
00158     case 0 :
00159       break;
00160     case EINVAL : // wchar from a GIOP 1.0
00161       ACE_THROW (CORBA::MARSHAL(CORBA::OMGVMCID | 5, CORBA::COMPLETED_YES));
00162       ACE_NOTREACHED(break);
00163 
00164     case EACCES : // wchar but no codeset
00165       ACE_THROW (CORBA::BAD_PARAM(CORBA::OMGVMCID | 23, CORBA::COMPLETED_YES));
00166       ACE_NOTREACHED(break);
00167 
00168     case ERANGE : // untranslatable character
00169       ACE_THROW (CORBA::DATA_CONVERSION(CORBA::OMGVMCID | 1, CORBA::COMPLETED_YES));
00170       ACE_NOTREACHED(break);
00171 
00172     default :
00173       ACE_THROW (CORBA::MARSHAL(TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES));
00174 
00175     }
00176 }
00177 
00178 
00179 
00180 // ****************************************************************
00181 
00182 TAO_InputCDR::TAO_InputCDR (const TAO_OutputCDR& rhs,
00183                             ACE_Allocator* buffer_allocator,
00184                             ACE_Allocator* data_block_allocator,
00185                             ACE_Allocator* message_block_allocator,
00186                             TAO_ORB_Core* orb_core)
00187   : ACE_InputCDR (rhs,
00188                   buffer_allocator
00189                   ? buffer_allocator
00190                   : (orb_core ? orb_core->output_cdr_buffer_allocator () : 0),
00191                   data_block_allocator
00192                   ? data_block_allocator
00193                   : (orb_core ? orb_core->output_cdr_dblock_allocator () :
00194                      0),
00195                   message_block_allocator
00196                   ? message_block_allocator
00197                   : (orb_core ?
00198                      orb_core->output_cdr_msgblock_allocator () : 0)),
00199   orb_core_ (orb_core)
00200 {
00201 }
00202 
00203 
00204 void
00205 TAO_InputCDR::throw_stub_exception (int error_num ACE_ENV_ARG_DECL)
00206 {
00207   switch (error_num)
00208     {
00209     case 0 :
00210       break;
00211     case EINVAL : // wchar from a GIOP 1.0
00212       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 6, CORBA::COMPLETED_YES));
00213       ACE_NOTREACHED(break);
00214     case ERANGE : // untranslatable character
00215       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1, CORBA::COMPLETED_YES));
00216       ACE_NOTREACHED(break);
00217     case EACCES : // wchar but no codeset
00218       ACE_THROW (CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_YES));
00219       ACE_NOTREACHED(break);
00220     default :
00221       ACE_THROW (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES));
00222     }
00223 }
00224 
00225 void
00226 TAO_InputCDR::throw_skel_exception (int error_num ACE_ENV_ARG_DECL)
00227 {
00228   switch (error_num)
00229     {
00230     case 0 :
00231       break;
00232     case EINVAL : // wchar from a GIOP 1.0
00233       ACE_THROW (CORBA::MARSHAL(CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO));
00234       ACE_NOTREACHED(break);
00235 
00236     case EACCES : // wchar but no codeset
00237       ACE_THROW (CORBA::BAD_PARAM(CORBA::OMGVMCID | 23, CORBA::COMPLETED_NO));
00238       ACE_NOTREACHED(break);
00239 
00240     case ERANGE : // untranslatable character
00241       ACE_THROW (CORBA::DATA_CONVERSION(CORBA::OMGVMCID | 1, CORBA::COMPLETED_NO));
00242       ACE_NOTREACHED(break);
00243 
00244     default :
00245       ACE_THROW (CORBA::MARSHAL());
00246 
00247     }
00248 }

Generated on Mon Jun 16 13:48:02 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002