This file is indexed.

/usr/include/omniORB4/internal/dynAnyImpl.h is in libomniorb4-dev 4.1.6-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
// -*- Mode: C++; -*-
//                            Package   : omniORB
// dynAny.h                   Created on: 11/1998
//                            Author    : David Riddoch (djr)
//
//    Copyright (C) 2003-2005 Apasphere Ltd
//    Copyright (C) 1996-1999 AT&T Laboratories Cambridge
//
//    This file is part of the omniORB library
//
//    The omniORB library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Library General Public
//    License as published by the Free Software Foundation; either
//    version 2 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Library General Public License for more details.
//
//    You should have received a copy of the GNU Library General Public
//    License along with this library; if not, write to the Free
//    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
//    02111-1307, USA
//
//
// Description:
//   Implementation of CORBA::DynAny.
//

/*
 $Log$
 Revision 1.1.4.4  2005/01/06 16:39:23  dgrisby
 DynValue and DynValueBox implementations; misc small fixes.

 Revision 1.1.4.3  2004/07/23 10:29:57  dgrisby
 Completely new, much simpler Any implementation.

 Revision 1.1.4.2  2004/07/04 23:53:35  dgrisby
 More ValueType TypeCode and Any support.

 Revision 1.1.4.1  2003/03/23 21:03:51  dgrisby
 Start of omniORB 4.1.x development branch.

 Revision 1.1.2.3  2001/10/19 11:04:03  dpg1
 Avoid confusing (to gcc 2.95) inheritance of refcount functions.

 Revision 1.1.2.2  2001/10/17 18:51:51  dpg1
 Fix inevitable Windows problems.

 Revision 1.1.2.1  2001/10/17 16:44:05  dpg1
 Update DynAny to CORBA 2.5 spec, const Any exception extraction.

 Revision 1.1.2.1  2001/04/18 17:18:17  sll
 Big checkin with the brand new internal APIs.
 These files were relocated and scoped with the omni namespace.

 Revision 1.5.2.5  2000/11/17 19:09:37  dpg1
 Support codeset conversion in any.

 Revision 1.5.2.4  2000/11/09 12:27:53  dpg1
 Huge merge from omni3_develop, plus full long long from omni3_1_develop.

 Revision 1.5.2.3  2000/10/06 16:40:53  sll
 Changed to use cdrStream.

 Revision 1.5.2.2  2000/09/27 17:25:41  sll
 Changed include/omniORB3 to include/omniORB4.

 Revision 1.5.2.1  2000/07/17 10:35:41  sll
 Merged from omni3_develop the diff between omni3_0_0_pre3 and omni3_0_0.

 Revision 1.6  2000/07/13 15:26:02  dpg1
 Merge from omni3_develop for 3.0 release.

 Revision 1.2.8.3  1999/10/26 20:18:20  sll
 DynAny no longer do alias expansion on the typecode. In other words, all
 aliases in the typecode are preserved.

 Revision 1.2.8.2  1999/09/22 16:15:59  djr
 Removed MT locking.

*/

#ifndef __DYNANYIMPL_H__
#define __DYNANYIMPL_H__

#include <typecode.h>
#include <omniORB4/anyStream.h>

OMNI_NAMESPACE_BEGIN(omni)

// Node type constants.
#define dt_any        0
#define dt_enum       1
#define dt_fixed      2
#define dt_struct     3
#define dt_union      4
#define dt_seq        5
#define dt_array      6
#define dt_disc       7
#define dt_enumdisc   8
#define dt_value      9
#define dt_value_box  10


// Forward declarations.
class DynAnyImplBase;
class DynAnyImpl;
class DynEnumImpl;
class DynFixedImpl;
class DynAnyConstrBase;
class DynStructImpl;
class DynUnionImpl;
class DynSequenceImpl;
class DynArrayImpl;
class DynValueImpl;
class DynValueBoxImpl;

inline DynAnyImpl*       ToDynAnyImpl      (DynamicAny::DynAny_ptr p);
inline DynAnyImplBase*   ToDynAnyImplBase  (DynamicAny::DynAny_ptr p);
inline DynAnyConstrBase* ToDynAnyConstrBase(DynamicAny::DynAny_ptr p);
inline DynUnionImpl*     ToDynUnionImpl    (DynamicAny::DynAny_ptr p);

// Values used to indicate whether a DynAny is the child of
// another DynAny, or the root.
#define DYNANY_CHILD  0
#define DYNANY_ROOT   1


//////////////////////////////////////////////////////////////////////
/////////////////////////// DynAnyImplBase ///////////////////////////
//////////////////////////////////////////////////////////////////////

//: Functionality common to all DynAny implementations.

class DynAnyImplBase : public virtual DynamicAny::DynAny
{
public:
  DynAnyImplBase(TypeCode_base* tc, int nodetype, CORBA::Boolean is_root)
    : OMNIORB_BASE_CTOR(DynamicAny::)DynAny(0),
      pd_tc(tc), pd_refcount(1), pd_is_root(is_root), pd_destroyed(0)
  {}
  // <tc> is consumed.

  virtual ~DynAnyImplBase();

  /*******************
  * public interface *
  *******************/
  virtual CORBA::TypeCode_ptr type() const;
  
  virtual void from_any(const CORBA::Any& value);
  virtual CORBA::Any* to_any();
  virtual void destroy();

  /***********
  * internal *
  ***********/

  virtual void set_to_initial_value() = 0;
  // Set the DynAny to the default initial value.

  virtual int copy_to(cdrAnyMemoryStream& mbs) = 0;
  // Copies our value into the given stream. Does not flush <mbs>,
  // but does rewind our buffer first. Returns 0 if we are not
  // properly initialised.
  //  Concurrency: hold DynAnyImplBase::lock

  virtual int copy_from(cdrAnyMemoryStream& mbs) = 0;
  // Copies the value from the given stream into this DynAny,
  // replacing the old value. Reads from the stream's current
  // position, and updates the stream's pointers. Returns 0 if there
  // was a problem reading the value out of the stream.
  //  Concurrency: hold DynAnyImplBase::lock

  virtual void onDispose();
  // Called when the reference count goes to zero. This gives the
  // node a chance to detach() any children before it is destroyed.
  // Should be overriden by descendants (which should call their
  // base-class's implementation).
  //  Concurrency: hold DynAnyImplBase::lock

  void detach() { pd_is_root = 1; }
  // Detach this one from its parent - ie. make it a root, so that
  // when it's reference count goes to zero it will be cleaned up.

