summaryrefslogtreecommitdiff
path: root/TAO/tao/Any.cpp
blob: 4a146416b8652a787669ccbb68ec1858e617b8ca (plain)
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
// @ (#) $Id$

// Copyright 1994-1995 by Sun Microsystems Inc.
// All Rights Reserved
//
// ORB:         Implementation of CORBA_Any
//
// This includes three constructors, a destructor, and a "replace"
// method for the "Any" data type.  "Any" values pair a pointer to a
// data structure in the native binary representation (e.g. C struct)
// with a TypeCode that describes that data structure.
//
// The copy constructor and the destructor each use the TypeCode
// interpreter with specialized "visit" callback routines.  The
// "visit" routines are used respectively to make "deep copies" and
// perform "deep frees" of the aritrary values as described by the
// "Any" value's typecode.
//
// Note that these "visit" routines are called directly, and they
// choose whether or not to use the TypeCode interpreter to examine
// constituents.  In the simple cases, the "visit" routines can do
// their work without any further calls; only for constructed types is
// the interpreter's knowledge really required.
//
// THREADING NOTE: "Any" is a data structure which must be protected
// by external critical sections.  Like simpler numeric types, "Any"
// instances are accessed and modified atomically.  This
// implementation is reentrant, so that independent "Any" values may
// be manipulated concurrently when the underlying programming
// environment is itself reentrant.
//

#include "tao/corba.h"

#if !defined (__ACE_INLINE__)
# include "tao/Any.i"
#endif /* ! __ACE_INLINE__ */

ACE_RCSID(tao, Any, "$Id$")

CORBA::TypeCode_ptr
CORBA_Any::type (void) const
{
  return CORBA::TypeCode::_duplicate (this->type_);
}

// TAO doesn't give any guarantees if the value returned by value can be cast
// to the desired type. This is a deprecated routine and its use must be
// avoided. Use the >>= operators.
const void *
CORBA_Any::value (void) const
{
  if (this->any_owns_data_)
    return this->value_;
  else
    return this->cdr_;
}

// Default "Any" constructor -- initializes to nulls per the
// OMG C++ mapping.

// NOTE: null (zero) typecode pointers are also treated as the null
// typecode ...

CORBA_Any::CORBA_Any (void)
  : type_ (CORBA::TypeCode::_duplicate (CORBA::_tc_null)),
    value_ (0),
    cdr_ (0),
    any_owns_data_ (0)
{
}

// The more common "Any" constructor has its own copy of a typecode,
// and either holds or "consumes" an arbitrary data value satisfying
// the normal binary interface rules.

CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr tc,
                      void *value,
                      CORBA::Boolean any_owns_data)
  : type_ (CORBA::TypeCode::_duplicate (tc)),
    value_ (value),
    cdr_ (0),
    any_owns_data_ (any_owns_data)
{
  if (this->value_ != 0)
    {
      CORBA::Environment env;
      TAO_OutputCDR stream;

      // encode the value
      stream.encode (this->type_, this->value_, 0, env);

      // retrieve the start of the message block chain and save it
      this->cdr_ = stream.begin ()->clone ();
    }
}

// Constructor using a message block.
CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr type,
                      const ACE_Message_Block* mb)
  : type_ (CORBA::TypeCode::_duplicate (type)),
    value_ (0),
    cdr_ (ACE_Message_Block::duplicate (mb)),
    any_owns_data_ (1)
{
}

// Copy constructor for "Any".
CORBA_Any::CORBA_Any (const CORBA_Any &src)
  : value_ (0),
    cdr_ (0),
    any_owns_data_ (1)
{
  if (src.type_ != 0)
    this->type_ = CORBA::TypeCode::_duplicate (src.type_);
  else
    this->type_ = CORBA::TypeCode::_duplicate (CORBA::_tc_null);

  CORBA::Environment env;

  // CDR stream always contains encoded object, if any holds anything at all.
  this->cdr_ = ACE_Message_Block::duplicate (src.cdr_);

  // No need to copy src's value_.  We can always get that from cdr.
}

