summaryrefslogtreecommitdiff
path: root/TAO/tao/ORB.h
blob: 142ad97a661fd86a7f61d927337d0bae34c518bb (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
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
// This may look like C, but it's really -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    ORB.h
//
// = DESCRIPTION
//     Header file for CORBA's <ORB> type and <CORBA> type.
//
// = AUTHOR
//     Copyright 1994-1995 by Sun Microsystems Inc. and Douglas C. Schmidt.
//
// ============================================================================

#if !defined (TAO_ORB_H)
#  define TAO_ORB_H

#include "tao/corba.h"

// ObjectIds recognized by CORBA_ORB::resolve_initial_references ()...
// of course, no guarantees are made that the call will return
// something useful.
#define TAO_OBJID_NAMESERVICE      "NameService"
#define TAO_OBJID_TRADINGSERVICE   "TradingService"
#define TAO_OBJID_ROOTPOA          "RootPOA"
#define TAO_DEFAULT_ROOTPOA_NAME   ""
#define TAO_OBJID_POACURRENT       "POACurrent"
#define TAO_OBJID_INTERFACEREP     "InterfaceRepository"

typedef enum
{
  TAO_SERVICEID_NAMESERVICE,
  TAO_SERVICEID_TRADINGSERVICE
} TAO_Service_ID;

// For some reason, PC compilers don't implement "natural" alignment,
// but only use fixed alignment policies.  The following #pragmas
// configure fixed one-byte alignment policy, since some fixed policy
// needs to apply throughout an ORB.

#if defined (_MSC_VER)
# pragma  pack (push, 1)          // VC++, stack 1-byte alignment policy
# ifdef   _DEBUG                  // convert from VC++ convention ...
#   define  DEBUG           // ... to normal convention
# endif
#elif defined (__BORLANDC__)
# pragma option -a                // BC++, use 1 byte alignment
#endif

#if !defined (TAO_CONST)
// Something to document the fact that we want to put 'const' in front
// of a type, but that it won't turn out the way we want, e.g., we
// really want to express that a CORBA_String is const, but since
// CORBA_String is a char*, the const modifies the pointer and not the
// pointed-to, and some compilers (like SGI's EDG-derived thang)
// complain.
#define TAO_CONST
#endif /* TAO_CONST */

// Forward declarations of some data types are needed.

class TAO_POA_Manager;
class TAO_POA_Policies;
class TAO_Object_Table;

class CORBA_Any;
class CORBA_Any_var;
class CORBA_Any_out;
//typedef class CORBA_Any *CORBA_Any_ptr;

class CORBA_TypeCode;
class CORBA_TypeCode_var;
class CORBA_TypeCode_out;
//typedef class CORBA_TypeCode *CORBA_TypeCode_ptr;

class CORBA_Exception;
//typedef class CORBA_Exception *CORBA_Exception_ptr;

class CORBA_Request;
class CORBA_Request_var;
class CORBA_Request_out;
//typedef class CORBA_Request *CORBA_Request_ptr;

class CORBA_NamedValue;
class CORBA_NamedValue_var;
class CORBA_NamedValue_out;
//typedef class CORBA_NamedValue *CORBA_NamedValue_ptr;

class CORBA_NVList;
class CORBA_NVList_var;
class CORBA_NVList_out;
//typedef class CORBA_NVList *CORBA_NVList_ptr;

class CORBA_ORB;
class CORBA_ORB_var;
class CORBA_ORB_out;
//typedef class CORBA_ORB *CORBA_ORB_ptr;

class CORBA_Object;
class CORBA_Object_var;
class CORBA_Object_out;
//typedef class CORBA_Object *CORBA_Object_ptr;

class CORBA_ServerRequest;
//typedef class CORBA_ServerRequest *CORBA_ServerRequest_ptr;

class CORBA_Environment;
//typedef class CORBA_Environment *CORBA_Environment_ptr;

class CORBA_Principal;
//typedef class CORBA_Principal *CORBA_Principal_ptr;

class CORBA_SystemException;
class CORBA_UserException;

class CORBA_Policy;
class CORBA_Policy_var;
class CORBA_Policy_out;

class CORBA_PolicyList;
class CORBA_PolicyList_var;
class CORBA_PolicyList_out;

class CORBA_Current;
class CORBA_Current_var;
class CORBA_Current_out;

// forward declarations of system exceptions
#define TAO_SYSTEM_EXCEPTION(name) class CORBA_ ## name

TAO_SYSTEM_EXCEPTION(UNKNOWN);
TAO_SYSTEM_EXCEPTION(BAD_PARAM);
TAO_SYSTEM_EXCEPTION(NO_MEMORY);
TAO_SYSTEM_EXCEPTION(IMP_LIMIT);
TAO_SYSTEM_EXCEPTION(COMM_FAILURE);
TAO_SYSTEM_EXCEPTION(INV_OBJREF);
TAO_SYSTEM_EXCEPTION(OBJECT_NOT_EXIST);
TAO_SYSTEM_EXCEPTION(NO_PERMISSION);
TAO_SYSTEM_EXCEPTION(INTERNAL);
TAO_SYSTEM_EXCEPTION(MARSHAL);
TAO_SYSTEM_EXCEPTION(INITIALIZE);
TAO_SYSTEM_EXCEPTION(NO_IMPLEMENT);
TAO_SYSTEM_EXCEPTION(BAD_TYPECODE);
TAO_SYSTEM_EXCEPTION(BAD_OPERATION);
TAO_SYSTEM_EXCEPTION(NO_RESOURCES);
TAO_SYSTEM_EXCEPTION(NO_RESPONSE);
TAO_SYSTEM_EXCEPTION(PERSIST_STORE);
TAO_SYSTEM_EXCEPTION(BAD_INV_ORDER);
TAO_SYSTEM_EXCEPTION(TRANSIENT);
TAO_SYSTEM_EXCEPTION(FREE_MEM);
TAO_SYSTEM_EXCEPTION(INV_IDENT);
TAO_SYSTEM_EXCEPTION(INV_FLAG);
TAO_SYSTEM_EXCEPTION(INTF_REPOS);
TAO_SYSTEM_EXCEPTION(BAD_CONTEXT);
TAO_SYSTEM_EXCEPTION(OBJ_ADAPTER);
TAO_SYSTEM_EXCEPTION(DATA_CONVERSION);
#undef TAO_SYSTEM_EXCEPTION

typedef class CORBA_ImplementationDef *
        CORBA_ImplementationDef_ptr;

typedef class CORBA_InterfaceDef *
        CORBA_InterfaceDef_ptr;

// =Forward declarations
struct TAO_Dispatch_Context;
class TAO_Object_Table_Impl;
class TAO_Operation_Table;
class TAO_Client_Strategy_Factory;
class TAO_Server_Strategy_Factory;
class TAO_ORB_Parameters;
class TAO_InputCDR;
class TAO_OutputCDR;

// The new (POA) base class for servants.
class TAO_ServantBase;

// enum values defined in nvlist.h, bitwise ORed.
typedef u_int CORBA_Flags;

#if defined (ghs) && defined (CHORUS)
  // This is non-compliant, but a nasty but with Green Hills C++68000 1.8.8
  // forces us into it.  TAO/tests/POA/RootPOA/RootPOA reveals the problem.
  typedef ACE_UINT32 CORBA_Boolean;
#else  /* ! (ghs && CHORUS) */
  typedef u_char CORBA_Boolean;
#endif /* ! (ghs && CHORUS) */

  typedef struct TAO_Leader_Follower_Info_Struct
    {
      ACE_SYNCH_MUTEX leader_follower_lock_; 
      // do protect the access to the following three members
  
      ACE_Unbounded_Set<ACE_SYNCH_CONDITION *> follower_set_;
      // keep a set of followers around (protected)

      int leaders_; 
      // 0 if no leader is around, 1 if there is a leader
      // > 1 if we do nested upcalls (protected)

      ACE_thread_t leader_thread_ID_;
      // thread ID of the leader thread (protected)
    } TAO_Leader_Follower_Info;


// forward declare sequences.
template <class T> class TAO_Unbounded_Sequence;
template <class T> class TAO_Unbounded_Object_Sequence;

class TAO_Export CORBA
{
  // = TITLE
  //    Provides the CORBA namespace.
  //
  // = DESCRIPTION
  //    This class allows the use of CORBA::Foo, as well as CORBA_Foo
  //    for all standard types Foo.
public:

  typedef CORBA_Boolean Boolean;
  typedef Boolean &Boolean_out;
  // Out type for boolean.

  static Boolean B_FALSE;
  static Boolean B_TRUE;

  typedef u_char Octet;
  typedef Octet  &Octet_out;
  // Out type for octet.

  typedef ACE_INT16 Short;
  typedef Short &Short_out;
  // Out type for Short.

  typedef ACE_UINT16 UShort;
  typedef UShort &UShort_out;
  // Out type for UShort.

  // = CORBA "Long" (and its unsigned cousin) are 32 bits.
  typedef ACE_INT32 Long;
  typedef ACE_UINT32 ULong;

  // 94-9-32 Appendix A, also the OMG C++ mapping, stipulate that 64
  // bit integers are "LongLong".
  typedef Long &Long_out;
  // Out type for long.

  typedef ULong &ULong_out;
  // Out type for unsigned long.

  // = The following are IDL extensions, not yet standard.

  typedef ACE_UINT64 ULongLong;
# if defined (_MSC_VER) && _MSC_VER >= 900
    typedef __int64 LongLong;
# elif ACE_SIZEOF_LONG == 8
    typedef long LongLong;
# elif ACE_SIZEOF_LONG_LONG == 8 && !defined (ACE_LACKS_LONGLONG_T)
#   if defined (sun) && !defined (ACE_LACKS_U_LONGLONG_T)
      // sun #defines u_longlong_t, maybe other platforms do also.
      // Use it, at least with g++, so that its -pedantic doesn't
      // complain about no ANSI C++ long long.
      typedef longlong_t LongLong;
#   else
      // LynxOS 2.5.0 and Linux don't have u_longlong_t.
      typedef long long LongLong;
#   endif /* sun */
# else  /* no native 64 bit integer type */

    // If "long long" isn't native, programs can't use these data
    // types in normal arithmetic expressions.  If any particular
    // application can cope with the loss of range, it can define
    // conversion operators itself.
#   define NONNATIVE_LONGLONG
#   if defined (ACE_BIG_ENDIAN)
      struct LongLong { Long h, l; };
#   else
      struct LongLong { Long l, h; };
#   endif /* ! ACE_BIG_ENDIAN */
# endif /* no native 64 bit integer type */

  typedef LongLong &LongLong_out;
  // Out type for long long.

  typedef ULongLong &ULongLong_out;
  // Out type for unsigned long long.

# if ACE_SIZEOF_FLOAT == 4
    typedef float Float;
# else  /* ACE_SIZEOF_FLOAT != 4 */
#   define TAO_NONNATIVE_FLOAT
    struct Float
    {
#     if ACE_SIZEOF_INT == 4
        // Use u_int to get word alignment.
        u_int f;
#     else  /* ACE_SIZEOF_INT != 4 */
        // Applications will probably have trouble with this.
        char f[4];
#     endif /* ACE_SIZEOF_INT != 4 */
    };
# endif /* ACE_SIZEOF_FLOAT != 4 */
  typedef Float &Float_out; // out type for float

# if ACE_SIZEOF_DOUBLE == 8
    typedef double Double;
# else  /* ACE_SIZEOF_DOUBLE != 8 */
#   define TAO_NONNATIVE_DOUBLE
    struct Double
    {
#     if ACE_SIZEOF_LONG == 8
        // Use u_long to get word alignment.
        u_long f;
#     else  /* ACE_SIZEOF_INT != 8 */
        // Applications will probably have trouble with this.
        char f[8];
#     endif /* ACE_SIZEOF_INT != 8 */
    };
# endif /* ACE_SIZEOF_DOUBLE != 8 */
  typedef Double &Double_out;
  // Out type for double.

  // 94-9-32 Appendix A defines a 128 bit floating point "long double"
  // data type, with greatly extended precision and four more bits of
  // exponent (compared to "double").  This is an IDL extension, not
  // yet standard.

#  if   ACE_SIZEOF_LONG_DOUBLE == 16
  typedef long double LongDouble;
#  else
#    define NONNATIVE_LONGDOUBLE
  struct LongDouble
  {
    char ld[16];
  };
#  endif /* ACE_SIZEOF_LONG_DOUBLE != 16 */

  typedef LongDouble &LongDouble_out;
  // Out type for long doubles.

  typedef char Char;
  typedef Char &Char_out;
  // Out type for char.

  typedef TAO_Unbounded_Sequence<Octet> OctetSeq;

  typedef Char *String;

  // = String memory management.
  static String string_alloc (ULong len);
  static String string_copy (const Char *);
  static String string_dup (const Char *);
  static void string_free (Char *);

  class TAO_Export String_var
  {
    // = TITLE
    //   String var class. Provides automatic deallocation of storage
    //   for the string once it goes out of scope.
  public:
    String_var (void);
    // default constructor.

    String_var (char *p);
    // constructor, owns p.

    String_var (const char *p);
    // constructor. Makes a copy of p.

    String_var (const String_var &s);
    // copy constructor.

    ~String_var (void);
    // destructor.

    String_var &operator= (char *p);
    // assignment operator.

    String_var &operator= (const char *p);
    // assignment to a const char*.  Makes a copy.

    String_var &operator= (const String_var &s);
    // assignment operator.

    operator char *();
    // access and modify.

    operator const char *() const;
    // only read privileges.

    char &operator[] (ULong index);
    // allows access and modification using an index.

    char operator[] (ULong index) const;
    // allows only accessing thru an index.

    // = in, out, out, and _retn operations.
    // ORBOS/97-05-15, Appendix C.2

    const char *in (void) const;
    // for in parameter.

    char *&inout (void);
    // for inout parameter.

    char *&out (void);
    // for out parameter.

    char *_retn (void);
    // for string of return type.

  private:
    char *ptr_;
    // instance.
  };

  class TAO_Export String_out
  {
    // = TITLE
    //   String_out
    //
    // = DESCRIPTION
    //   To support the memory management for "out" parameter passing
    //   mode.  ORBOS/97-05-15, Appendix C.2 defines a String_out class
  public:
    // = operations.

    String_out (char *&p);
    // Construction from a reference to a string.

    String_out (String_var &p);
    // Construction from a var.

    String_out (String_out &s);
    // Copy constructor.

    String_out &operator= (String_out &s);
    // Assignment from a string_out.

    String_out &operator= (char *p);
    // Assignment from a string.

    String_out &operator= (const char *p);
    // Assignment from a const string.

    operator char *&();
    // Cast.

    char *&ptr (void);
    // Return underlying instance.

  private:
    char *&ptr_;
    // Instance.

    // assignment from _var disallowed
    void operator= (const String_var &);
  };

  // WChar is an IDL extension, not yet standard.  We use 32 bits
  // because that's what many platforms use for their native wchar_t.

  typedef ACE_OS::WChar WChar;
  typedef WChar *WString;

  typedef WChar &WChar_out;
  // Out type for WChar.

  // = String memory management routines.
  static WString wstring_alloc (ULong len);
  static WString wstring_copy (const WChar *const);
  static WString wstring_dup (const WChar *const);
  static void wstring_free (WChar *const);

  // = various CORBA defined classes.
  typedef CORBA_Any Any;
  typedef CORBA_Any_var Any_var;
  typedef CORBA_Any_out Any_out;
  typedef Any *Any_ptr;

  typedef CORBA_Environment Environment;
  typedef Environment *Environment_ptr;

  typedef CORBA_Exception Exception;
  typedef Exception *Exception_ptr;

  typedef CORBA_NamedValue NamedValue;
  typedef NamedValue *NamedValue_ptr;
  typedef CORBA_NamedValue_var NamedValue_var;
  typedef CORBA_NamedValue_out NamedValue_out;

  typedef CORBA_NVList NVList;
  typedef NVList *NVList_ptr;
  typedef CORBA_NVList_var NVList_var;
  typedef CORBA_NVList_out NVList_out;

  typedef CORBA_Object Object;
  typedef CORBA_Object *Object_ptr;
  typedef CORBA_Object_var Object_var;
  typedef CORBA_Object_out Object_out;

  typedef CORBA_Principal Principal;
  typedef CORBA_Principal *Principal_ptr;

  typedef CORBA_ORB ORB;
  typedef CORBA_ORB *ORB_ptr;
  typedef CORBA_ORB_var ORB_var;
  typedef CORBA_ORB_out ORB_out;

  typedef CORBA_Request Request; 
  typedef Request *Request_ptr;
  typedef CORBA_Request_var Request_var;
  typedef CORBA_Request_out Request_out;

  typedef CORBA_ServerRequest ServerRequest;
  typedef ServerRequest *ServerRequest_ptr;

  typedef CORBA_SystemException SystemException;

  typedef CORBA_TypeCode TypeCode;
  typedef TypeCode *TypeCode_ptr;
  typedef CORBA_TypeCode_var TypeCode_var;
  typedef CORBA_TypeCode_out TypeCode_out;

  typedef CORBA_UserException  UserException;

  typedef CORBA_ExceptionList ExceptionList;
  typedef CORBA_ExceptionList *ExceptionList_ptr;

  typedef CORBA_ImplementationDef *ImplementationDef_ptr;

  typedef class CORBA_InterfaceDef *InterfaceDef_ptr;


  typedef CORBA_Policy Policy;
  typedef CORBA_Policy *Policy_ptr;
  typedef CORBA_Policy_var Policy_var;
  typedef CORBA_Policy_out Policy_out;

  typedef CORBA_PolicyList PolicyList;
  typedef CORBA_PolicyList_var PolicyList_var;
  typedef CORBA_PolicyList_out PolicyList_out;

  typedef CORBA_Current Current;
  typedef CORBA_Current *Current_ptr;
  typedef CORBA_Current_var Current_var;
  typedef CORBA_Current_out Current_out;

  // enum values defined in nvlist.hh, bitwise ORed.
  typedef u_int Flags;

  enum CompletionStatus
  {
    // = Completion Status for System exceptions

    COMPLETED_YES,     // successful or exceptional completion
    COMPLETED_NO,      // didn't change any state; retry is OK
    COMPLETED_MAYBE    // can't say what happened; retry unsafe
  };

  enum ExceptionType
  {
    // = Exception type.

    NO_EXCEPTION,
    SYSTEM_EXCEPTION,
    USER_EXCEPTION
  };

  // all the system exception classes
#define TAO_SYSTEM_EXCEPTION(name) \
  typedef CORBA_ ## name      name
  TAO_SYSTEM_EXCEPTION(UNKNOWN);
  TAO_SYSTEM_EXCEPTION(BAD_PARAM);
  TAO_SYSTEM_EXCEPTION(NO_MEMORY);
  TAO_SYSTEM_EXCEPTION(IMP_LIMIT);
  TAO_SYSTEM_EXCEPTION(COMM_FAILURE);
  TAO_SYSTEM_EXCEPTION(INV_OBJREF);
  TAO_SYSTEM_EXCEPTION(OBJECT_NOT_EXIST);
  TAO_SYSTEM_EXCEPTION(NO_PERMISSION);
  TAO_SYSTEM_EXCEPTION(INTERNAL);
  TAO_SYSTEM_EXCEPTION(MARSHAL);
  TAO_SYSTEM_EXCEPTION(INITIALIZE);
  TAO_SYSTEM_EXCEPTION(NO_IMPLEMENT);
  TAO_SYSTEM_EXCEPTION(BAD_TYPECODE);
  TAO_SYSTEM_EXCEPTION(BAD_OPERATION);
  TAO_SYSTEM_EXCEPTION(NO_RESOURCES);
  TAO_SYSTEM_EXCEPTION(NO_RESPONSE);
  TAO_SYSTEM_EXCEPTION(PERSIST_STORE);
  TAO_SYSTEM_EXCEPTION(BAD_INV_ORDER);
  TAO_SYSTEM_EXCEPTION(TRANSIENT);
  TAO_SYSTEM_EXCEPTION(FREE_MEM);
  TAO_SYSTEM_EXCEPTION(INV_IDENT);
  TAO_SYSTEM_EXCEPTION(INV_FLAG);
  TAO_SYSTEM_EXCEPTION(INTF_REPOS);
  TAO_SYSTEM_EXCEPTION(BAD_CONTEXT);
  TAO_SYSTEM_EXCEPTION(OBJ_ADAPTER);
  TAO_SYSTEM_EXCEPTION(DATA_CONVERSION);
#undef TAO_SYSTEM_EXCEPTION

  // = all the CORBA::is_nil methods.
  static Boolean is_nil (Object_ptr);
  static Boolean is_nil (Environment_ptr);
  static Boolean is_nil (NamedValue_ptr);
  static Boolean is_nil (NVList_ptr);
  static Boolean is_nil (Request_ptr);
  //  static Boolean is_nil (Context_ptr);
  static Boolean is_nil (TypeCode_ptr);
  static Boolean is_nil (ORB_ptr);
  static Boolean is_nil (Principal_ptr);
  static Boolean is_nil (ServerRequest_ptr req);

  // = all the CORBA release methods.
  static void release (Object_ptr);
  static void release (Environment_ptr);
  static void release (NamedValue_ptr);
  static void release (NVList_ptr);
  static void release (Request_ptr);
  static void release (Principal_ptr);
  //  static Boolean release (Context_ptr);
  static void release (TypeCode_ptr);
  static void release (ORB_ptr);
  static void release (ServerRequest_ptr req);

  enum TCKind
  {
    // = Kinds of typecodes.

    // Do not change these enum values, or duplicate them if you need
    // to add values.  They are used to index tables, and if you
    // change the values you'll need to find and update all of those
    // tables.  The values are also part of the Common Data
    // Representation, and hence are part of IIOP and other ORB
    // protocols.

    tk_null               = 0,
    tk_void               = 1,
    tk_short              = 2,
    tk_long               = 3,
    tk_ushort             = 4,
    tk_ulong              = 5,
    tk_float              = 6,
    tk_double             = 7,
    tk_boolean            = 8,
    tk_char               = 9,
    tk_octet              = 10,
    tk_any                = 11,
    tk_TypeCode           = 12,
    tk_Principal          = 13,
    tk_objref             = 14,
    tk_struct             = 15,
    tk_union              = 16,
    tk_enum               = 17,
    tk_string             = 18,
    tk_sequence           = 19,
    tk_array              = 20,
    tk_alias              = 21,           // 94-11-7
    tk_except             = 22,           // 94-11-7

    // = These five are OMG-IDL data type extensions.
    tk_longlong           = 23,           // 94-9-32 Appendix A (+ 2)
    tk_ulonglong          = 24,           // 94-9-32 Appendix A (+ 2)
    tk_longdouble         = 25,           // 94-9-32 Appendix A (+ 2)
    tk_wchar              = 26,           // 94-9-32 Appendix A (+ 2)
    tk_wstring            = 27,           // 94-9-32 Appendix A (+ 2)

    // This symbol is not defined by CORBA 2.0.  It's used to speed up
    // dispatch based on TCKind values, and lets many important ones
    // just be table lookups.  It must always be the last enum value!!

    TC_KIND_COUNT
  };

  // All the typecode constants
  static TypeCode_ptr _tc_null;
  static TypeCode_ptr _tc_void;
  static TypeCode_ptr _tc_short;
  static TypeCode_ptr _tc_long;
  static TypeCode_ptr _tc_ushort;
  static TypeCode_ptr _tc_ulong;
  static TypeCode_ptr _tc_float;
  static TypeCode_ptr _tc_double;
  static TypeCode_ptr _tc_boolean;
  static TypeCode_ptr _tc_char;
  static TypeCode_ptr _tc_octet;
  static TypeCode_ptr _tc_any;
  static TypeCode_ptr _tc_TypeCode;
  static TypeCode_ptr _tc_Principal;
  static TypeCode_ptr _tc_Object;
  static TypeCode_ptr _tc_struct;
  static TypeCode_ptr _tc_union;
  static TypeCode_ptr _tc_enum;
  static TypeCode_ptr _tc_string;
  static TypeCode_ptr _tc_sequence;
  static TypeCode_ptr _tc_array;
  static TypeCode_ptr _tc_alias;
  static TypeCode_ptr _tc_except;
  static TypeCode_ptr _tc_longlong;
  static TypeCode_ptr _tc_ulonglong;
  static TypeCode_ptr _tc_longdouble;
  static TypeCode_ptr _tc_wchar;
  static TypeCode_ptr _tc_wstring;

  // = Typecode constants for system exceptions.
#define TAO_SYSTEM_EXCEPTION(name) \
  static TypeCode_ptr          _tc_ ## name

  TAO_SYSTEM_EXCEPTION(UNKNOWN);
  TAO_SYSTEM_EXCEPTION(BAD_PARAM);
  TAO_SYSTEM_EXCEPTION(NO_MEMORY);
  TAO_SYSTEM_EXCEPTION(IMP_LIMIT);
  TAO_SYSTEM_EXCEPTION(COMM_FAILURE);
  TAO_SYSTEM_EXCEPTION(INV_OBJREF);
  TAO_SYSTEM_EXCEPTION(OBJECT_NOT_EXIST);
  TAO_SYSTEM_EXCEPTION(NO_PERMISSION);
  TAO_SYSTEM_EXCEPTION(INTERNAL);
  TAO_SYSTEM_EXCEPTION(MARSHAL);
  TAO_SYSTEM_EXCEPTION(INITIALIZE);
  TAO_SYSTEM_EXCEPTION(NO_IMPLEMENT);
  TAO_SYSTEM_EXCEPTION(BAD_TYPECODE);
  TAO_SYSTEM_EXCEPTION(BAD_OPERATION);
  TAO_SYSTEM_EXCEPTION(NO_RESOURCES);
  TAO_SYSTEM_EXCEPTION(NO_RESPONSE);
  TAO_SYSTEM_EXCEPTION(PERSIST_STORE);
  TAO_SYSTEM_EXCEPTION(BAD_INV_ORDER);
  TAO_SYSTEM_EXCEPTION(TRANSIENT);
  TAO_SYSTEM_EXCEPTION(FREE_MEM);
  TAO_SYSTEM_EXCEPTION(INV_IDENT);
  TAO_SYSTEM_EXCEPTION(INV_FLAG);
  TAO_SYSTEM_EXCEPTION(INTF_REPOS);
  TAO_SYSTEM_EXCEPTION(BAD_CONTEXT);
  TAO_SYSTEM_EXCEPTION(OBJ_ADAPTER);
  TAO_SYSTEM_EXCEPTION(DATA_CONVERSION);
#undef  TAO_SYSTEM_EXCEPTION

  static TypeCode_ptr _tc_Bounds;
  static TypeCode_ptr _tc_BadKind;

  static ORB_ptr ORB_init (int &argc,
                           char *const *argv,
                           const char *orb_name,
                           Environment &env);
  // ORB initialisation, per OMG document 94-9-46.

  enum
  {
    // = Define flags for NVList add methods

    ARG_IN = 0x01,
    ARG_OUT = 0x02,
    ARG_INOUT = 0x04,
    IN_COPY_VALUE = 0x08,
    OUT_LIST_MEMORY = 0x10
  };

  static CORBA::TypeCode_ptr _tc_Policy;
  static CORBA::TypeCode_ptr _tc_PolicyList;

  static CORBA::TypeCode_ptr _tc_Current;

  typedef char *Identifier;
  typedef CORBA::String_var Identifier_var;
  typedef CORBA::String_out Identifier_out;
  static CORBA::TypeCode_ptr _tc_Identifier;

  typedef char *RepositoryId;
  typedef CORBA::String_var RepositoryId_var;
  typedef CORBA::String_out RepositoryId_out;
  static CORBA::TypeCode_ptr _tc_RepositoryId;

  typedef CORBA::ULong PolicyType;
  typedef CORBA::ULong_out PolicyType_out;
  static CORBA::TypeCode_ptr _tc_PolicyType;

};  // end of class (namespace) CORBA

#include "tao/Sequence.h"
#include "tao/Sequence_T.h"
#include "tao/Object_KeyC.h"
#include "tao/Union.h"

class STUB_Object;
// Forward declaration.

class TAO_Export CORBA_ORB
{
  // = TITLE
  //   ORB pseudo-objref.
  //
  // = DESCRIPTION
  //   The "ORB" pseudo-object is used in bootstrapping, such as to
  //   create object references from strings.  It's also used to
  //   create strings from object references.
public:
  static CORBA::ORB_ptr _duplicate (CORBA::ORB_ptr orb);
  // Return a duplicate of <{orb}>.  When work with this duplicate is
  // complete, it should be freed up using <CORBA::release()>.

  static CORBA::ORB_ptr _nil (void);
  // Returns a pointer to a nil ORB, i.e., an non-existent ORB.  This
  // can be used for initialization or in comparisons.

  virtual CORBA::Object_ptr string_to_object (CORBA::String str,
                                              CORBA::Environment &env) = 0;
  // Turn a string-ified object reference back into an object pointer.
  // Each type of ORB, e.g. an IIOP ORB, must implement this.
  // Typically these strings are created using <object_to_string()>.
  virtual CORBA::String object_to_string (CORBA::Object_ptr obj,
                                          CORBA::Environment &env) = 0;
  // Turn an object reference into a string.  Each type of ORB,
  // e.g. an IIOP ORB, must implement this.  This can be used by
  // servers to publish their whereabouts to clients.  The output of
  // this is typically eventually given to <string_to_object()> as an
  // argument.

  virtual TAO_ServantBase *_get_collocated_servant (STUB_Object *p) = 0;
  // Return the object pointer of an collocated object it there is
  // one, otherwise, return 0.  Each type of ORB, e. g., IIOP ORB,
  // must implement this and determine what is a collocated object
  // based on information provided in the STUB_Object.

  void create_list (CORBA::Long count,
                    CORBA::NVList_ptr &retval);

  // = New Things from the POA Specification
  //
  // Of all of these operations, only <run> is currently implemented.
  // Others require clarification of design or more implementation
  // than is currently available.

  CORBA::Boolean work_pending (void);
  // Returns an indication of whether the ORB needs the <{main thread}> to
  // perform some work.

  int perform_work (ACE_Time_Value * = 0);
  // If called by the <{main thread}>, this operation performs an
  // implementation-defined unit of work. Otherwise, it does nothing.
  //
  // It is platform-specific how the application and ORB arrange to
  // use compatible threading primitives.

  int run (ACE_Time_Value *tv = 0);
  // Instructs the ORB to initialize itself and run its event loop in
  // the current thread, not returning until the ORB has shut down.
  // If an error occurs during initialization or a run-time this
  // method will return -1.  If <tv> is non-NULL then if no requests
  // arrive at this thread before the timeout elapses we return to the
  // caller with a value of 0 (this allows timeouts).  Otherwise, if
  // we've returned since we've been asked to shut down the value of 1
  // is returned.
  //
  // <{Note that this interface differs from the POA specification,
  // which is reproduced below:}>
  //
  // Returns when the ORB has shut down.  If called by the main
  // thread, it enables the ORB to perform work using the main
  // thread. Otherwise, it simply waits until the ORB has shut down.
  //
  // This operation can be used instead of perform_work() to give the
  // main thread to the ORB if there are no other activities that need
  // to share the main thread. Even in a pure multi-threaded server,
  // calling run() in the main thread is useful to ensure that the
  // process does not exit until the ORB has been shut down.

  void shutdown (CORBA::Boolean wait_for_completion = CORBA::B_FALSE);
  // This operation instructs the ORB to shut down. Shutting down the
  // ORB causes all Object Adapters to be shut down. If
  // <wait_for_completion> parameter is TRUE, this operation blocks
  // until all ORB processing (including request processing and object
  // deactivation or other operations associated with object adapters)
  // has completed.  <[NOTE]> <wait_for_completion>=TRUE is not
  // currently supported.

  CORBA_Object_ptr resolve_initial_references (CORBA::String name);
  // This method acts as a mini-bootstrapping Naming Service, which is
  // provided by the ORB for certain well-known object references.
  // TAO supports the "NameService", "TradingService", "RootPOA", and
  // "POACurrent" via this method.

  // = TAO-specific Extensions

  CORBA_Object_ptr resolve_root_poa (const char *adapter_name = TAO_DEFAULT_ROOTPOA_NAME,
                                     TAO_POA_Manager *poa_manager = 0,
                                     const TAO_POA_Policies *policies = 0,
                                     TAO_Object_Table *active_object_map = 0);
  // Resolve the POA.

  CORBA_Object_ptr key_to_object (const TAO_ObjectKey &key,
                                  const char *type_id,
                                  CORBA::Environment &env);
  // Convert key into an object reference.  Return Object_ptr as out
  // parameter.  Errors will come through the environment.
  //
  // Object IDs are assigned and used by servers to identify objects.
  //
  // Type IDs are repository IDs, assigned as part of OMG-IDL
  // interface definition to identify specific interfaces and their
  // relationships to other OMG-IDL interfaces.  It's OK to provide a
  // null type ID.  Providing a null object key will result in an
  // INV_OBJREF exception.
  //
  // Clients which invoke operations using one of these references
  // when the server is not active (or after the last reference to the
  // POA is released) will normally see an OBJECT_NOT_EXIST exception
  // reported by the ORB.  If the POA is a "Named POA" the client's
  // ORB will not normally return OBJECT_NOT_EXIST unless the POA
  // reports that fault.

  int run (const ACE_Time_Value &tv);
  // This is the same as the more "standard" <run> method, except that
  // you don't need to put the & in front of <tv>.

  int preconnect (CORBA::String connections);
  // Establish connectsion to each of the comma-separated
  // <{host}>:<{port}> combinations specified in <connections>.

  // This class is intended to be inherited by others, which will
  // provide some more of the CORBA support.  Implementations of this
  // "CORBA::ORB" class must know how to create stringify/destringify
  // their objrefs, as well as how to marshal and unmarshal them.

  int open (void);
  // Set up the ORB Core's acceptor to listen on the
  // previously-specified port for requests.  Returns -1 on failure,
  // else 0.

  static void init_orb_globals (CORBA::Environment &env);
  // Initialize the ORB globals correctly, i.e., only when they
  // haven't been initialized yet.

  static CORBA::Boolean orb_free_resources (void);
  // indicates if we have reached a point where all ORB owned resources will be
  // deallocated

  // Reference counting...
  virtual CORBA::ULong _incr_refcnt (void);
  virtual CORBA::ULong _decr_refcnt (void);

  TAO_Leader_Follower_Info &leader_follower_info (void);
  // get access to the leader_follower_info

protected:
  // We must be created via the <ORB_init> call.
  CORBA_ORB (void);
  virtual ~CORBA_ORB (void);

  CORBA_Object_ptr resolve_poa_current (void);
  // Resolve the POA current.

private:
  CORBA_Object_ptr resolve_name_service (void);
  // Resolve the name service object reference.

  CORBA_Object_ptr resolve_trading_service (void);
  // Resolve the trading object reference.

  CORBA_Object_ptr multicast_to_service (TAO_Service_ID service_id,
                                         u_short port);
  // Resolve the refernce of a service of type <name>.

  ACE_SYNCH_MUTEX lock_;
  // lock required for mutual exclusion between multiple threads.

  u_int refcount_;
  // maintains a reference count of number of instantiations of the ORB

  ACE_Atomic_Op<ACE_SYNCH_MUTEX, u_int> open_called_;
  // Flag which denotes that the open method was called.

  ACE_Lock* shutdown_lock_;
  int should_shutdown_;
  // Flag which denotes that the ORB should shut down and <run> should
  // return.

  CORBA_Object_ptr name_service_;
  // If this is non-_nil(), then this is the object reference to our
  // configured Naming Context.

  CORBA_Object_ptr schedule_service_;
  // If this is non-_nil(), then this is the object reference to our
  // configured RtecScheduler::Scheduler.

  CORBA_Object_ptr event_service_;
  // If this is non-_nil(), then this is the object reference to our
  // configured Event Channel.

  CORBA_Object_ptr trading_service_;
  // If this is non-_nil(), then this is the object reference to our
  // configured Trading.

  static int orb_init_count_;
  // Count of the number of times that <ORB_init> has been called.
  // This must be protected by <ACE_Static_Object_Lock>.

  ACE_SYNCH_CONDITION* cond_become_leader_;
  // wait to become the leader if the leader-follower model is active

  TAO_Leader_Follower_Info  leader_follower_info_;
  // Information about the leader follower model

  // = NON-PROVIDED METHODS
  CORBA_ORB (const CORBA_ORB &);
  CORBA_ORB &operator= (const CORBA_ORB &);
};

class TAO_Export CORBA_ORB_var
{
public:
  CORBA_ORB_var (void); // default constructor
  CORBA_ORB_var (CORBA::ORB_ptr);
  CORBA_ORB_var (const CORBA_ORB_var &); // copy constructor
  ~CORBA_ORB_var (void); // destructor

  CORBA_ORB_var &operator= (CORBA::ORB_ptr);
  CORBA_ORB_var &operator= (const CORBA_ORB_var &);
  CORBA::ORB_ptr operator-> (void) const;

  operator const CORBA::ORB_ptr &() const;
  operator CORBA::ORB_ptr &();
  // in, inout, out, _retn
  CORBA::ORB_ptr in (void) const;
  CORBA::ORB_ptr &inout (void);
  CORBA::ORB_ptr &out (void);
  CORBA::ORB_ptr _retn (void);
  CORBA::ORB_ptr ptr (void) const;

private:
  CORBA::ORB_ptr ptr_;
};

class TAO_Export CORBA_ORB_out
{
public:
  CORBA_ORB_out (CORBA::ORB_ptr &);
  CORBA_ORB_out (CORBA_ORB_var &);
  CORBA_ORB_out (CORBA_ORB_out &);
  CORBA_ORB_out &operator= (CORBA_ORB_out &);
  CORBA_ORB_out &operator= (const CORBA_ORB_var &);
  CORBA_ORB_out &operator= (CORBA::ORB_ptr);
  operator CORBA::ORB_ptr &();
  CORBA::ORB_ptr &ptr (void);
  CORBA::ORB_ptr operator-> (void);

private:
  CORBA::ORB_ptr &ptr_;
};

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

// Signature of a skeleton for every operation of an interface.
typedef void (*TAO_Skeleton)(CORBA::ServerRequest &,
                             void *, // object_ptr
                             void *, // context_ptr
                             CORBA::Environment &);

// NOTE: stub APIs are nonportable, and must be explicitly #included
// by code emitted from an IDL compiler.

#if     defined (_MSC_VER)
#       pragma pack (pop)               // VC++, goes back to other padding rules
#endif /* _MSV_VER */

#endif /* TAO_ORB_H */