  void attach() { OMNIORB_ASSERT(pd_is_root); pd_is_root = 0; }
  // Attach to a new parent.

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  TypeCode_base* tc() const { return pd_tc; }

  TypeCode_base* actualTc() const { 
    return (TypeCode_base*)TypeCode_base::NP_expand(pd_tc);
  }
  // Return the typecode. If the typecode is an alias, return the content
  // type.

  CORBA::TCKind tckind() const { return actualTc()->NP_kind(); }
  // Return the TCKind. If the typecode is an alias, return the TCKind of
  // the content type.


  cdrAnyMemoryStream pd_buf;
  // The value held by the DynAny. Basic DynAny values are
  // always stored in the buffer. For complex types it is stored
  // in the buffer when convenient - otherwise in sub-components.

  inline CORBA::Boolean is_root()   const { return pd_is_root; }
  inline CORBA::Boolean destroyed() const { return pd_destroyed; }
  // Assume reading is atomic.

  virtual void* _ptrToObjRef(const char* repoId) = 0;

  static const char* _PD_repoId;
  // Fake repoId for use by _ptrToObjRef

private:
  // TypeCode of the value held.
  TypeCode_base* pd_tc;

  // Reference counting and child management.
  int            pd_refcount;
  CORBA::Boolean pd_is_root;
  CORBA::Boolean pd_destroyed;

  static omni_tracedmutex refCountLock;
};

//////////////////////////////////////////////////////////////////////
///////////////////////////// DynAnyImpl /////////////////////////////
//////////////////////////////////////////////////////////////////////

//: Implementation of DynAny for basic types.

class DynAnyImpl : public DynAnyImplBase
{
public:
  DynAnyImpl(TypeCode_base* tc, int nodetype, CORBA::Boolean is_root=1);
  virtual ~DynAnyImpl();

  /*******************
  * public interface *
  *******************/
  virtual void assign(DynamicAny::DynAny_ptr dyn_any);
  virtual DynamicAny::DynAny_ptr copy();
  virtual CORBA::Boolean equal(DynamicAny::DynAny_ptr dyn_any);

  virtual void insert_boolean   (CORBA::Boolean      	 value);
  virtual void insert_octet     (CORBA::Octet        	 value);
  virtual void insert_char      (CORBA::Char         	 value);
  virtual void insert_short     (CORBA::Short        	 value);
  virtual void insert_ushort    (CORBA::UShort       	 value);
  virtual void insert_long      (CORBA::Long         	 value);
  virtual void insert_ulong     (CORBA::ULong        	 value);
#ifndef NO_FLOAT				 	       
  virtual void insert_float     (CORBA::Float        	 value);
  virtual void insert_double    (CORBA::Double       	 value);
#endif						 	       
  virtual void insert_string    (const char*         	 value);
  virtual void insert_reference (CORBA::Object_ptr   	 value);
  virtual void insert_typecode  (CORBA::TypeCode_ptr 	 value);
#ifdef HAS_LongLong				 	       
  virtual void insert_longlong  (CORBA::LongLong     	 value);
  virtual void insert_ulonglong (CORBA::ULongLong    	 value);
#endif						 	       
#ifdef HAS_LongDouble				 	       
  virtual void insert_longdouble(CORBA::LongDouble   	 value);
#endif						 	       
  virtual void insert_wchar     (CORBA::WChar        	 value);
  virtual void insert_wstring   (const CORBA::WChar* 	 value);
  virtual void insert_any       (const CORBA::Any&   	 value);
  virtual void insert_dyn_any   (DynamicAny::DynAny_ptr  value);
  virtual void insert_val       (CORBA::ValueBase*   	 value);
  virtual void insert_abstract  (CORBA::AbstractBase_ptr value);

  virtual CORBA::Boolean      	  get_boolean();
  virtual CORBA::Octet        	  get_octet();
  virtual CORBA::Char         	  get_char();
  virtual CORBA::Short        	  get_short();
  virtual CORBA::UShort       	  get_ushort();
  virtual CORBA::Long         	  get_long();
  virtual CORBA::ULong        	  get_ulong();
#ifndef NO_FLOAT
  virtual CORBA::Float        	  get_float();
  virtual CORBA::Double       	  get_double();
#endif			 	    
  virtual char*               	  get_string();
  virtual CORBA::Object_ptr   	  get_reference();
  virtual CORBA::TypeCode_ptr 	  get_typecode();
#ifdef HAS_LongLong
  virtual CORBA::LongLong     	  get_longlong();
  virtual CORBA::ULongLong    	  get_ulonglong();
#endif			 	    
#ifdef HAS_LongDouble
  virtual CORBA::LongDouble   	  get_longdouble();
#endif
  virtual CORBA::WChar        	  get_wchar();
  virtual CORBA::WChar*       	  get_wstring();
  virtual CORBA::Any*         	  get_any();
  virtual DynamicAny::DynAny_ptr  get_dyn_any();
  virtual CORBA::ValueBase*       get_val();
  virtual CORBA::AbstractBase_ptr get_abstract();

  virtual void insert_boolean_seq   (CORBA::BooleanSeq&    value);
  virtual void insert_octet_seq     (CORBA::OctetSeq&      value);
  virtual void insert_char_seq      (CORBA::CharSeq&       value);
  virtual void insert_short_seq     (CORBA::ShortSeq&      value);
  virtual void insert_ushort_seq    (CORBA::UShortSeq&     value);
  virtual void insert_long_seq      (CORBA::LongSeq&       value);
  virtual void insert_ulong_seq     (CORBA::ULongSeq&      value);
#ifndef NO_FLOAT
  virtual void insert_float_seq     (CORBA::FloatSeq&      value);
  virtual void insert_double_seq    (CORBA::DoubleSeq&     value);
#endif
#ifdef HAS_LongLong
  virtual void insert_longlong_seq  (CORBA::LongLongSeq&   value);
  virtual void insert_ulonglong_seq (CORBA::ULongLongSeq&  value);
#endif
#ifdef HAS_LongDouble						 
  virtual void insert_longdouble_seq(CORBA::LongDoubleSeq& value);
#endif								 
  virtual void insert_wchar_seq     (CORBA::WCharSeq&      value);

