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