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
);
234 TAO_OutputCDR::fragment_stream (ACE_CDR::ULong pending_alignment
,
235 ACE_CDR::ULong pending_length
)
237 if (this->fragmentation_strategy_
)
239 return (this->fragmentation_strategy_
->fragment (*this,
241 pending_length
) == 0);
244 return true; // Success.
250 TAO_OutputCDR::offset (char* pos
)
253 const ACE_Message_Block
* cur_mb
= this->begin ();
254 char* wr_ptr
= this->current ()->wr_ptr ();
257 while (cur_mb
!= this->end ())
259 if (pos
>= cur_mb
->rd_ptr () && pos
<= cur_mb
->wr_ptr ())
261 offset
+= ACE_Utils::truncate_cast
<int> (cur_mb
->wr_ptr () - pos
);
266 offset
+= ACE_Utils::truncate_cast
<int> (cur_mb
->length ());
269 if (wr_ptr
== cur_mb
->wr_ptr ())
272 cur_mb
= cur_mb
->cont();
275 if (!found
|| wr_ptr
!= cur_mb
->wr_ptr ())
277 throw ::CORBA::INTERNAL ();
284 // ****************************************************************
286 TAO_InputCDR::TAO_InputCDR (const TAO_OutputCDR
& rhs
,
287 ACE_Allocator
* buffer_allocator
,
288 ACE_Allocator
* data_block_allocator
,
289 ACE_Allocator
* message_block_allocator
,
290 TAO_ORB_Core
* orb_core
)
294 : (orb_core
? orb_core
->output_cdr_buffer_allocator () : nullptr),
296 ? data_block_allocator
297 : (orb_core
? orb_core
->output_cdr_dblock_allocator () :
299 message_block_allocator
300 ? message_block_allocator
302 orb_core
->output_cdr_msgblock_allocator () : nullptr)),
308 TAO_InputCDR::throw_stub_exception (int error_num
)
312 case EINVAL
: // wchar from a GIOP 1.0
313 throw ::CORBA::MARSHAL (CORBA::OMGVMCID
| 6, CORBA::COMPLETED_YES
);
314 ACE_NOTREACHED(break);
315 #if (ERANGE != EINVAL)
316 case ERANGE
: // untranslatable character
317 throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID
| 1, CORBA::COMPLETED_YES
);
318 ACE_NOTREACHED(break);
320 case EACCES
: // wchar but no codeset
321 throw ::CORBA::INV_OBJREF (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_YES
);
322 ACE_NOTREACHED(break);
324 throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_YES
);
329 TAO_InputCDR::throw_skel_exception (int error_num
)
333 case EINVAL
: // wchar from a GIOP 1.0
334 throw ::CORBA::MARSHAL(CORBA::OMGVMCID
| 5, CORBA::COMPLETED_NO
);
335 ACE_NOTREACHED(break);
337 case EACCES
: // wchar but no codeset
338 throw ::CORBA::BAD_PARAM(CORBA::OMGVMCID
| 23, CORBA::COMPLETED_NO
);
339 ACE_NOTREACHED(break);
341 #if (ERANGE != EINVAL)
342 case ERANGE
: // untranslatable character
343 throw ::CORBA::DATA_CONVERSION(CORBA::OMGVMCID
| 1, CORBA::COMPLETED_NO
);
344 ACE_NOTREACHED(break);
348 throw ::CORBA::MARSHAL();
353 ACE_Message_Block::Message_Flags
354 TAO_InputCDR::clr_mb_flags( ACE_Message_Block::Message_Flags less_flags
)
356 return start_
.clr_self_flags( less_flags
);
360 TAO_END_VERSIONED_NAMESPACE_DECL