  virtual CORBA::BooleanSeq*    get_boolean_seq();
  virtual CORBA::OctetSeq*      get_octet_seq();
  virtual CORBA::CharSeq*       get_char_seq();
  virtual CORBA::ShortSeq*      get_short_seq();
  virtual CORBA::UShortSeq*     get_ushort_seq();
  virtual CORBA::LongSeq*       get_long_seq();
  virtual CORBA::ULongSeq* 	get_ulong_seq();
#ifndef NO_FLOAT
  virtual CORBA::FloatSeq* 	get_float_seq();
  virtual CORBA::DoubleSeq*     get_double_seq();
#endif
#ifdef HAS_LongLong
  virtual CORBA::LongLongSeq*   get_longlong_seq();
  virtual CORBA::ULongLongSeq*  get_ulonglong_seq();
#endif
#ifdef HAS_LongDouble
  virtual CORBA::LongDoubleSeq* get_longdouble_seq();
#endif
  virtual CORBA::WCharSeq*      get_wchar_seq();

  virtual CORBA::Boolean seek(CORBA::Long index);
  virtual void rewind();
  virtual CORBA::Boolean next();
  virtual CORBA::ULong component_count();
  virtual DynamicAny::DynAny_ptr current_component();

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  virtual int copy_to(cdrAnyMemoryStream& mbs);
  virtual int copy_from(cdrAnyMemoryStream& mbs);

  CORBA::Boolean isValid() const { return pd_isValid; }
  // If true it indicates that the value in the internal
  // buffer is valid.
  //  Must hold DynAnyImplBase::lock.

  void setValid()                { pd_isValid = 1; }
  void setInvalid()              { pd_isValid = 0; }
  // Must hold DynAnyImplBase::lock.

  virtual void* _ptrToObjRef(const char* repoId);

  static const char* _PD_repoId;
  // Fake repoId for use by _ptrToObjRef

protected:
  cdrAnyMemoryStream& doWrite(CORBA::TCKind kind) {
    if( tckind() != kind )  throw DynamicAny::DynAny::TypeMismatch();
    pd_buf.rewindPtrs();
    setValid();
    return pd_buf;
  }

  cdrAnyMemoryStream& doRead(CORBA::TCKind kind) {
    if( tckind() != kind || !isValid())
      throw DynamicAny::DynAny::TypeMismatch();
    pd_buf.rewindInputPtr();
    return pd_buf;
  }

private:
  CORBA::Boolean    pd_isValid;
};

//////////////////////////////////////////////////////////////////////
//////////////////////////// DynFixedImpl ////////////////////////////
//////////////////////////////////////////////////////////////////////

class DynFixedImpl : public DynAnyImpl,
		     public DynamicAny::DynFixed
{
public:
  DynFixedImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynFixedImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual char* get_value();
  virtual CORBA::Boolean set_value(const char* val);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  TypeCode_fixed* actualTc() const {
    return (TypeCode_fixed*) DynAnyImplBase::actualTc();
  }

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);

private:
};

//////////////////////////////////////////////////////////////////////
///////////////////////////// DynEnumImpl ////////////////////////////
//////////////////////////////////////////////////////////////////////

class DynEnumImpl : public DynAnyImpl,
		    public DynamicAny::DynEnum
{
public:
  DynEnumImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynEnumImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual char* get_as_string();
  virtual void set_as_string(const char* value);
  virtual CORBA::ULong get_as_ulong();
  virtual void set_as_ulong(CORBA::ULong value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  TypeCode_enum* actualTc() const {
    return (TypeCode_enum*) DynAnyImplBase::actualTc();
  }

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);
};


//////////////////////////////////////////////////////////////////////
////////////////////////// DynAnyConstrBase //////////////////////////
//////////////////////////////////////////////////////////////////////

//: Base class for constructed type DynAny's.

class DynAnyConstrBase : public DynAnyImplBase
{
public:
  DynAnyConstrBase(TypeCode_base* tc, int nodetype, CORBA::Boolean is_root);
  ~DynAnyConstrBase();

  /*******************
  * public interface *
  *******************/
  virtual void assign(DynamicAny::DynAny_ptr dyn_any);
  virtual CORBA::Boolean equal(DynamicAny::DynAny_ptr dyn_any);

  virtual void insert_boolean   (CORBA::Boolean      	 value);
  virtual void insert_octet     (CORBA::Octet        	 value);
  virtual void insert_char      (CORBA::Char         	 value);
  virtual void insert_short     (CORBA::Short        	 value);
  virtual void insert_ushort    (CORBA::UShort       	 value);
  virtual void insert_long      (CORBA::Long         	 value);
  virtual void insert_ulong     (CORBA::ULong        	 value);
#ifndef NO_FLOAT				 	       
  virtual void insert_float     (CORBA::Float        	 value);
  virtual void insert_double    (CORBA::Double       	 value);
#endif						 	       
  virtual void insert_string    (const char*         	 value);
  virtual void insert_reference (CORBA::Object_ptr   	 value);
  virtual void insert_typecode  (CORBA::TypeCode_ptr 	 value);
#ifdef HAS_LongLong				 	       
  virtual void insert_longlong  (CORBA::LongLong     	 value);
  virtual void insert_ulonglong (CORBA::ULongLong    	 value);
#endif						 	       
#ifdef HAS_LongDouble				 	       
  virtual void insert_longdouble(CORBA::LongDouble   	 value);
#endif						 	       
  virtual void insert_wchar     (CORBA::WChar        	 value);
  virtual void insert_wstring   (const CORBA::WChar* 	 value);
  virtual void insert_any       (const CORBA::Any&   	 value);
  virtual void insert_dyn_any   (DynamicAny::DynAny_ptr  value);
  virtual void insert_val       (CORBA::ValueBase*   	 value);
  virtual void insert_abstract  (CORBA::AbstractBase_ptr value);

  virtual CORBA::Boolean      	  get_boolean();
  virtual CORBA::Octet        	  get_octet();
  virtual CORBA::Char         	  get_char();
  virtual CORBA::Short        	  get_short();
  virtual CORBA::UShort       	  get_ushort();
  virtual CORBA::Long         	  get_long();
  virtual CORBA::ULong        	  get_ulong();
#ifndef NO_FLOAT
  virtual CORBA::Float        	  get_float();
  virtual CORBA::Double       	  get_double();
#endif			 	    
  virtual char*               	  get_string();
  virtual CORBA::Object_ptr   	  get_reference();
  virtual CORBA::TypeCode_ptr 	  get_typecode();
#ifdef HAS_LongLong
  virtual CORBA::LongLong     	  get_longlong();
  virtual CORBA::ULongLong    	  get_ulonglong();
#endif			 	    
#ifdef HAS_LongDouble
  virtual CORBA::LongDouble   	  get_longdouble();
#endif
  virtual CORBA::WChar        	  get_wchar();
  virtual CORBA::WChar*       	  get_wstring();
  virtual CORBA::Any*         	  get_any();
  virtual DynamicAny::DynAny_ptr  get_dyn_any();
  virtual CORBA::ValueBase*       get_val();
  virtual CORBA::AbstractBase_ptr get_abstract();