// assignment operator
CORBA_Any &
CORBA_Any::operator= (const CORBA_Any &src)
{
  CORBA::Environment env;

  // check if it is a self assignment
  if (this == &src)
    return *this;

  // decrement the refcount on the Message_Block we hold, it does not
  // matter if we own the data or not, because we always own the
  // message block (i.e. it is always cloned or duplicated.
  ACE_Message_Block::release ((ACE_Message_Block *) this->cdr_);
  this->cdr_ = 0;

  // if we own any previous data, deallocate it
  this->free_value (env);

  if (this->type_ != 0)
    CORBA::release (this->type_);

  // Now copy the contents of the source to ourselves.
  if (src.type_ != 0)
    this->type_ = CORBA::TypeCode::_duplicate (src.type_);
  else
    this->type_ = CORBA::TypeCode::_duplicate (CORBA::_tc_null);
  this->any_owns_data_ = 1;

  this->cdr_ = ACE_Message_Block::duplicate (src.cdr_);
  // Simply duplicate the cdr string here.  We can save the decode operation
  // if there's no need to extract the object.

  return *this;
}

// Destructor for an "Any" deep-frees memory if needed.
//

CORBA_Any::~CORBA_Any (void)
{
  // decrement the refcount on the Message_Block we hold, it does not
  // matter if we own the data or not, because we always own the
  // message block (i.e. it is always cloned or duplicated.
  ACE_Message_Block::release (this->cdr_);
  this->cdr_ = 0;

  CORBA::Environment env;
  this->free_value (env);

  if (this->type_)
    CORBA::release (this->type_);

}

// All-at-once replacement of the contents of an "Any."

void
CORBA_Any::replace (CORBA::TypeCode_ptr tc,
                    const void *value,
                    CORBA::Boolean any_owns_data,
                    CORBA::Environment &env)
{
  // decrement the refcount on the Message_Block we hold, it does not
  // matter if we own the data or not, because we always own the
  // message block (i.e. it is always cloned or duplicated.
  ACE_Message_Block::release (this->cdr_);

  this->free_value (env);

  // Duplicate tc and then release this->type_, just in case tc and
  // type_ are the same thing.
  CORBA::TypeCode_ptr tmp = CORBA::TypeCode::_duplicate (tc);
  CORBA::release (this->type_);
  this->type_ = tmp;

  this->value_ = ACE_const_cast(void *, value);
  this->any_owns_data_ = any_owns_data;
  this->cdr_ = 0;

  // NW: I think an Any should alway owns the CDR stream, so I removed the
  //     check here.
  // if the Any owns the data, we encode the "value" into a CDR stream and
  // store it. We also destroy the "value" since we own it.
  TAO_OutputCDR stream;

  stream.encode (tc, value, 0, env);
  // retrieve the start of the message block chain and duplicate it
  this->cdr_ = ACE_Message_Block::duplicate (stream.begin ());
}

// Free internal data.
void
CORBA_Any::free_value (CORBA::Environment &env)
{
  if (this->any_owns_data_ && this->value_ != 0)
    {
      // This is not exception safe.
      DEEP_FREE (this->type_, this->value_, 0, env);
      ::operator delete (this->value_);
    }
  this->value_ = 0;
}

// insertion of typecode
void
CORBA_Any::operator<<= (CORBA::TypeCode_ptr tc)
{
  CORBA::Environment env;
  CORBA::TypeCode_ptr *_tao_tc;
  ACE_NEW (_tao_tc, CORBA::TypeCode_ptr);
  *_tao_tc = CORBA::TypeCode::_duplicate (tc);
  this->replace (CORBA::_tc_TypeCode,
                 _tao_tc,
                 1,
                 env);
}

// insertion of CORBA object
void
CORBA::Any::operator<<= (const CORBA::Object_ptr obj)
{
  CORBA::Object_ptr objptr = CORBA::Object::_duplicate (obj);
  (*this) <<= &objptr;
}

void
CORBA::Any::operator<<= (CORBA::Object_ptr *objptr)
{
  CORBA::Environment env;
  CORBA::Object_ptr *_tao_object_ptr;
  ACE_NEW (_tao_object_ptr, CORBA::Object_ptr);
  *_tao_object_ptr = *objptr;
  this->replace (CORBA::_tc_Object,
                 _tao_object_ptr,
                 1,
                 env);
}

