1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
|
// $Id$
#include "tao/Profile.h"
#include "tao/Messaging_PolicyValueC.h"
#include "tao/Stub.h"
#include "tao/debug.h"
#include "tao/target_specification.h"
#include "tao/ORB_Core.h"
#include "tao/Client_Strategy_Factory.h"
#include "tao/CDR.h"
#include "tao/SystemException.h"
#include "tao/PolicyC.h"
#include "tao/Endpoint.h"
#include "ace/ACE.h"
#include "ace/OS_NS_string.h"
#include "ace/os_include/os_ctype.h"
#if !defined (__ACE_INLINE__)
#include "tao/Profile.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID (tao,
Profile,
"$Id$")
// ****************************************************************
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO_Profile::TAO_Profile (CORBA::ULong tag,
TAO_ORB_Core *orb_core,
const TAO::ObjectKey &obj_key,
const TAO_GIOP_Message_Version &version)
: version_ (version)
, are_policies_parsed_ (false)
, addressing_mode_ (0)
, tagged_profile_ (0)
, ref_object_key_ (0)
, tag_ (tag)
, orb_core_ (orb_core)
, forward_to_ (0)
, refcount_ (this->orb_core_->
client_factory ()->create_profile_refcount ())
{
(void) this->orb_core_->object_key_table ().bind (obj_key,
this->ref_object_key_);
}
TAO_Profile::TAO_Profile (CORBA::ULong tag,
TAO_ORB_Core *orb_core,
const TAO_GIOP_Message_Version &version)
: version_ (version)
, are_policies_parsed_ (false)
, addressing_mode_ (0)
, tagged_profile_ (0)
, ref_object_key_ (0)
, tag_ (tag)
, orb_core_ (orb_core)
, forward_to_ (0)
, refcount_ (this->orb_core_->
client_factory ()->create_profile_refcount ())
{
}
TAO_Profile::~TAO_Profile (void)
{
if (this->tagged_profile_)
{
delete this->tagged_profile_;
}
this->orb_core_->object_key_table ().unbind (this->ref_object_key_);
//@@ TAO_PROFILE_SPL_DESTRUCTOR_ADD_HOOK
}
unsigned long
TAO_Profile::_incr_refcnt (void)
{
return this->refcount_.increment ();
}
unsigned long
TAO_Profile::_decr_refcnt (void)
{
unsigned long count = this->refcount_.decrement ();
if (count != 0)
return count;
// refcount is 0, so delete us!
// delete will call our ~ destructor which in turn deletes stuff.
delete this;
return 0;
}
void
TAO_Profile::add_tagged_component (const IOP::TaggedComponent &component
ACE_ENV_ARG_DECL)
{
// Sanity checks.
this->verify_orb_configuration (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
this->verify_profile_version (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
// ----------------------------------------------------------------
// Add the given tagged component to this profile.
//
// Note that multiple tagged profiles with the same tag value may be
// added, unless the tagged component is known to be unique by TAO.
this->tagged_components_.set_component (component);
}
TAO::ObjectKey *
TAO_Profile::_key (void) const
{
TAO::ObjectKey *key = 0;
if (this->ref_object_key_)
{
ACE_NEW_RETURN (key,
TAO::ObjectKey (this->ref_object_key_->object_key ()),
0);
}
return key;
}
int
TAO_Profile::encode (TAO_OutputCDR &stream) const
{
// UNSIGNED LONG, protocol tag
stream.write_ulong (this->tag_);
// Create the encapsulation....
TAO_OutputCDR encap (ACE_CDR::DEFAULT_BUFSIZE,
TAO_ENCAP_BYTE_ORDER,
this->orb_core ()->output_cdr_buffer_allocator (),
this->orb_core ()->output_cdr_dblock_allocator (),
this->orb_core ()->output_cdr_msgblock_allocator (),
this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
TAO_DEF_GIOP_MAJOR,
TAO_DEF_GIOP_MINOR);
// Create the profile body
this->create_profile_body (encap);
// write the encapsulation as an octet sequence...
stream << CORBA::ULong (encap.total_length ());
stream.write_octet_array_mb (encap.begin ());
return 1;
}
int
TAO_Profile::decode (TAO_InputCDR& cdr)
{
size_t const encap_len = cdr.length ();
// Read and verify major, minor versions, ignoring profiles
// whose versions we don't understand.
if (!(cdr.read_octet (this->version_.major)
&& this->version_.major == TAO_DEF_GIOP_MAJOR
&& cdr.read_octet (this->version_.minor)
&& this->version_.minor <= TAO_DEF_GIOP_MINOR))
{
if (TAO_debug_level > 0)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - Profile::decode - v%d.%d\n"),
this->version_.major,
this->version_.minor));
}
return -1;
}
// Transport specific details
if (this->decode_profile (cdr) < 0)
{
return -1;
}
// @@NOTE: This place *may* need strategizing. Here are the
// issues. Placing the ObjectKey in the table adds an allocation and
// a lock while decoding. This is bad for some cases especially if
// the application is marshalling object references across to the
// server end. But the server could use "lazy" evaluation and avoid
// this during marshalling.
//
// The only place this will get important is when a thead tries to
// use the object reference to create a CORBA object to make an
// invocation. Since creation of a CORBA object itself is expensive,
// it looks like we may not need to worry much.
//
// Remember strategizing needs reconciliation of forces imposed
// by runtime memory growth. Doing a random strategization would
// destroy the wins in runtime memory growth got by using this
// table scheme.
TAO::ObjectKey ok;
// ... and object key.
if (TAO::ObjectKey::demarshal_key (ok,
cdr) == 0)
{
return -1;
}
TAO::ObjectKey_Table &okt = this->orb_core ()->object_key_table ();
if (okt.bind (ok, this->ref_object_key_) == -1)
{
return -1;
}
// Tagged Components *only* exist after version 1.0!
// For GIOP 1.2, IIOP and GIOP have same version numbers!
if (this->version_.major > 1
|| this->version_.minor > 0)
{
if (this->tagged_components_.decode (cdr) == 0)
{
return -1;
}
}
if (cdr.length () != 0 && TAO_debug_level)
{
// If there is extra data in the profile we are supposed to
// ignore it, but print a warning just in case...
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("%d bytes out of %d left after profile data\n"),
cdr.length (),
encap_len));
}
// Decode any additional endpoints per profile. This is used by RTCORBA
// and by IIOP when TAG_ALTERNATE_IIOP_ADDRESS components are present.
if (this->decode_endpoints () == -1)
{
return -1;
}
return 1;
}
IOP::TaggedProfile *
TAO_Profile::create_tagged_profile (void)
{
if (this->tagged_profile_ == 0)
{
ACE_NEW_RETURN (this->tagged_profile_,
IOP::TaggedProfile,
0);
// As we have not created we will now create the TaggedProfile
this->tagged_profile_->tag = this->tag_;
// Create the encapsulation....
TAO_OutputCDR encap (ACE_DEFAULT_CDR_BUFSIZE,
TAO_ENCAP_BYTE_ORDER,
this->orb_core ()->output_cdr_buffer_allocator (),
this->orb_core ()->output_cdr_dblock_allocator (),
this->orb_core ()->output_cdr_msgblock_allocator (),
this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
TAO_DEF_GIOP_MAJOR,
TAO_DEF_GIOP_MINOR);
// Create the profile body
this->create_profile_body (encap);
CORBA::ULong const length =
static_cast <CORBA::ULong> (encap.total_length ());
#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
// Place the message block in to the Sequence of Octets that we
// have
this->tagged_profile_->profile_data.replace (length,
encap.begin ());
#else
this->tagged_profile_->profile_data.length (length);
CORBA::Octet *buffer =
this->tagged_profile_->profile_data.get_buffer ();
for (const ACE_Message_Block *i = encap.begin ();
i != encap.end ();
i = i->next ())
{
ACE_OS::memcpy (buffer, i->rd_ptr (), i->length ());
buffer += i->length ();
}
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
}
return this->tagged_profile_;
}
void
TAO_Profile::set_tagged_components (TAO_OutputCDR &out_cdr)
{
CORBA::ULong const length = static_cast <CORBA::ULong> (out_cdr.total_length ());
IOP::TaggedComponent tagged_component;
tagged_component.tag = TAO_TAG_ENDPOINTS;
tagged_component.component_data.length (length);
CORBA::Octet *buf =
tagged_component.component_data.get_buffer ();
for (const ACE_Message_Block *iterator = out_cdr.begin ();
iterator != 0;
iterator = iterator->cont ())
{
size_t const i_length = iterator->length ();
ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
buf += i_length;
}
// Add component with encoded endpoint data to this profile's
// TaggedComponents.
tagged_components_.set_component (tagged_component);
}
void
TAO_Profile::policies (CORBA::PolicyList *policy_list
ACE_ENV_ARG_DECL)
{
#if (TAO_HAS_CORBA_MESSAGING == 1)
if (policy_list == 0)
{
if (TAO_debug_level)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO_Profile::policies: ")
ACE_TEXT ("Null Policy List!\n")));
}
return;
}
Messaging::PolicyValue pv;
Messaging::PolicyValueSeq policy_value_seq;
size_t length;
CORBA::Octet *buf = 0;
policy_value_seq.length (policy_list->length ());
// This loop iterates through CORBA::PolicyList to convert
// each CORBA::Policy into a CORBA::PolicyValue
const size_t plen = policy_list->length ();
for (CORBA::ULong i = 0; i < plen; ++i)
{
TAO_OutputCDR out_CDR;
policy_value_seq[i].ptype =
(*policy_list)[i]->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
(*policy_list)[i]->_tao_encode (out_CDR);
length = out_CDR.total_length ();
policy_value_seq[i].pvalue.length (static_cast <CORBA::ULong>(length));
buf = policy_value_seq[i].pvalue.get_buffer ();
// Copy the CDR buffer data into the octet sequence buffer.
for (const ACE_Message_Block *iterator = out_CDR.begin ();
iterator != 0;
iterator = iterator->cont ())
{
ACE_OS::memcpy (buf, iterator->rd_ptr (), iterator->length ());
buf += iterator->length ();
}
}
TAO_OutputCDR out_cdr;
// Now we have to embed the Messaging::PolicyValueSeq into
// a TaggedComponent.
IOP::TaggedComponent tagged_component;
tagged_component.tag = Messaging::TAG_POLICIES;
out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
out_cdr << policy_value_seq;
length = out_cdr.total_length ();
tagged_component.component_data.length (static_cast <CORBA::ULong>(length));
buf = tagged_component.component_data.get_buffer ();
for (const ACE_Message_Block *iterator = out_cdr.begin ();
iterator != 0;
iterator = iterator->cont ())
{
size_t const i_length = iterator->length ();
ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
buf += i_length;
}
// Eventually we add the TaggedComponent to the TAO_TaggedComponents
// member variable.
tagged_components_.set_component (tagged_component);
this->are_policies_parsed_ = true;
#else /* TAO_HAS_CORBA_MESSAGING == 1 */
ACE_UNUSED_ARG (policy_list);
ACE_ENV_ARG_NOT_USED; // FUZZ: ignore check_for_ace_check
#endif /* TAO_HAS_CORBA_MESSAGING == 1 */
}
void
TAO_Profile::get_policies (CORBA::PolicyList& pl
ACE_ENV_ARG_DECL)
{
#if (TAO_HAS_CORBA_MESSAGING == 1) && !defined (CORBA_E_MICRO)
if (!this->are_policies_parsed_)
// None has already parsed the policies.
{
IOP::TaggedComponent tagged_component;
tagged_component.tag = Messaging::TAG_POLICIES;
// This gets a component with the proper "tag" field
// if it exists.
if (this->tagged_components_.get_component (tagged_component))
{
const CORBA::Octet *buf =
tagged_component.component_data.get_buffer ();
TAO_InputCDR in_cdr (reinterpret_cast <const char *> (buf),
tagged_component.component_data.length ());
// Extract the Byte Order
CORBA::Boolean byte_order;
if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
{
return ;
}
in_cdr.reset_byte_order (static_cast <int> (byte_order));
// Now we take out the Messaging::PolicyValueSeq out from the
// CDR.
Messaging::PolicyValueSeq policy_value_seq;
if (!(in_cdr >> policy_value_seq))
{
ACE_THROW (CORBA::INV_OBJREF ());
}
// Here we extract the Messaging::PolicyValue out of the sequence
// and we convert those into the proper CORBA::Policy
CORBA::Policy_var policy;
CORBA::ULong const length = policy_value_seq.length ();
// Set the policy list length.
pl.length (length);
for (CORBA::ULong i = 0; i < length; ++i)
{
ACE_TRY_NEW_ENV
{
policy =
this->orb_core_->orb ()->_create_policy (
policy_value_seq[i].ptype
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (!CORBA::is_nil (policy.in ()))
{
buf = policy_value_seq[i].pvalue.get_buffer ();
TAO_InputCDR in_cdr (
reinterpret_cast <const char*> (buf),
policy_value_seq[i].pvalue.length ());
if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
ACE_TRY_THROW (CORBA::INV_OBJREF ());
in_cdr.reset_byte_order (static_cast <int> (byte_order));
policy->_tao_decode (in_cdr);
pl[i] = policy._retn ();
}
else
{
// This case should occure when in the IOR are
// embedded policies that TAO doesn't support,
// so as specified by the RT-CORBA
// spec. ptc/99-05-03 we just ignore these
// un-understood policies.
if (TAO_debug_level >= 5)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("The IOR contains unsupported ")
ACE_TEXT ("policies.\n")));
}
}
ACE_CATCHANY
{
// This case should occur when in the IOR are
// embedded policies that TAO doesn't support, so as
// specified by the RT-CORBA spec. ptc/99-05-03 we
// just ignore these un-understood policies.
if (TAO_debug_level >= 5)
ACE_PRINT_EXCEPTION(ACE_ANY_EXCEPTION,
ACE_TEXT ("IOR contains ")
ACE_TEXT ("unsupported policies."));
}
ACE_ENDTRY;
}
}
}
#else
ACE_UNUSED_ARG (pl);
ACE_ENV_ARG_NOT_USED; // FUZZ: ignore check_for_ace_check
#endif /* (TAO_HAS_CORBA_MESSAGING == 1) */
}
void
TAO_Profile::verify_orb_configuration (ACE_ENV_SINGLE_ARG_DECL)
{
// If the ORB isn't configured to support tagged components, then
// throw an exception.
if (this->orb_core_->orb_params ()->std_profile_components () == 0
|| !this->orb_core_->orb ()->_use_omg_ior_format ())
{
if (TAO_debug_level > 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) Cannot add ")
ACE_TEXT ("IOP::TaggedComponent to profile.\n")
ACE_TEXT ("(%P|%t) Standard profile components ")
ACE_TEXT ("have been disabled or URL style IORs\n")
ACE_TEXT ("(%P|%t) are in use. Try ")
ACE_TEXT ("\"-ORBStdProfileComponents 1\" and/or\n")
ACE_TEXT ("(%P|%t) \"-ORBObjRefStyle IOR\".\n")));
}
// According to the Portable Interceptor specification, we're
// supposed to throw a CORBA::BAD_PARAM exception if it isn't
// possible to add components to the profile.
// @todo: We need the proper minor code as soon as the spec is
// updated.
ACE_THROW (CORBA::BAD_PARAM (
CORBA::SystemException::_tao_minor_code (
0,
EINVAL),
CORBA::COMPLETED_NO));
}
}
void
TAO_Profile::verify_profile_version (ACE_ENV_SINGLE_ARG_DECL)
{
// GIOP 1.0 does not support tagged components. Throw an exception
// if the profile is a GIOP 1.0 profile.
if (this->version_.major == 1 && this->version_.minor == 0)
{
if (TAO_debug_level > 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) Cannot add ")
ACE_TEXT ("IOP::TaggedComponent to GIOP 1.0")
ACE_TEXT ("IOR profile.\n")
ACE_TEXT ("(%P|%t) Try using a GIOP 1.1 or ")
ACE_TEXT ("greater endpoint.\n")));
}
// According to the Portable Interceptor specification, we're
// supposed to throw a CORBA::BAD_PARAM exception if it isn't
// possible to add components to the profile.
// @todo: We need the proper minor code as soon as the spec is
// updated.
ACE_THROW (CORBA::BAD_PARAM (
CORBA::SystemException::_tao_minor_code (
0,
EINVAL),
CORBA::COMPLETED_NO));
}
}
int
TAO_Profile::supports_multicast (void) const
{
// Most profiles do not support multicast endpoints.
return 0;
}
bool
TAO_Profile::supports_non_blocking_oneways (void) const
{
return !(this->version_.major == 1 && this->version_.minor == 0);
}
void
TAO_Profile::addressing_mode (CORBA::Short addr
ACE_ENV_ARG_DECL)
{
// ** See race condition note about addressing mode in Profile.h **
switch (addr)
{
case TAO_Target_Specification::Key_Addr:
case TAO_Target_Specification::Profile_Addr:
case TAO_Target_Specification::Reference_Addr:
this->addressing_mode_ = addr;
break;
default:
ACE_THROW (CORBA::BAD_PARAM (
CORBA::SystemException::_tao_minor_code (
0,
EINVAL),
CORBA::COMPLETED_NO));
}
}
void
TAO_Profile::parse_string (const char *ior
ACE_ENV_ARG_DECL)
{
if (!ior || !*ior)
{
ACE_THROW (CORBA::INV_OBJREF (
CORBA::SystemException::_tao_minor_code (
0,
EINVAL),
CORBA::COMPLETED_NO));
}
// Remove the "N.n@" version prefix, if it exists, and verify the
// version is one that we accept.
// Check for version
if (isdigit (ior [0]) &&
ior[1] == '.' &&
isdigit (ior [2]) &&
ior[3] == '@')
{
// @@ This may fail for non-ascii character sets [but take that
// with a grain of salt]
this->version_.set_version ((char) (ior[0] - '0'),
(char) (ior[2] - '0'));
ior += 4;
// Skip over the "N.n@"
}
else
{
// CORBA spec requires 1.0 if a version isn't specified.
this->version_.set_version (1, 0);
}
if (this->version_.major != TAO_DEF_GIOP_MAJOR ||
this->version_.minor > TAO_DEF_GIOP_MINOR)
{
ACE_THROW (CORBA::INV_OBJREF (
CORBA::SystemException::_tao_minor_code (
0,
EINVAL),
CORBA::COMPLETED_NO));
}
this->parse_string_i (ior
ACE_ENV_ARG_PARAMETER);
}
CORBA::Boolean
TAO_Profile::is_equivalent (const TAO_Profile *other)
{
CORBA::Boolean result = false;
if (other)
{
TAO_Service_Callbacks::Profile_Equivalence callback
= this->is_equivalent_hook (other);
switch (callback)
{
case TAO_Service_Callbacks::DONT_KNOW:
return this->tag () == other->tag ()
&& this->version_ == other->version ()
&& this->endpoint_count () == other->endpoint_count ()
&& this->object_key () == other->object_key ()
&& this->do_is_equivalent (other);
case TAO_Service_Callbacks::EQUIVALENT:
result = true;
break;
case TAO_Service_Callbacks::NOT_EQUIVALENT:
break;
}
}
return result;
}
CORBA::Boolean
TAO_Profile::compare_key (const TAO_Profile *other) const
{
return (this->ref_object_key_ == other->ref_object_key_) ||
((this->ref_object_key_ != 0 &&
other->ref_object_key_ != 0 &&
this->ref_object_key_->object_key() ==
other->ref_object_key_->object_key()));
}
TAO_Endpoint *
TAO_Profile::first_filtered_endpoint (void)
{
TAO_Endpoint *ep = this->endpoint();
return ep == 0 ? 0 : ep->next_filtered(this->orb_core_,0);
}
TAO_Endpoint *
TAO_Profile::next_filtered_endpoint (TAO_Endpoint *source)
{
if (source == 0)
return this->first_filtered_endpoint();
return source->next_filtered(this->orb_core_,this->endpoint());
}
void
TAO_Profile::add_generic_endpoint (TAO_Endpoint *)
{
// noop for the base type
}
TAO_Service_Callbacks::Profile_Equivalence
TAO_Profile::is_equivalent_hook (const TAO_Profile *other)
{
// Allow services to apply their own definition of "equivalence."
return this->orb_core_->is_profile_equivalent (this, other);
}
CORBA::ULong
TAO_Profile::hash_service_i (CORBA::ULong m)
{
return this->orb_core_->hash_service (this, m);
}
/*
* Hook to comment out no op method
* in the base class that is specialized in the
* derived class.
*/
//@@ TAO_PROFILE_SPL_COMMENT_HOOK_START
int
TAO_Profile::encode_alternate_endpoints(void)
{
// this should be a pure virtual, but there are many
// existing specializations that would need to be
// modified. This maintains the existing behavior, since
// the previous version of the POA did not gather alternate
// endpoints.
return 0;
}
void
TAO_Profile::remove_generic_endpoint (TAO_Endpoint *)
{
// default for virtual methods, thus a no-op
}
//@@ TAO_PROFILE_SPL_COMMENT_HOOK_END
//@@ TAO_PROFILE_SPL_METHODS_ADD_HOOK
// ****************************************************************
TAO_Unknown_Profile::TAO_Unknown_Profile (CORBA::ULong tag,
TAO_ORB_Core *orb_core)
: TAO_Profile (tag,
orb_core,
TAO_GIOP_Message_Version (TAO_DEF_GIOP_MAJOR,
TAO_DEF_GIOP_MINOR))
{
}
TAO_Endpoint*
TAO_Unknown_Profile::endpoint (void)
{
return 0;
}
CORBA::ULong
TAO_Unknown_Profile::endpoint_count (void) const
{
return 0;
}
void
TAO_Unknown_Profile::parse_string (const char *
ACE_ENV_ARG_DECL_NOT_USED)
{
// @@ THROW something????
}
void
TAO_Unknown_Profile::parse_string_i (const char *
ACE_ENV_ARG_DECL_NOT_USED)
{
// @@ THROW something????
}
char
TAO_Unknown_Profile::object_key_delimiter (void) const
{
return 0;
}
char *
TAO_Unknown_Profile::to_string (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
{
// @@ THROW something?
return 0;
}
int
TAO_Unknown_Profile::decode (TAO_InputCDR& cdr)
{
if ((cdr >> this->body_) == 0)
{
return -1;
}
return 0;
}
int
TAO_Unknown_Profile::decode_profile (TAO_InputCDR &)
{
return 0;
}
int
TAO_Unknown_Profile::decode_endpoints (void)
{
return 0;
}
int
TAO_Unknown_Profile::encode (TAO_OutputCDR &stream) const
{
stream.write_ulong (this->tag ());
return (stream << this->body_);
}
int
TAO_Unknown_Profile::encode_endpoints (void)
{
return 0;
}
const TAO::ObjectKey &
TAO_Unknown_Profile::object_key (void) const
{
// @@ TODO this is wrong, but the function is deprecated anyway....
static TAO::ObjectKey empty_key;
return empty_key;
}
TAO::ObjectKey *
TAO_Unknown_Profile::_key (void) const
{
return 0;
}
CORBA::Boolean
TAO_Unknown_Profile::do_is_equivalent (const TAO_Profile* other_profile)
{
const TAO_Unknown_Profile * op =
dynamic_cast <const TAO_Unknown_Profile *> (other_profile);
return (CORBA::Boolean) (op == 0 ? 0 : this->body_ == op->body_);
}
TAO_Service_Callbacks::Profile_Equivalence
TAO_Unknown_Profile::is_equivalent_hook (const TAO_Profile * /* other */)
{
// Override the default implementation since we don't need the
// additional checks it performs.
return TAO_Service_Callbacks::DONT_KNOW;
}
CORBA::ULong
TAO_Unknown_Profile::hash (CORBA::ULong max
ACE_ENV_ARG_DECL_NOT_USED)
{
return (ACE::hash_pjw (reinterpret_cast <const char*>
(this->body_.get_buffer ()),
this->body_.length ()) % max);
}
void
TAO_Unknown_Profile::create_profile_body (TAO_OutputCDR &) const
{
// No idea about the profile body! Just return
return;
}
// *************************************************************
// Operators for TAO_opaque encoding and decoding
// *************************************************************
CORBA::Boolean
operator<< (TAO_OutputCDR& cdr, const TAO_opaque& x)
{
CORBA::ULong const length = x.length ();
cdr.write_ulong (length);
#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
if (x.mb () != 0)
{
cdr.write_octet_array_mb (x.mb ());
}
else
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
{
cdr.write_octet_array (x.get_buffer (), length);
}
return (CORBA::Boolean) cdr.good_bit ();
}
CORBA::Boolean
operator>>(TAO_InputCDR& cdr, TAO_opaque& x)
{
CORBA::ULong length;
cdr.read_ulong (length);
#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
if(ACE_BIT_DISABLED(cdr.start()->flags(),
ACE_Message_Block::DONT_DELETE)
&& (cdr.orb_core() == 0
|| 1 == cdr.orb_core()->
resource_factory()->
input_cdr_allocator_type_locked()
)
)
{
x.replace (length, cdr.start ());
x.mb ()->wr_ptr (x.mb ()->rd_ptr () + length);
cdr.skip_bytes (length);
}
else
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
{
x.length (length);
cdr.read_octet_array (x.get_buffer (), length);
}
return (CORBA::Boolean) cdr.good_bit ();
}
TAO_END_VERSIONED_NAMESPACE_DECL
|