  virtual void insert_boolean_seq   (CORBA::BooleanSeq&    value);
  virtual void insert_octet_seq     (CORBA::OctetSeq&      value);
  virtual void insert_char_seq      (CORBA::CharSeq&       value);
  virtual void insert_short_seq     (CORBA::ShortSeq&      value);
  virtual void insert_ushort_seq    (CORBA::UShortSeq&     value);
  virtual void insert_long_seq      (CORBA::LongSeq&       value);
  virtual void insert_ulong_seq     (CORBA::ULongSeq&      value);
#ifndef NO_FLOAT
  virtual void insert_float_seq     (CORBA::FloatSeq&      value);
  virtual void insert_double_seq    (CORBA::DoubleSeq&     value);
#endif
#ifdef HAS_LongLong
  virtual void insert_longlong_seq  (CORBA::LongLongSeq&   value);
  virtual void insert_ulonglong_seq (CORBA::ULongLongSeq&  value);
#endif
#ifdef HAS_LongDouble						 
  virtual void insert_longdouble_seq(CORBA::LongDoubleSeq& value);
#endif								 
  virtual void insert_wchar_seq     (CORBA::WCharSeq&      value);

  virtual CORBA::BooleanSeq*    get_boolean_seq();
  virtual CORBA::OctetSeq*      get_octet_seq();
  virtual CORBA::CharSeq*       get_char_seq();
  virtual CORBA::ShortSeq*      get_short_seq();
  virtual CORBA::UShortSeq*     get_ushort_seq();
  virtual CORBA::LongSeq*       get_long_seq();
  virtual CORBA::ULongSeq* 	get_ulong_seq();
#ifndef NO_FLOAT
  virtual CORBA::FloatSeq* 	get_float_seq();
  virtual CORBA::DoubleSeq*     get_double_seq();
#endif
#ifdef HAS_LongLong
  virtual CORBA::LongLongSeq*   get_longlong_seq();
  virtual CORBA::ULongLongSeq*  get_ulonglong_seq();
#endif
#ifdef HAS_LongDouble
  virtual CORBA::LongDoubleSeq* get_longdouble_seq();
#endif
  virtual CORBA::WCharSeq*      get_wchar_seq();

  virtual CORBA::Boolean seek(CORBA::Long index);
  virtual void rewind();
  virtual CORBA::Boolean next();
  virtual CORBA::ULong component_count();
  virtual DynamicAny::DynAny_ptr current_component();

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  virtual int copy_to(cdrAnyMemoryStream& mbs);
  virtual int copy_from(cdrAnyMemoryStream& mbs);
  virtual void onDispose();

  static const char* _PD_repoId;
  // Fake repoId for use by _ptrToObjRef

protected:
  void setNumComponents(unsigned n);
  // May be called by derived classes to set/change the number of
  // components.
  //  Concurrency: hold DynAnyImplBase::lock (unless called from
  //                                          a constructor)

  virtual TypeCode_base* nthComponentTC(unsigned n) = 0;
  // Returns the TypeCode of the n'th component. Overriden by descendants.
  // This does not return a new reference - so it should not be
  // released. <n> MUST be in the range [0..pd_n_components).
  //  Must hold DynAnyImplBase::lock.

  CORBA::TCKind currentKind() {
    return TypeCode_base::NP_expand(nthComponentTC(pd_curr_index))->NP_kind();
  }
  // Return the alias expanded CORBA::TCKind of the current component.
  // There MUST be a valid current component.
  //  Must hold DynAnyImplBase::lock.

  CORBA::Boolean canAppendComponent(unsigned i) const {
    return i == pd_n_really_in_buf && i == pd_n_in_buf && i < pd_first_in_comp;
  }
  // True if the given component can be appended to <pd_buf>.
  // The result is only valid if <i> is in range.
  //  Must hold DynAnyImplBase::lock.

  cdrAnyMemoryStream& writeCurrent(CORBA::TCKind kind) {
    if( pd_curr_index < 0 )
      throw DynamicAny::DynAny::InvalidValue();
    if( currentKind() != kind )
      throw DynamicAny::DynAny::TypeMismatch();
    if( canAppendComponent(pd_curr_index) ) {
      pd_n_in_buf++;
      pd_n_really_in_buf++;
      return pd_buf;
    } else {
      DynAnyImpl* cc = ToDynAnyImpl(getCurrent());
      cc->pd_buf.rewindPtrs();
      cc->setValid();
      return cc->pd_buf;
    }
  }
  // Helper function for writing primitive values into the current
  // component. It returns a reference to the buffer which the value
  // should be inserted into. If the value can be appended to <pd_buf>,
  // then <pd_buf> is returned, otherwise it is the buffer of the
  // child DynAny.
  //  Checks also the there is a current component, and that its type
  // is the same as the value being inserted.
  //  Must hold DynAnyImplBase::lock.

  cdrAnyMemoryStream& readCurrent(CORBA::TCKind kind) {
    if( pd_curr_index < 0 )
      throw DynamicAny::DynAny::InvalidValue();
    if( currentKind() != kind )
      throw DynamicAny::DynAny::TypeMismatch();
    if( pd_curr_index < (int)pd_n_in_buf ) {
      if( pd_read_index != pd_curr_index )  seekTo(pd_curr_index);
      pd_read_index++;
      return pd_buf;
    }
    else if( pd_curr_index >= (int)pd_first_in_comp ) {
      DynAnyImpl* cc = ToDynAnyImpl(getCurrent());
      if( !cc->isValid() )  throw DynamicAny::DynAny::InvalidValue();
      cc->pd_buf.rewindInputPtr();
      return cc->pd_buf;
    }
    else throw DynamicAny::DynAny::InvalidValue();
#ifdef NEED_DUMMY_RETURN
    return pd_buf;
#endif
  }
  // Helper function for reading a primitive value from the current
  // component. Returns a reference to the buffer from which the
  // value may be extracted. It checks that <pd_curr_index> is valid,
  // and the component is of the type expected.
  //  Must hold DynAnyImplBase::lock.

public:
  enum SeqLocation { SEQ_HERE, SEQ_COMPONENT };

protected:
  virtual SeqLocation prepareSequenceWrite(CORBA::TCKind kind,
					   CORBA::ULong len) = 0;
  // Used by insert_..._seq functions. Check if a sequence with the
  // specified kind and length can be inserted, and prepare for the
  // write. Returns SEQ_HERE if it can be inserted in this DynAny's
  // <pd_buf>, SEQ_COMPONENT if it can be inserted in the current
  // component. Throws InvalidValue if no current component or wrong
  // length, TypeMismatch if the kind is wrong.