// insertion of from_string
void
CORBA_Any::operator<<= (from_string s)
{
  // If the inserted string is bounded, we create a typecode.
  static CORBA::Long _oc_string [] =
  {
    // CDR typecode octets
    TAO_ENCAP_BYTE_ORDER,   // native endian + padding; "tricky"
    0                       // ... unbounded string to start with
  };

  CORBA::TypeCode_ptr tc = 0;
  if (s.bound_ > 0)
  {
    // Bounded string.
    _oc_string [1] = s.bound_;
    ACE_NEW (tc, CORBA::TypeCode (CORBA::tk_string,
                                  sizeof _oc_string,
                                  (char *) &_oc_string,
                                  1,
                                  sizeof (CORBA::String_var)));
  }
  else
  tc = CORBA::_tc_string; // unbounded.

  CORBA::Environment env;
  if (s.nocopy_)
  this->replace (tc, new char* (s.val_), 1, env);
  else
  // copying
  this->replace (tc, new char* (CORBA::string_dup (s.val_)),
                 1, env);
}

// Extraction: these are safe and hence we have to check that the
// typecode of the Any is equal to the one we are trying to extract
// into

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::Short &s) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_short, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      s = *(CORBA::Short *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_short (s);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::UShort &s) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_ushort, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      s = *(CORBA::UShort *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_ushort (s);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::Long &l) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_long, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      l = *(CORBA::Long *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_long (l);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::ULong &l) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_ulong, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      l = *(CORBA::ULong *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_ulong (l);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::LongLong &l) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_longlong, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      l = *(CORBA::LongLong *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_longlong (l);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::ULongLong &l) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_ulonglong, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      l = *(CORBA::ULongLong *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_ulonglong (l);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::Float &f) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_float, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      f = *(CORBA::Float *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_float (f);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::Double &d) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_double, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      d = *(CORBA::Double *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      return stream.read_double (d);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::Any &a) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_any, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      a = *(CORBA::Any *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      // decode the CDR
      return (stream.decode (CORBA::_tc_any, &a, 0, env)
              == CORBA::TypeCode::TRAVERSE_CONTINUE) ? 1 : 0;
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (char *&s) const
{
  CORBA::Environment env;

  if (this->type_->equal (CORBA::_tc_string, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      s = *(char **) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream (this->cdr_);
      if (stream.read_string (s))
      {
        ACE_const_cast(CORBA_Any*, this)->any_owns_data_ = 1;
        char** tmp = new char*;
        *tmp = s;
        ACE_const_cast(CORBA_Any*, this)->value_ = tmp;
        return 1;
      }
      return 0;
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (CORBA::TypeCode_ptr &tc) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_TypeCode, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      tc = *(CORBA::TypeCode_ptr *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
      CORBA::Boolean flag =
      (stream.decode (CORBA::_tc_TypeCode,
                      &tc,
                      0,
                      env)
       == CORBA::TypeCode::TRAVERSE_CONTINUE) ? 1 : 0;
      return flag;
    }
  }
  else
  return 0;
}

// = extraction into the special types

CORBA::Boolean
CORBA_Any::operator>>= (to_boolean b) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_boolean, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      b.ref_ = *(CORBA::Boolean *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
      return stream.read_boolean (b.ref_);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (to_octet o) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_octet, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      o.ref_ = *(CORBA::Octet *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
      return stream.read_octet (o.ref_);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (to_char c) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_char, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      c.ref_ = *(CORBA::Char *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
      return stream.read_char (c.ref_);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (to_wchar wc) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_wchar, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      wc.ref_ = *(CORBA::WChar *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
      return stream.read_wchar (wc.ref_);
    }
  }
  else
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (to_string s) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_string, env))
  {
    CORBA::ULong bound = this->type_->length (env);
    if (s.bound_ == bound) // bounds are same
    {
      if (this->any_owns_data_ && this->value_)
      {
        s.val_ = *(char **) this->value_;
        return 1;
      }
      else
      {
        TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
        if (stream.read_string (s.val_))
        {
          ACE_const_cast (CORBA_Any*, this)->any_owns_data_ = 1;
          return 1;
        }
      }
    }
  }

  // Otherwise.
  return 0;
}

CORBA::Boolean
CORBA_Any::operator>>= (to_object obj) const
{
  CORBA::Environment env;

  if (this->type_->equivalent (CORBA::_tc_Object, env))
  {
    if (this->any_owns_data_ && this->value_)
    {
      obj.ref_ = *(CORBA::Object_ptr *) this->value_;
      return 1;
    }
    else
    {
      TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_);
      CORBA::Boolean flag = (stream.decode (CORBA::_tc_Object,
                                            &obj.ref_, 0, env)
                             == CORBA::TypeCode::TRAVERSE_CONTINUE) ? 1:0;
      if (flag)
      {
        CORBA::Object_ptr *tmp = new CORBA::Object_ptr;
        *tmp = obj.ref_;
        ACE_const_cast(CORBA_Any*,this)->value_ = tmp;
        return 1;
      }
      // we own this allocated value
      //          this->value_ = obj.ref_;
      return flag;
    }
  }
  else
  return 0;
}

