2 #include "tao/Timeprobe.h"
3 #include "tao/ORB_Core.h"
4 #include "tao/SystemException.h"
5 #include "tao/GIOP_Fragmentation_Strategy.h"
7 #include "ace/Truncate.h"
9 #if !defined (__ACE_INLINE__)
10 # include "tao/CDR.inl"
11 #endif /* ! __ACE_INLINE__ */
13 #if defined (ACE_ENABLE_TIMEPROBES)
15 static const char *TAO_CDR_Timeprobe_Description
[] =
17 "OutputCDR::ctor[1] - enter",
18 "OutputCDR::ctor[1] - leave",
19 "OutputCDR::ctor[2] - enter",
20 "OutputCDR::ctor[2] - leave",
21 "OutputCDR::ctor[3] - enter",
22 "OutputCDR::ctor[3] - leave",
23 "OutputCDR::ctor[4] - enter",
24 "OutputCDR::ctor[4] - leave",
25 "OutputCDR::ctor[5] - enter",
26 "OutputCDR::ctor[5] - leave"
31 TAO_OUTPUT_CDR_CTOR1_ENTER
= 2000,
32 TAO_OUTPUT_CDR_CTOR1_LEAVE
,
33 TAO_OUTPUT_CDR_CTOR2_ENTER
,
34 TAO_OUTPUT_CDR_CTOR2_LEAVE
,
35 TAO_OUTPUT_CDR_CTOR3_ENTER
,
36 TAO_OUTPUT_CDR_CTOR3_LEAVE
,
37 TAO_OUTPUT_CDR_CTOR4_ENTER
,
38 TAO_OUTPUT_CDR_CTOR4_LEAVE
,
39 TAO_OUTPUT_CDR_CTOR5_ENTER
,
40 TAO_OUTPUT_CDR_CTOR5_LEAVE
44 ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_CDR_Timeprobe_Description
,
45 TAO_OUTPUT_CDR_CTOR1_ENTER
);
47 #endif /* ACE_ENABLE_TIMEPROBES */
49 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
51 TAO_OutputCDR::TAO_OutputCDR (size_t size
,
53 ACE_Allocator
*buffer_allocator
,
54 ACE_Allocator
*data_block_allocator
,
55 ACE_Allocator
* message_block_allocator
,
56 size_t memcpy_tradeoff
,
57 ACE_CDR::Octet major_version
,
58 ACE_CDR::Octet minor_version
)
59 : ACE_OutputCDR (size
,
63 message_block_allocator
,
67 , fragmentation_strategy_ (nullptr)
68 , more_fragments_ (false)
71 , message_semantics_ (TAO_Message_Semantics::TAO_TWOWAY_REQUEST
)
74 ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER
);
76 #if defined (TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS)
77 // Zero out the buffer if we allocated the buffer.
79 (void) ACE_OS::memset (this->current()->wr_ptr(),
81 this->current()->space());
82 #endif /* TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS */
85 TAO_OutputCDR::TAO_OutputCDR (char *data
,
88 ACE_Allocator
*buffer_allocator
,
89 ACE_Allocator
*data_block_allocator
,
90 ACE_Allocator
* message_block_allocator
,
91 size_t memcpy_tradeoff
,
92 ACE_CDR::Octet major_version
,
93 ACE_CDR::Octet minor_version
)
94 : ACE_OutputCDR (data
,
99 message_block_allocator
,
103 , fragmentation_strategy_ (nullptr)
104 , more_fragments_ (false)
107 , message_semantics_ (TAO_Message_Semantics::TAO_TWOWAY_REQUEST
)
110 ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER
);
113 TAO_OutputCDR::TAO_OutputCDR (char *data
,
116 ACE_Allocator
* buffer_allocator
,
117 ACE_Allocator
* data_block_allocator
,
118 ACE_Allocator
* message_block_allocator
,
119 size_t memcpy_tradeoff
,
120 TAO_GIOP_Fragmentation_Strategy
* fs
,
121 ACE_CDR::Octet major_version
,
122 ACE_CDR::Octet minor_version
)
123 : ACE_OutputCDR (data
,
127 data_block_allocator
,
128 message_block_allocator
,
132 , fragmentation_strategy_ (fs
)
133 , more_fragments_ (false)
136 , message_semantics_ (TAO_Message_Semantics::TAO_TWOWAY_REQUEST
)
139 ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER
);
142 TAO_OutputCDR::TAO_OutputCDR (ACE_Message_Block
*data
,
144 size_t memcpy_tradeoff
,
145 ACE_CDR::Octet major_version
,
146 ACE_CDR::Octet minor_version
)
147 : ACE_OutputCDR (data
,
152 , fragmentation_strategy_ (nullptr)
153 , more_fragments_ (false)
156 , message_semantics_ (TAO_Message_Semantics::TAO_TWOWAY_REQUEST
)
159 ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER
);
162 TAO_OutputCDR::TAO_OutputCDR (ACE_Data_Block
*data_block
,
164 ACE_Allocator
* message_block_allocator
,
165 size_t memcpy_tradeoff
,
166 TAO_GIOP_Fragmentation_Strategy
* fs
,
167 ACE_CDR::Octet major_version
,
168 ACE_CDR::Octet minor_version
)
169 : ACE_OutputCDR (data_block
,
171 message_block_allocator
,
175 , fragmentation_strategy_ (fs
)
176 , more_fragments_ (false)
179 , message_semantics_ (TAO_Message_Semantics::TAO_TWOWAY_REQUEST
)
182 ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR5_ENTER
);
186 TAO_OutputCDR::throw_stub_exception (int error_num
)
190 case EINVAL
: // wchar from a GIOP 1.0
191 throw ::CORBA::MARSHAL (CORBA::OMGVMCID
| 5, CORBA::COMPLETED_NO
);
192 ACE_NOTREACHED (break);
193 #if (ERANGE != EINVAL)
194 case ERANGE
: // untranslatable character
195 throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID
| 1,
196 CORBA::COMPLETED_NO
);
197 ACE_NOTREACHED (break);
199 case EACCES
: // wchar but no codeset
200 throw ::CORBA::INV_OBJREF (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_NO
);
201 ACE_NOTREACHED (break);
203 throw ::CORBA::MARSHAL ();
208 TAO_OutputCDR::throw_skel_exception (int error_num
)
212 case EINVAL
: // wchar from a GIOP 1.0
213 throw ::CORBA::MARSHAL (CORBA::OMGVMCID
| 5, CORBA::COMPLETED_YES
);
214 ACE_NOTREACHED (break);
216 case EACCES
: // wchar but no codeset
217 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID
| 23, CORBA::COMPLETED_YES
);
218 ACE_NOTREACHED (break);
220 #if (ERANGE != EINVAL)
221 case ERANGE
: // untranslatable character
222 throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID
| 1,
223 CORBA::COMPLETED_YES
);
224 ACE_NOTREACHED (break);
228 throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_YES
);
233 TAO_OutputCDR::fragment_stream (ACE_CDR::ULong pending_alignment
,
234 ACE_CDR::ULong pending_length
)
236 if (this->fragmentation_strategy_
)
238 return (this->fragmentation_strategy_
->fragment (*this,
240 pending_length
) == 0);
243 return true; // Success.
248 TAO_OutputCDR::offset (char* pos
)
251 const ACE_Message_Block
* cur_mb
= this->begin ();
252 char* wr_ptr
= this->current ()->wr_ptr ();
255 while (cur_mb
!= this->end ())
257 if (pos
>= cur_mb
->rd_ptr () && pos
<= cur_mb
->wr_ptr ())
259 offset
+= ACE_Utils::truncate_cast
<int> (cur_mb
->wr_ptr () - pos
);
264 offset
+= ACE_Utils::truncate_cast
<int> (cur_mb
->length ());
267 if (wr_ptr
== cur_mb
->wr_ptr ())
270 cur_mb
= cur_mb
->cont();
273 if (!found
|| wr_ptr
!= cur_mb
->wr_ptr ())
275 throw ::CORBA::INTERNAL ();
282 // ****************************************************************
284 TAO_InputCDR::TAO_InputCDR (const TAO_OutputCDR
& rhs
,
285 ACE_Allocator
* buffer_allocator
,
286 ACE_Allocator
* data_block_allocator
,
287 ACE_Allocator
* message_block_allocator
,
288 TAO_ORB_Core
* orb_core
)
292 : (orb_core
? orb_core
->output_cdr_buffer_allocator () : nullptr),
294 ? data_block_allocator
295 : (orb_core
? orb_core
->output_cdr_dblock_allocator () :
297 message_block_allocator
298 ? message_block_allocator
300 orb_core
->output_cdr_msgblock_allocator () : nullptr)),
306 TAO_InputCDR::throw_stub_exception (int error_num
)
310 case EINVAL
: // wchar from a GIOP 1.0
311 throw ::CORBA::MARSHAL (CORBA::OMGVMCID
| 6, CORBA::COMPLETED_YES
);
312 ACE_NOTREACHED(break);
313 #if (ERANGE != EINVAL)
314 case ERANGE
: // untranslatable character
315 throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID
| 1, CORBA::COMPLETED_YES
);
316 ACE_NOTREACHED(break);
318 case EACCES
: // wchar but no codeset
319 throw ::CORBA::INV_OBJREF (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_YES
);
320 ACE_NOTREACHED(break);
322 throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_YES
);
327 TAO_InputCDR::throw_skel_exception (int error_num
)
331 case EINVAL
: // wchar from a GIOP 1.0
332 throw ::CORBA::MARSHAL(CORBA::OMGVMCID
| 5, CORBA::COMPLETED_NO
);
333 ACE_NOTREACHED(break);
335 case EACCES
: // wchar but no codeset
336 throw ::CORBA::BAD_PARAM(CORBA::OMGVMCID
| 23, CORBA::COMPLETED_NO
);
337 ACE_NOTREACHED(break);
339 #if (ERANGE != EINVAL)
340 case ERANGE
: // untranslatable character
341 throw ::CORBA::DATA_CONVERSION(CORBA::OMGVMCID
| 1, CORBA::COMPLETED_NO
);
342 ACE_NOTREACHED(break);
346 throw ::CORBA::MARSHAL();
350 ACE_Message_Block::Message_Flags
351 TAO_InputCDR::clr_mb_flags( ACE_Message_Block::Message_Flags less_flags
)
353 return start_
.clr_self_flags( less_flags
);
357 TAO_END_VERSIONED_NAMESPACE_DECL