  virtual SeqLocation prepareSequenceRead(CORBA::TCKind kind) = 0;
  // Used by get_..._seq functions. Check if a sequence with the
  // specified kind can be read. Returns SEQ_HERE if this DynAny is a
  // sequence or array of the specified kind, SEQ_COMPONENT if the
  // current component is a sequence or array of the specified kind.
  // If there is a current component but it's not a sequence of the
  // right kind, throws TypeMismatch; if there is no current
  // component, throws InvalidValue.

  DynAnyImplBase* getCurrent() {
    if( pd_curr_index < (int)pd_first_in_comp )
      createComponent(pd_curr_index);
    return pd_components[pd_curr_index];
  }
  // If not already there, puts the current component (and those
  // following it) into <pd_components>, and returns it. There
  // must be a current component.
  //  Must hold DynAnyImplBase::lock.

  void createComponent(unsigned n);
  // If it does not already exist, create a DynAny for the n'th
  // component. Ensures also that DynAny's are created for all
  // components following that one.
  //  Requires n < pd_n_components.
  //  Must hold DynAnyImplBase::lock.

  void seekTo(unsigned n);
  // Seek the internal buffer so as to read the i'th component.
  //  Does not throw any exceptions.
  //  Requires n < pd_n_in_buf.
  //  Must hold DynAnyImplBase::lock.

  int component_to_any(unsigned i, CORBA::Any& a);
  // Copy the i'th component into <a>. Returns 0 if that
  // component is not properly initialised.
  //  Does not throw any exceptions.
  //  Requires i < pd_n_components.
  //  Must hold DynAnyImplBase::lock.

  int component_from_any(unsigned i, const CORBA::Any& a);
  // Sets the value of the i'th component to that in <a>.
  // Returns 0 if the value in the Any is of the wrong
  // type, or the Any has not been initialised.
  //  Does not throw any exceptions.
  //  Requires i < pd_n_components.
  //  Must hold DynAnyImplBase::lock.

  omnivector<DynAnyImplBase*> pd_components;
  // Sequence of pointers to components that are not stored in <pd_buf>.
  // The length of this sequence is always equal to pd_n_components.

  unsigned pd_n_components;
  // The total number of components this value has.

  unsigned pd_n_in_buf;
  // Components in the range [0..pd_n_in_buf) are in <pd_buf>.
  // pd_n_in_buf <= pd_first_in_comp.

  unsigned pd_n_really_in_buf;
  // The number of components which have actually been written into
  // <pd_buf>. This value may be greater than <pd_n_components> or
  // <pd_first_in_comp>.

  unsigned pd_first_in_comp;
  // Components in the range [pd_first_in_comp..pd_n_components)
  // are in pd_components. Thus those in the range
  // [pd_n_in_buf..pd_first_in_comp) are not yet defined.

  int pd_curr_index;
  // The index of the 'current component'. If this is -1 then
  // there is no current component. If there are zero components
  // then this is always -1.

  int pd_read_index;
  // The index of the component that the buffer's read marker is
  // pointing at. So if pd_curr_index == pd_read_index, and the
  // component is in the buffer, then it can be read out.
};



//////////////////////////////////////////////////////////////////////
//////////////////////////// DynStructImpl ///////////////////////////
//////////////////////////////////////////////////////////////////////

//: DynAny for structure and exception types.

class DynStructImpl : public DynAnyConstrBase,
		      public DynamicAny::DynStruct
{
public:
  DynStructImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynStructImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual char* current_member_name();
  virtual CORBA::TCKind current_member_kind();
  virtual DynamicAny::NameValuePairSeq* get_members();
  virtual void set_members(const DynamicAny::NameValuePairSeq& value);
  virtual DynamicAny::NameDynAnyPairSeq* get_members_as_dyn_any();
  virtual void set_members_as_dyn_any(const DynamicAny::NameDynAnyPairSeq& value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  virtual TypeCode_base* nthComponentTC(unsigned n);
  // Overrides DynAnyConstrBase

  virtual SeqLocation prepareSequenceWrite(CORBA::TCKind kind,
					   CORBA::ULong len);
  virtual SeqLocation prepareSequenceRead(CORBA::TCKind kind);

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);
};



//////////////////////////////////////////////////////////////////////
/////////////////////////// DynUnionDisc /////////////////////////////
//////////////////////////////////////////////////////////////////////

//: DynAny for the discriminator of a union.
// Behaves like a DynAnyImpl, but catches any updates, and informs
// the union (which this is the discriminator of) so that it may
// update its member appropriately.

class DynUnionDisc : public DynAnyImpl {
public:
  DynUnionDisc(TypeCode_base* tc, int nodetype, DynUnionImpl* un)
    : DynAnyImpl(tc, nodetype, DYNANY_CHILD),
      pd_union(un) {}
  virtual ~DynUnionDisc();

  /*******************
  * public interface *
  *******************/
  virtual void assign(DynamicAny::DynAny_ptr dyn_any);