// ----------------------------------------------------------------------
// Any_var type
// ----------------------------------------------------------------------

CORBA::Any_var &
CORBA_Any_var::operator= (CORBA::Any *p)
{
  if (this->ptr_ != p)
  {
    if (this->ptr_ != 0)
    delete (this->ptr_);

    this->ptr_ = p;
  }
  return *this;
}

CORBA::Any_var &
CORBA_Any_var::operator= (const CORBA::Any_var& r)
{
  if (this->ptr_ != 0)
  delete this->ptr_;

  this->ptr_ = new CORBA::Any (*r.ptr_);
  return *this;
}

// = Debugging method.

// Prints the type and the value of the any value. Dumping is
// supported only for standard data types.

void
CORBA_Any::dump (const CORBA::Any any_value)
{
  CORBA::Environment env;

  // Get the type.
  CORBA::TypeCode_var type = any_value.type ();

  if (type->equal (CORBA::_tc_null, env))
    ACE_DEBUG ((LM_DEBUG,"Null\n"));

  else if (type->equal (CORBA::_tc_void, env))
    ACE_DEBUG ((LM_DEBUG,"Void\n"));

  else if (type->equal (CORBA::_tc_short, env))
    {
      CORBA::Short s;
      any_value >>= s;
      ACE_DEBUG ((LM_DEBUG,"Short %d\n",s));
    }
  else if (type->equal (CORBA::_tc_long, env))
    {
      CORBA::Long l;
      any_value >>= l;
      ACE_DEBUG ((LM_DEBUG,"Long %d\n", l));
    }
  else if (type->equal (CORBA::_tc_ushort, env))
    {
      CORBA::UShort s;
      any_value >>= s;
      ACE_DEBUG ((LM_DEBUG,"UShort %d\n", s));
    }
  else if (type->equal (CORBA::_tc_ulong, env))
    {
      CORBA::ULong l;
      any_value >>= l;
      ACE_DEBUG ((LM_DEBUG,"ULong %d\n", l));
    }
  else if (type->equal (CORBA::_tc_float, env))
    {
      CORBA::Float f;
      any_value >>= f;
      ACE_DEBUG ((LM_DEBUG,"Float %f\n", f));
    }
  else if (type->equal (CORBA::_tc_double, env))
    {
      CORBA::Double d;
      any_value >>= d;
      ACE_DEBUG ((LM_DEBUG,"Double %f\n", d));
    }
  else if (type->equal (CORBA::_tc_boolean, env))
    {
      CORBA::Boolean b;
      any_value >>= (to_boolean)b;
      if (b == 1)
        ACE_DEBUG ((LM_DEBUG, "Boolean TRUE\n"));
      else
        ACE_DEBUG ((LM_DEBUG, "Boolean FALSE\n"));
    }
  else if (type->equal (CORBA::_tc_char, env))
    {
      CORBA::Char ch;
      any_value >>= to_char (ch);
      ACE_DEBUG ((LM_DEBUG,"Char %c\n", ch));
    }
  else if (type->equal (CORBA::_tc_string, env))
    {
      CORBA::String str;
      any_value >>= str;
      ACE_DEBUG ((LM_DEBUG, "String %s\n", str));
    }
  else
    ACE_DEBUG ((LM_DEBUG, "TCKind %d\n", type->kind_));
}