CDR.cpp

Go to the documentation of this file.
00001 // CDR.cpp,v 1.61 2006/04/20 12:37:17 jwillemsen Exp
00002 
00003 #include "tao/CDR.h"
00004 #include "tao/Timeprobe.h"
00005 #include "tao/ORB_Core.h"
00006 #include "tao/Environment.h"
00007 #include "tao/SystemException.h"
00008 #include "tao/GIOP_Fragmentation_Strategy.h"
00009 
00010 #if !defined (__ACE_INLINE__)
00011 # include "tao/CDR.i"
00012 #endif /* ! __ACE_INLINE__ */
00013 
00014 
00015 ACE_RCSID (tao,
00016            CDR,
00017            "CDR.cpp,v 1.61 2006/04/20 12:37:17 jwillemsen Exp")
00018 
00019 
00020 #if defined (ACE_ENABLE_TIMEPROBES)
00021 
00022 static const char *TAO_CDR_Timeprobe_Description[] =
00023 {
00024   "OutputCDR::ctor[1] - enter",
00025   "OutputCDR::ctor[1] - leave",
00026   "OutputCDR::ctor[2] - enter",
00027   "OutputCDR::ctor[2] - leave",
00028   "OutputCDR::ctor[3] - enter",
00029   "OutputCDR::ctor[3] - leave",
00030   "OutputCDR::ctor[4] - enter",
00031   "OutputCDR::ctor[4] - leave"
00032 };
00033 
00034 enum
00035 {
00036   TAO_OUTPUT_CDR_CTOR1_ENTER = 2000,
00037   TAO_OUTPUT_CDR_CTOR1_LEAVE,
00038   TAO_OUTPUT_CDR_CTOR2_ENTER,
00039   TAO_OUTPUT_CDR_CTOR2_LEAVE,
00040   TAO_OUTPUT_CDR_CTOR3_ENTER,
00041   TAO_OUTPUT_CDR_CTOR3_LEAVE,
00042   TAO_OUTPUT_CDR_CTOR4_ENTER,
00043   TAO_OUTPUT_CDR_CTOR4_LEAVE
00044 };
00045 
00046 // Setup Timeprobes
00047 ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_CDR_Timeprobe_Description,
00048                                   TAO_OUTPUT_CDR_CTOR1_ENTER);
00049 
00050 #endif /* ACE_ENABLE_TIMEPROBES */
00051 
00052 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00053 
00054 TAO_OutputCDR::TAO_OutputCDR (size_t size,
00055                               int byte_order,
00056                               ACE_Allocator *buffer_allocator,
00057                               ACE_Allocator *data_block_allocator,
00058                               ACE_Allocator* message_block_allocator,
00059                               size_t memcpy_tradeoff,
00060                               ACE_CDR::Octet major_version,
00061                               ACE_CDR::Octet minor_version)
00062   : ACE_OutputCDR (size,
00063                    byte_order,
00064                    buffer_allocator,
00065                    data_block_allocator,
00066                    message_block_allocator,
00067                    memcpy_tradeoff,
00068                    major_version,
00069                    minor_version)
00070   , fragmentation_strategy_ (0)
00071   , more_fragments_ (false)
00072   , request_id_ (0)
00073   , stub_ (0)
00074   , message_semantics_ (-1)
00075   , timeout_ (0)
00076 {
00077   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER);
00078 }
00079 
00080 TAO_OutputCDR::TAO_OutputCDR (char *data,
00081                               size_t size,
00082                               int byte_order,
00083                               ACE_Allocator *buffer_allocator,
00084                               ACE_Allocator *data_block_allocator,
00085                               ACE_Allocator* message_block_allocator,
00086                               size_t memcpy_tradeoff,
00087                               ACE_CDR::Octet major_version,
00088                               ACE_CDR::Octet minor_version)
00089   : ACE_OutputCDR (data,
00090                    size,
00091                    byte_order,
00092                    buffer_allocator,
00093                    data_block_allocator,
00094                    message_block_allocator,
00095                    memcpy_tradeoff,
00096                    major_version,
00097                    minor_version)
00098   , fragmentation_strategy_ (0)
00099   , more_fragments_ (false)
00100   , request_id_ (0)
00101   , stub_ (0)
00102   , message_semantics_ (-1)
00103   , timeout_ (0)
00104 {
00105   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER);
00106 }
00107 
00108 TAO_OutputCDR::TAO_OutputCDR (char *data,
00109                               size_t size,
00110                               int byte_order,
00111                               ACE_Allocator* buffer_allocator,
00112                               ACE_Allocator* data_block_allocator,
00113                               ACE_Allocator* message_block_allocator,
00114                               size_t memcpy_tradeoff,
00115                               TAO_GIOP_Fragmentation_Strategy * fs,
00116                               ACE_CDR::Octet major_version,
00117                               ACE_CDR::Octet minor_version)
00118   : ACE_OutputCDR (data,
00119                    size,
00120                    byte_order,
00121                    buffer_allocator,
00122                    data_block_allocator,
00123                    message_block_allocator,
00124                    memcpy_tradeoff,
00125                    major_version,
00126                    minor_version)
00127   , fragmentation_strategy_ (fs)
00128   , more_fragments_ (false)
00129   , request_id_ (0)
00130   , stub_ (0)
00131   , message_semantics_ (-1)
00132   , timeout_ (0)
00133 {
00134   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER);
00135 }
00136 
00137 TAO_OutputCDR::TAO_OutputCDR (ACE_Message_Block *data,
00138                               int byte_order,
00139                               size_t memcpy_tradeoff,
00140                               ACE_CDR::Octet major_version,
00141                               ACE_CDR::Octet minor_version)
00142   : ACE_OutputCDR (data,
00143                    byte_order,
00144                    memcpy_tradeoff,
00145                    major_version,
00146                    minor_version)
00147   , fragmentation_strategy_ (0)
00148   , more_fragments_ (false)
00149   , request_id_ (0)
00150   , stub_ (0)
00151   , message_semantics_ (-1)
00152   , timeout_ (0)
00153 {
00154   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER);
00155 }
00156 
00157 void
00158 TAO_OutputCDR::throw_stub_exception (int error_num ACE_ENV_ARG_DECL)
00159 {
00160   switch (error_num)
00161     {
00162     case 0 :
00163       break;
00164     case EINVAL : // wchar from a GIOP 1.0
00165       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO));
00166       ACE_NOTREACHED (break);
00167 #if (ERANGE != EINVAL)
00168     case ERANGE : // untranslatable character
00169       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1,
00170                                          CORBA::COMPLETED_NO));
00171       ACE_NOTREACHED (break);
00172 #endif
00173     case EACCES : // wchar but no codeset
00174       ACE_THROW (CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO));
00175       ACE_NOTREACHED (break);
00176     default :
00177       ACE_THROW (CORBA::MARSHAL ());
00178     }
00179 }
00180 
00181 void
00182 TAO_OutputCDR::throw_skel_exception (int error_num ACE_ENV_ARG_DECL)
00183 {
00184   switch (error_num)
00185     {
00186     case 0 :
00187       break;
00188 
00189     case EINVAL : // wchar from a GIOP 1.0
00190       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_YES));
00191       ACE_NOTREACHED (break);
00192 
00193     case EACCES : // wchar but no codeset
00194       ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 23,
00195                                    CORBA::COMPLETED_YES));
00196       ACE_NOTREACHED (break);
00197 
00198 #if (ERANGE != EINVAL)
00199     case ERANGE : // untranslatable character
00200       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1,
00201                                          CORBA::COMPLETED_YES));
00202       ACE_NOTREACHED (break);
00203 #endif
00204 
00205     default :
00206       ACE_THROW (CORBA::MARSHAL (0, CORBA::COMPLETED_YES));
00207 
00208     }
00209 }
00210 
00211 bool
00212 TAO_OutputCDR::fragment_stream (ACE_CDR::ULong pending_alignment,
00213                                 ACE_CDR::ULong pending_length)
00214 {
00215   if (this->fragmentation_strategy_)
00216     {
00217       return (this->fragmentation_strategy_->fragment (*this,
00218                                                        pending_alignment,
00219                                                        pending_length) == 0);
00220     }
00221 
00222   return true;  // Success.
00223 }
00224 
00225 
00226 // ****************************************************************
00227 
00228 TAO_InputCDR::TAO_InputCDR (const TAO_OutputCDR& rhs,
00229                             ACE_Allocator* buffer_allocator,
00230                             ACE_Allocator* data_block_allocator,
00231                             ACE_Allocator* message_block_allocator,
00232                             TAO_ORB_Core* orb_core)
00233   : ACE_InputCDR (rhs,
00234                   buffer_allocator
00235                   ? buffer_allocator
00236                   : (orb_core ? orb_core->output_cdr_buffer_allocator () : 0),
00237                   data_block_allocator
00238                   ? data_block_allocator
00239                   : (orb_core ? orb_core->output_cdr_dblock_allocator () :
00240                      0),
00241                   message_block_allocator
00242                   ? message_block_allocator
00243                   : (orb_core ?
00244                      orb_core->output_cdr_msgblock_allocator () : 0)),
00245   orb_core_ (orb_core)
00246 {
00247 }
00248 
00249 
00250 void
00251 TAO_InputCDR::throw_stub_exception (int error_num ACE_ENV_ARG_DECL)
00252 {
00253   switch (error_num)
00254     {
00255     case 0 :
00256       break;
00257     case EINVAL : // wchar from a GIOP 1.0
00258       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 6, CORBA::COMPLETED_YES));
00259       ACE_NOTREACHED(break);
00260 #if (ERANGE != EINVAL)
00261     case ERANGE : // untranslatable character
00262       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1, CORBA::COMPLETED_YES));
00263       ACE_NOTREACHED(break);
00264 #endif
00265     case EACCES : // wchar but no codeset
00266       ACE_THROW (CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_YES));
00267       ACE_NOTREACHED(break);
00268     default :
00269       ACE_THROW (CORBA::MARSHAL (0, CORBA::COMPLETED_YES));
00270     }
00271 }
00272 
00273 void
00274 TAO_InputCDR::throw_skel_exception (int error_num ACE_ENV_ARG_DECL)
00275 {
00276   switch (error_num)
00277     {
00278     case 0 :
00279       break;
00280     case EINVAL : // wchar from a GIOP 1.0
00281       ACE_THROW (CORBA::MARSHAL(CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO));
00282       ACE_NOTREACHED(break);
00283 
00284     case EACCES : // wchar but no codeset
00285       ACE_THROW (CORBA::BAD_PARAM(CORBA::OMGVMCID | 23, CORBA::COMPLETED_NO));
00286       ACE_NOTREACHED(break);
00287 
00288 #if (ERANGE != EINVAL)
00289     case ERANGE : // untranslatable character
00290       ACE_THROW (CORBA::DATA_CONVERSION(CORBA::OMGVMCID | 1, CORBA::COMPLETED_NO));
00291       ACE_NOTREACHED(break);
00292 #endif
00293 
00294     default :
00295       ACE_THROW (CORBA::MARSHAL());
00296 
00297     }
00298 }
00299 
00300 ACE_Message_Block::Message_Flags
00301 TAO_InputCDR::clr_mb_flags( ACE_Message_Block::Message_Flags less_flags )
00302 {
00303   return start_.clr_self_flags( less_flags );
00304 }
00305 
00306 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 11:54:08 2006 for TAO by doxygen 1.3.6