  virtual void insert_boolean   (CORBA::Boolean      	value);
  virtual void insert_octet     (CORBA::Octet        	value);
  virtual void insert_char      (CORBA::Char         	value);
  virtual void insert_short     (CORBA::Short        	value);
  virtual void insert_ushort    (CORBA::UShort       	value);
  virtual void insert_long      (CORBA::Long         	value);
  virtual void insert_ulong     (CORBA::ULong        	value);
#ifndef NO_FLOAT				 	      
  virtual void insert_float     (CORBA::Float        	value);
  virtual void insert_double    (CORBA::Double       	value);
#endif						 	      
  virtual void insert_string    (const char*         	value);
  virtual void insert_reference (CORBA::Object_ptr   	value);
  virtual void insert_typecode  (CORBA::TypeCode_ptr 	value);
#ifdef HAS_LongLong				 	      
  virtual void insert_longlong  (CORBA::LongLong     	value);
  virtual void insert_ulonglong (CORBA::ULongLong    	value);
#endif						 	      
#ifdef HAS_LongDouble				 	      
  virtual void insert_longdouble(CORBA::LongDouble   	value);
#endif						 	      
  virtual void insert_wchar     (CORBA::WChar        	value);
  virtual void insert_wstring   (const CORBA::WChar* 	value);
  virtual void insert_any       (const CORBA::Any&   	value);
  virtual void insert_dyn_any   (DynamicAny::DynAny_ptr value);
  virtual void insert_val       (CORBA::ValueBase*   	 value);
  virtual void insert_abstract  (CORBA::AbstractBase_ptr value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  void set_to_initial_value();

  void detach() {
    pd_union = 0;
    DynAnyImpl::detach();
  }
  virtual void set_value(TypeCode_union::Discriminator v);
  // Must NOT hold DynAnyImplBase::lock.

protected:
  DynUnionImpl* pd_union;
  // Pointer to the parent union, or 0 if detached.
};

//////////////////////////////////////////////////////////////////////
///////////////////////// DynUnionEnumDisc ///////////////////////////
//////////////////////////////////////////////////////////////////////

//: DynAny for the (enum) discriminator of a union.

class DynUnionEnumDisc : public DynUnionDisc,
			 public DynamicAny::DynEnum
{
public:
  DynUnionEnumDisc(TypeCode_base* tc, DynUnionImpl* un);
  virtual ~DynUnionEnumDisc();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual char* get_as_string();
  virtual void set_as_string(const char* value);
  virtual CORBA::ULong get_as_ulong();
  virtual void set_as_ulong(CORBA::ULong value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  void set_to_initial_value();
  virtual void set_value(TypeCode_union::Discriminator v);
  // Must NOT hold DynAnyImplBase::lock.

  TypeCode_enum* actualTc() const {
    return (TypeCode_enum*) DynAnyImplBase::actualTc();
  }

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);
};

//////////////////////////////////////////////////////////////////////
/////////////////////////// DynUnionImpl /////////////////////////////
//////////////////////////////////////////////////////////////////////

class DynUnionImpl : public DynAnyImplBase,
		     public DynamicAny::DynUnion
{
public:
  DynUnionImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynUnionImpl();

  /*******************
  * public interface *
  *******************/
  virtual void assign(DynamicAny::DynAny_ptr dyn_any);
  virtual DynamicAny::DynAny_ptr copy();
  virtual CORBA::Boolean equal(DynamicAny::DynAny_ptr dyn_any);

  virtual void insert_boolean   (CORBA::Boolean      	value);
  virtual void insert_octet     (CORBA::Octet        	value);
  virtual void insert_char      (CORBA::Char         	value);
  virtual void insert_short     (CORBA::Short        	value);
  virtual void insert_ushort    (CORBA::UShort       	value);
  virtual void insert_long      (CORBA::Long         	value);
  virtual void insert_ulong     (CORBA::ULong        	value);
#ifndef NO_FLOAT				 	      
  virtual void insert_float     (CORBA::Float        	value);
  virtual void insert_double    (CORBA::Double       	value);
#endif						 	      
  virtual void insert_string    (const char*         	value);
  virtual void insert_reference (CORBA::Object_ptr   	value);
  virtual void insert_typecode  (CORBA::TypeCode_ptr 	value);
#ifdef HAS_LongLong				 	      
  virtual void insert_longlong  (CORBA::LongLong     	value);
  virtual void insert_ulonglong (CORBA::ULongLong    	value);
#endif						 	      
#ifdef HAS_LongDouble				 	      
  virtual void insert_longdouble(CORBA::LongDouble   	value);
#endif						 	      
  virtual void insert_wchar     (CORBA::WChar        	value);
  virtual void insert_wstring   (const CORBA::WChar* 	value);
  virtual void insert_any       (const CORBA::Any&   	value);
  virtual void insert_dyn_any   (DynamicAny::DynAny_ptr value);
  virtual void insert_val       (CORBA::ValueBase*   	 value);
  virtual void insert_abstract  (CORBA::AbstractBase_ptr value);

  virtual CORBA::Boolean      	  get_boolean();
  virtual CORBA::Octet        	  get_octet();
  virtual CORBA::Char         	  get_char();
  virtual CORBA::Short        	  get_short();
  virtual CORBA::UShort       	  get_ushort();
  virtual CORBA::Long         	  get_long();
  virtual CORBA::ULong        	  get_ulong();
#ifndef NO_FLOAT
  virtual CORBA::Float        	  get_float();
  virtual CORBA::Double       	  get_double();
#endif			 	    
  virtual char*               	  get_string();
  virtual CORBA::Object_ptr   	  get_reference();
  virtual CORBA::TypeCode_ptr 	  get_typecode();
#ifdef HAS_LongLong
  virtual CORBA::LongLong     	  get_longlong();
  virtual CORBA::ULongLong    	  get_ulonglong();
#endif			 	    
#ifdef HAS_LongDouble
  virtual CORBA::LongDouble   	  get_longdouble();
#endif
  virtual CORBA::WChar        	  get_wchar();
  virtual CORBA::WChar*       	  get_wstring();
  virtual CORBA::Any*         	  get_any();
  virtual DynamicAny::DynAny_ptr  get_dyn_any();
  virtual CORBA::ValueBase*       get_val();
  virtual CORBA::AbstractBase_ptr get_abstract();

  virtual void insert_boolean_seq   (CORBA::BooleanSeq&    value);
  virtual void insert_octet_seq     (CORBA::OctetSeq&      value);
  virtual void insert_char_seq      (CORBA::CharSeq&       value);
  virtual void insert_short_seq     (CORBA::ShortSeq&      value);
  virtual void insert_ushort_seq    (CORBA::UShortSeq&     value);
  virtual void insert_long_seq      (CORBA::LongSeq&       value);
  virtual void insert_ulong_seq     (CORBA::ULongSeq&      value);
#ifndef NO_FLOAT
  virtual void insert_float_seq     (CORBA::FloatSeq&      value);
  virtual void insert_double_seq    (CORBA::DoubleSeq&     value);
#endif
#ifdef HAS_LongLong
  virtual void insert_longlong_seq  (CORBA::LongLongSeq&   value);
  virtual void insert_ulonglong_seq (CORBA::ULongLongSeq&  value);
#endif
#ifdef HAS_LongDouble						 
  virtual void insert_longdouble_seq(CORBA::LongDoubleSeq& value);
#endif								 
  virtual void insert_wchar_seq     (CORBA::WCharSeq&      value);

  virtual CORBA::BooleanSeq*    get_boolean_seq();
  virtual CORBA::OctetSeq*      get_octet_seq();
  virtual CORBA::CharSeq*       get_char_seq();
  virtual CORBA::ShortSeq*      get_short_seq();
  virtual CORBA::UShortSeq*     get_ushort_seq();
  virtual CORBA::LongSeq*       get_long_seq();
  virtual CORBA::ULongSeq* 	get_ulong_seq();
#ifndef NO_FLOAT
  virtual CORBA::FloatSeq* 	get_float_seq();
  virtual CORBA::DoubleSeq*     get_double_seq();
#endif
#ifdef HAS_LongLong
  virtual CORBA::LongLongSeq*   get_longlong_seq();
  virtual CORBA::ULongLongSeq*  get_ulonglong_seq();
#endif
#ifdef HAS_LongDouble
  virtual CORBA::LongDoubleSeq* get_longdouble_seq();
#endif
  virtual CORBA::WCharSeq*      get_wchar_seq();

  virtual CORBA::Boolean seek(CORBA::Long index);
  virtual void rewind();
  virtual CORBA::Boolean next();
  virtual CORBA::ULong component_count();
  virtual DynamicAny::DynAny_ptr current_component();

  virtual DynamicAny::DynAny_ptr get_discriminator();
  virtual void set_discriminator(DynamicAny::DynAny_ptr d);
  virtual void set_to_default_member();
  virtual void set_to_no_active_member();
  virtual CORBA::Boolean has_no_active_member();
  virtual CORBA::TCKind discriminator_kind();
  virtual DynamicAny::DynAny_ptr member();
  virtual char*  member_name();
  virtual CORBA::TCKind member_kind();
  virtual CORBA::Boolean is_set_to_default_member();

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);

  static const char* _PD_repoId;
  // Fake repoId for use by _ptrToObjRef

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  virtual int copy_to(cdrAnyMemoryStream& mbs);
  virtual int copy_from(cdrAnyMemoryStream& mbs);
  virtual void onDispose();

  void discriminatorHasChanged();
  // If necassary detaches the old member, and creates a new member
  // of the appropriate type.

  inline TypeCode_union::Discriminator NP_disc_value() const {
    return pd_disc_value;
  }
  inline CORBA::Long NP_disc_index() const {
    return pd_member ? pd_disc_index : -1;
  }

  TypeCode_union* actualTc() const {
    return (TypeCode_union*) DynAnyImplBase::actualTc();
  }

private:
  cdrAnyMemoryStream& writeCurrent(CORBA::TCKind kind) {
    switch( pd_curr_index ) {
    case 0:
      if( kind != pd_disc_kind )  throw DynamicAny::DynAny::TypeMismatch();
      pd_disc->pd_buf.rewindPtrs();
      pd_disc->setValid();
      return pd_disc->pd_buf;
    case 1:
      if( pd_member_kind != kind )  throw DynamicAny::DynAny::TypeMismatch();
      pd_member->pd_buf.rewindPtrs();
      // Must be a DynAnyImpl ...
      ToDynAnyImpl(pd_member)->setValid();
      return pd_member->pd_buf;
    default:
      throw DynamicAny::DynAny::InvalidValue();
    }
#ifdef NEED_DUMMY_RETURN
    return pd_buf;
#endif
  }

  cdrAnyMemoryStream& readCurrent(CORBA::TCKind kind) {
    switch( pd_curr_index ) {
    case 0:
      if( kind != pd_disc_kind || !pd_disc->isValid() )
	throw DynamicAny::DynAny::TypeMismatch();
      pd_disc->pd_buf.rewindInputPtr();
      return pd_disc->pd_buf;
    case 1:
      // If !pd_member, then pd_member_kind == tk_null.
      if( pd_member_kind != kind || !ToDynAnyImpl(pd_member)->isValid() )
	throw DynamicAny::DynAny::TypeMismatch();
      pd_member->pd_buf.rewindInputPtr();
      return pd_member->pd_buf;
    default:
      throw DynamicAny::DynAny::InvalidValue();
    }
#ifdef NEED_DUMMY_RETURN
    return pd_buf;
#endif
  }

  void detachMember() {
    if( pd_member ) {
      pd_member->detach();
      pd_member->destroy();
      pd_member->_NP_decrRefCount();
      pd_member = 0;
      pd_member_kind = CORBA::tk_null;
    }
  }

  /*
  ** DynUnionImpl does not use an internal buffer to store the value.
  ** Instead an instance of a DynAny is created for each of the
  ** discriminator and the member value.
  */

  DynUnionDisc*                 pd_disc;
  TypeCode_base*                pd_disc_type;
  CORBA::TCKind                 pd_disc_kind;
  TypeCode_union::Discriminator pd_disc_value;
  CORBA::Long                   pd_disc_index;  // invalid if !pd_member

  DynAnyImplBase* pd_member;            // may be 0
  CORBA::TCKind   pd_member_kind;       // tk_null if !pd_member

  int pd_curr_index;                    // -1, 0 or 1
};

//////////////////////////////////////////////////////////////////////
///////////////////////// DynSequenceImpl ////////////////////////////
//////////////////////////////////////////////////////////////////////

class DynSequenceImpl : public DynAnyConstrBase,
			public DynamicAny::DynSequence
{
public:
  DynSequenceImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynSequenceImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual CORBA::ULong get_length();
  virtual void set_length (CORBA::ULong len);
  virtual DynamicAny::AnySeq* get_elements();
  virtual void set_elements(const DynamicAny::AnySeq& value);
  virtual DynamicAny::DynAnySeq* get_elements_as_dyn_any();
  virtual void set_elements_as_dyn_any(const DynamicAny::DynAnySeq& value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);

  /***********
  * internal *
  ***********/
  virtual int copy_to(cdrAnyMemoryStream& mbs);
  virtual int copy_from(cdrAnyMemoryStream& mbs);
  virtual TypeCode_base* nthComponentTC(unsigned n);
  // Overrides DynAnyConstrBase

  virtual SeqLocation prepareSequenceWrite(CORBA::TCKind kind,
					   CORBA::ULong len);

  virtual SeqLocation prepareSequenceRead(CORBA::TCKind kind);

private:
  CORBA::ULong pd_bound;  // 0 if unbounded sequence, bound otherwise
};


//////////////////////////////////////////////////////////////////////
/////////////////////////// DynArrayImpl /////////////////////////////
//////////////////////////////////////////////////////////////////////

class DynArrayImpl : public DynAnyConstrBase,
		     public DynamicAny::DynArray
{
public:
  DynArrayImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynArrayImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual DynamicAny::AnySeq* get_elements();
  virtual void set_elements(const DynamicAny::AnySeq& value);
  virtual DynamicAny::DynAnySeq* get_elements_as_dyn_any();
  virtual void set_elements_as_dyn_any(const DynamicAny::DynAnySeq& value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);

  /***********
  * internal *
  ***********/
  virtual TypeCode_base* nthComponentTC(unsigned n);
  // Overrides DynAnyConstrBase

  virtual SeqLocation prepareSequenceWrite(CORBA::TCKind kind,
					   CORBA::ULong len);

  virtual SeqLocation prepareSequenceRead(CORBA::TCKind kind);
private:
};


//////////////////////////////////////////////////////////////////////
//////////////////////////// DynValueImpl ////////////////////////////
//////////////////////////////////////////////////////////////////////

//: DynAny for valuetypes

class DynValueImpl : public DynAnyConstrBase,
		     public DynamicAny::DynValue
{
public:
  DynValueImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynValueImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual CORBA::Boolean is_null();
  virtual void set_to_null();
  virtual void set_to_value();

  virtual char* current_member_name();
  virtual CORBA::TCKind current_member_kind();
  virtual DynamicAny::NameValuePairSeq* get_members();
  virtual void set_members(const DynamicAny::NameValuePairSeq& value);
  virtual DynamicAny::NameDynAnyPairSeq* get_members_as_dyn_any();
  virtual void set_members_as_dyn_any(const DynamicAny::NameDynAnyPairSeq& value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  virtual int copy_to(cdrAnyMemoryStream& mbs);
  virtual int copy_from(cdrAnyMemoryStream& mbs);
  virtual TypeCode_base* nthComponentTC(unsigned n);
  // Overrides DynAnyConstrBase

  virtual SeqLocation prepareSequenceWrite(CORBA::TCKind kind,
					   CORBA::ULong len);
  virtual SeqLocation prepareSequenceRead(CORBA::TCKind kind);

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);

private:
  omniTypedefs::TypeCodeSeq pd_componentTCs;
  CORBA::StringSeq          pd_componentNames;
  CORBA::Boolean            pd_null;
};



//////////////////////////////////////////////////////////////////////
//////////////////////////// DynValueBoxImpl /////////////////////////
//////////////////////////////////////////////////////////////////////

//: DynAny for valueboxes

class DynValueBoxImpl : public DynAnyConstrBase,
			public DynamicAny::DynValueBox
{
public:
  DynValueBoxImpl(TypeCode_base* tc, CORBA::Boolean is_root=1);
  virtual ~DynValueBoxImpl();

  /*******************
  * public interface *
  *******************/
  virtual DynamicAny::DynAny_ptr copy();

  virtual CORBA::Boolean is_null();
  virtual void set_to_null();
  virtual void set_to_value();

  virtual CORBA::Any* get_boxed_value();
  virtual void set_boxed_value(const CORBA::Any& value);
  virtual DynamicAny::DynAny_ptr get_boxed_value_as_dyn_any();
  virtual void set_boxed_value_as_dyn_any(DynamicAny::DynAny_ptr value);

  /****************************
  * exposed private interface *
  ****************************/
  virtual int NP_nodetype() const;

  /***********
  * internal *
  ***********/
  virtual void set_to_initial_value();
  virtual int copy_to(cdrAnyMemoryStream& mbs);
  virtual int copy_from(cdrAnyMemoryStream& mbs);
  virtual TypeCode_base* nthComponentTC(unsigned n);
  // Overrides DynAnyConstrBase

  virtual SeqLocation prepareSequenceWrite(CORBA::TCKind kind,
					   CORBA::ULong len);
  virtual SeqLocation prepareSequenceRead(CORBA::TCKind kind);

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();
  // Must not hold DynAnyImplBase::refCountLock.

  virtual void* _ptrToObjRef(const char* repoId);

private:
  CORBA::Boolean pd_null;
};


//////////////////////////////////////////////////////////////////////
////////////////////////////// Narrowing /////////////////////////////
//////////////////////////////////////////////////////////////////////

// <p> must not be nil.
inline DynAnyImplBase* ToDynAnyImplBase(DynamicAny::DynAny_ptr p)
{
  DynAnyImplBase* daib =
    (DynAnyImplBase*)p->_ptrToObjRef(DynAnyImplBase::_PD_repoId);
  OMNIORB_ASSERT(daib);
  return daib;
}

// <p> must not be nil.
inline DynAnyImpl* ToDynAnyImpl(DynamicAny::DynAny_ptr p)
{
  DynAnyImpl* dai = (DynAnyImpl*)p->_ptrToObjRef(DynAnyImpl::_PD_repoId);
  OMNIORB_ASSERT(dai);
  return dai;
}

// <p> must not be nil.
inline DynAnyConstrBase* ToDynAnyConstrBase(DynamicAny::DynAny_ptr p)
{
  DynAnyConstrBase* dacb = (DynAnyConstrBase*)p->
                                   _ptrToObjRef(DynAnyConstrBase::_PD_repoId);
  OMNIORB_ASSERT(dacb);
  return dacb;
}

// <p> must not be nil.
inline DynUnionImpl* ToDynUnionImpl(DynamicAny::DynAny_ptr p)
{
  DynUnionImpl* daui = (DynUnionImpl*)p->
                                  _ptrToObjRef(DynUnionImpl::_PD_repoId);
  OMNIORB_ASSERT(daui);
  return daui;
}

//////////////////////////////////////////////////////////////////////
/////////////////////////// DynAnyFactoryImpl ////////////////////////
//////////////////////////////////////////////////////////////////////

class DynAnyFactoryImpl : public DynamicAny::DynAnyFactory
{
public:
  DynAnyFactoryImpl() :
    OMNIORB_BASE_CTOR(DynamicAny::)DynAnyFactory(0), pd_refCount(1) {}

  virtual ~DynAnyFactoryImpl();

  // IDL defined functions
  virtual DynamicAny::DynAny_ptr
  create_dyn_any(const CORBA::Any& value);

  virtual DynamicAny::DynAny_ptr
  create_dyn_any_from_type_code(CORBA::TypeCode_ptr type);

  // Internals
  virtual void* _ptrToObjRef(const char* repoId);

  virtual void _NP_incrRefCount();
  virtual void _NP_decrRefCount();

  static DynamicAny::DynAnyFactory_ptr theFactory();

private:
  int pd_refCount;
};


OMNI_NAMESPACE_END(omni)

#endif  // __DYNANYIMPL_H__