summaryrefslogtreecommitdiff
path: root/TAO/tao/POA.h
blob: b69d69547b4645c607ffe278666ad5c1f7d64bd1 (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
// -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    POA.h
//
// = DESCRIPTION
//     POA
//
// = AUTHOR
//     Irfan Pyarali
//
// ============================================================================

#ifndef TAO_POA_H
#define TAO_POA_H

// CORBA
#include "tao/corba.h"

// Stubs
#include "tao/POAC.h"

// Servant
#include "tao/Servant_Base.h"

// Skeletons
#include "tao/POAS.h"

// String
#include "ace/SString.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

// Map
#include "ace/Hash_Map_Manager.h"

// Vector
#include "ace/Containers.h"

// Locking
#include "ace/Synch.h"

class TAO_POA;
class TAO_POA_Manager;

class TAO_Export TAO_ObjectId_Hash
{
public:
  u_long operator () (const PortableServer::ObjectId &id) const;
  // Returns hash value.
};

extern TAO_Export int operator== (const PortableServer::ObjectId &l,
                                  const PortableServer::ObjectId &r);

extern TAO_Export int operator== (const TAO_ObjectKey &l,
                                  const TAO_ObjectKey &r);

// Active Object Table
#include "tao/Active_Object_Map.h"

class TAO_Export TAO_Thread_Policy : public POA_PortableServer::ThreadPolicy
{
public:
  TAO_Thread_Policy (PortableServer::ThreadPolicyValue value,
                     PortableServer::POA_ptr poa);

  TAO_Thread_Policy (const TAO_Thread_Policy &new_policy);

  virtual PortableServer::ThreadPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::ThreadPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_Lifespan_Policy : public POA_PortableServer::LifespanPolicy
{
public:
  TAO_Lifespan_Policy (PortableServer::LifespanPolicyValue value,
                       PortableServer::POA_ptr poa);

  TAO_Lifespan_Policy (const TAO_Lifespan_Policy &rhs);

  virtual PortableServer::LifespanPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::LifespanPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_Id_Uniqueness_Policy : public POA_PortableServer::IdUniquenessPolicy
{
public:
  TAO_Id_Uniqueness_Policy (PortableServer::IdUniquenessPolicyValue value,
                            PortableServer::POA_ptr poa);

  TAO_Id_Uniqueness_Policy (const TAO_Id_Uniqueness_Policy &rhs);

  virtual PortableServer::IdUniquenessPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::IdUniquenessPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_Id_Assignment_Policy : public POA_PortableServer::IdAssignmentPolicy
{
public:
  TAO_Id_Assignment_Policy (PortableServer::IdAssignmentPolicyValue value,
                            PortableServer::POA_ptr poa);

  TAO_Id_Assignment_Policy (const TAO_Id_Assignment_Policy &rhs);

  virtual PortableServer::IdAssignmentPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::IdAssignmentPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_Implicit_Activation_Policy : public POA_PortableServer::ImplicitActivationPolicy
{
public:
  TAO_Implicit_Activation_Policy (PortableServer::ImplicitActivationPolicyValue value,
                                  PortableServer::POA_ptr poa);

  TAO_Implicit_Activation_Policy (const TAO_Implicit_Activation_Policy &rhs);

  virtual PortableServer::ImplicitActivationPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::ImplicitActivationPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_Servant_Retention_Policy : public POA_PortableServer::ServantRetentionPolicy
{
public:
  TAO_Servant_Retention_Policy (PortableServer::ServantRetentionPolicyValue value,
                                PortableServer::POA_ptr poa);

  TAO_Servant_Retention_Policy (const TAO_Servant_Retention_Policy &rhs);

  virtual PortableServer::ServantRetentionPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::ServantRetentionPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_Request_Processing_Policy : public POA_PortableServer::RequestProcessingPolicy
{
public:
  TAO_Request_Processing_Policy (PortableServer::RequestProcessingPolicyValue value,
                                 PortableServer::POA_ptr poa);

  TAO_Request_Processing_Policy (const TAO_Request_Processing_Policy &rhs);

  virtual PortableServer::RequestProcessingPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::RequestProcessingPolicyValue value_;

  PortableServer::POA_var poa_;
};

// **************************************************
//
// TAO spcific POA locking policy (non-standard)
//
// **************************************************

class TAO_Export TAO_Synchronization_Policy : public POA_PortableServer::SynchronizationPolicy
{
public:
  TAO_Synchronization_Policy (PortableServer::SynchronizationPolicyValue value,
                              PortableServer::POA_ptr poa);

  TAO_Synchronization_Policy (const TAO_Synchronization_Policy &rhs);

  virtual PortableServer::SynchronizationPolicyValue value (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Policy_ptr copy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::PolicyType policy_type (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:
  PortableServer::SynchronizationPolicyValue value_;

  PortableServer::POA_var poa_;
};

class TAO_Export TAO_POA_Policies
{
public:

  TAO_POA_Policies (void);

  virtual PortableServer::ThreadPolicyValue thread (void) const;
  virtual void thread (PortableServer::ThreadPolicyValue value);

  virtual PortableServer::LifespanPolicyValue lifespan (void) const;
  virtual void lifespan (PortableServer::LifespanPolicyValue value);

  virtual PortableServer::IdUniquenessPolicyValue id_uniqueness (void) const;
  virtual void id_uniqueness (PortableServer::IdUniquenessPolicyValue value);

  virtual PortableServer::IdAssignmentPolicyValue id_assignment (void) const;
  virtual void id_assignment (PortableServer::IdAssignmentPolicyValue value);

  virtual PortableServer::ImplicitActivationPolicyValue implicit_activation (void) const;
  virtual void implicit_activation (PortableServer::ImplicitActivationPolicyValue value);

  virtual PortableServer::ServantRetentionPolicyValue servant_retention (void) const;
  virtual void servant_retention (PortableServer::ServantRetentionPolicyValue value);

  virtual PortableServer::RequestProcessingPolicyValue request_processing (void) const;
  virtual void request_processing (PortableServer::RequestProcessingPolicyValue value);

  // **************************************************
  //
  // TAO spcific POA locking policy (non-standard)
  //
  // **************************************************

  virtual PortableServer::SynchronizationPolicyValue synchronization (void) const;
  virtual void synchronization (PortableServer::SynchronizationPolicyValue value);

  virtual void parse_policies (const CORBA::PolicyList &policies,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:

  virtual void parse_policy (const CORBA::Policy_ptr policy,
                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual int validity_check (void);

  PortableServer::ThreadPolicyValue thread_;

  PortableServer::LifespanPolicyValue lifespan_;

  PortableServer::IdUniquenessPolicyValue id_uniqueness_;

  PortableServer::IdAssignmentPolicyValue id_assignment_;

  PortableServer::ImplicitActivationPolicyValue implicit_activation_;

  PortableServer::ServantRetentionPolicyValue servant_retention_;

  PortableServer::RequestProcessingPolicyValue request_processing_;

  // **************************************************
  //
  // TAO spcific POA locking policy (non-standard)
  //
  // **************************************************

  PortableServer::SynchronizationPolicyValue synchronization_;
};

class TAO_Temporary_Creation_Time;

class TAO_Creation_Time
{
public:

  TAO_Creation_Time (const ACE_Time_Value &creation_time);

  TAO_Creation_Time (void);

  virtual void creation_time (const void *creation_time);

  virtual const void *creation_time (void) const;

  static int creation_time_length (void);

  int operator== (const TAO_Creation_Time &rhs) const;

  int operator!= (const TAO_Creation_Time &rhs) const;

  int operator== (const TAO_Temporary_Creation_Time &rhs) const;

  int operator!= (const TAO_Temporary_Creation_Time &rhs) const;

protected:

  enum
  {
    SEC_FIELD = 0,
    USEC_FIELD = 1
  };

  // Timestamp
  CORBA::ULong time_stamp_[2];

};

// Special creation time only useful in the lifetime of the upcall
class TAO_Temporary_Creation_Time
{
public:

  TAO_Temporary_Creation_Time (void);

  virtual void creation_time (const void *creation_time);

  int operator== (const TAO_Creation_Time &rhs) const;

  int operator!= (const TAO_Creation_Time &rhs) const;

protected:

  void *time_stamp_;
};

class TAO_POA_Current;

class TAO_Export TAO_POA : public POA_PortableServer::POA
{
public:

  typedef ACE_CString String;

  virtual PortableServer::POA_ptr create_POA (const char *adapter_name,
                                              PortableServer::POAManager_ptr poa_manager,
                                              const CORBA::PolicyList &policies,
                                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::POA_ptr find_POA (const char *adapter_name,
                                            CORBA::Boolean activate_it,
                                            CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy (CORBA::Boolean etherealize_objects,
                        CORBA::Boolean wait_for_completion,
                        CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ThreadPolicy_ptr create_thread_policy (PortableServer::ThreadPolicyValue value,
                                                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::LifespanPolicy_ptr create_lifespan_policy (PortableServer::LifespanPolicyValue value,
                                                                     CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::IdUniquenessPolicy_ptr create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value,
                                                                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::IdAssignmentPolicy_ptr create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value,
                                                                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ImplicitActivationPolicy_ptr create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value,
                                                                                          CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ServantRetentionPolicy_ptr create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value,
                                                                                      CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::RequestProcessingPolicy_ptr create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value,
                                                                                        CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // **************************************************
  //
  // TAO spcific POA locking policy (non-standard)
  //
  // **************************************************

  virtual PortableServer::SynchronizationPolicy_ptr create_synchronization_policy (PortableServer::SynchronizationPolicyValue value,
                                                                                   CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::String the_name (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::POA_ptr the_parent (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::POAManager_ptr the_POAManager (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::AdapterActivator_ptr the_activator (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void the_activator (PortableServer::AdapterActivator_ptr adapter_activator,
                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ServantManager_ptr get_servant_manager (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void set_servant_manager (PortableServer::ServantManager_ptr imgr,
                                    CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant get_servant (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void set_servant (PortableServer::Servant servant,
                            CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ObjectId *activate_object (PortableServer::Servant p_servant,
                                                     CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void activate_object_with_id (const PortableServer::ObjectId &id,
                                        PortableServer::Servant p_servant,
                                        CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void deactivate_object (const PortableServer::ObjectId &oid,
                                  CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Object_ptr create_reference (const char *intf,
                                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Object_ptr create_reference_with_id (const PortableServer::ObjectId &oid,
                                                      const char *intf,
                                                      CORBA_Environment &_env = CORBA_Environment::default_environment ());
  virtual PortableServer::ObjectId *servant_to_id (PortableServer::Servant p_servant,
                                                   CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Object_ptr servant_to_reference (PortableServer::Servant p_servant,
                                                  CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant reference_to_servant (CORBA::Object_ptr reference,
                                                        CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ObjectId *reference_to_id (CORBA::Object_ptr reference,
                                                     CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant id_to_servant (const PortableServer::ObjectId &oid,
                                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Object_ptr id_to_reference (const PortableServer::ObjectId &oid,
                                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void forward_object (const PortableServer::ObjectId &oid,
                               CORBA::Object_ptr forward_to,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  // Utility functions for the other
  static void encode_sequence_to_string (CORBA::String &str,
                                         const TAO_Unbounded_Sequence<CORBA::Octet> &seq);
  static void decode_string_to_sequence (TAO_Unbounded_Sequence<CORBA::Octet> &seq,
                                         const char *str);

  static CORBA::String ObjectId_to_string (const PortableServer::ObjectId &id);

  static CORBA::WString ObjectId_to_wstring (const PortableServer::ObjectId &id);

  static PortableServer::ObjectId *string_to_ObjectId (const char *id);

  static PortableServer::ObjectId *string_to_ObjectId (const char *string,
                                                       int size);

  static PortableServer::ObjectId *wstring_to_ObjectId (const CORBA::WChar *id);

  TAO_POA (const String &adapter_name,
           TAO_POA_Manager &poa_manager,
           const TAO_POA_Policies &policies,
           TAO_POA *parent,
           CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_POA *clone (const String &adapter_name,
                          TAO_POA_Manager &poa_manager,
                          const TAO_POA_Policies &policies,
                          TAO_POA *parent,
                          CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual ~TAO_POA (void);

  virtual void dispatch_servant (const TAO_ObjectKey &key,
                                 CORBA::ServerRequest &req,
                                 void *context,
                                 TAO_ORB_Core *orb_core,
                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual int locate_servant (const TAO_ObjectKey &key,
                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant find_servant (const TAO_ObjectKey &key,
                                                CORBA_Environment &_env = CORBA_Environment::default_environment ());

  static char name_separator (void);

  static char id_separator (void);

  static CORBA::ULong name_separator_length (void);

  static CORBA::ULong id_separator_length (void);

protected:

  virtual TAO_POA *create_POA (const String &adapter_name,
                               TAO_POA_Manager &poa_manager,
                               const TAO_POA_Policies &policies,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_POA *create_POA_i (const String &adapter_name,
                                 TAO_POA_Manager &poa_manager,
                                 const TAO_POA_Policies &policies,
                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_POA *find_POA (const String &adapter_name,
                             CORBA::Boolean activate_it,
                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_POA *find_POA_i (const String &adapter_name,
                               CORBA::Boolean activate_it,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_POA *find_POA_i_optimized (const String &adapter_name,
                                         CORBA::Boolean activate_it,
                                         CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void destroy_i (CORBA::Boolean etherealize_objects,
                          CORBA::Boolean wait_for_completion,
                          CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ServantManager_ptr get_servant_manager_i (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void set_servant_manager_i (PortableServer::ServantManager_ptr imgr,
                                      CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant get_servant_i (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void set_servant_i (PortableServer::Servant servant,
                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ObjectId *activate_object_i (PortableServer::Servant p_servant,
                                                       CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void activate_object_with_id_i (const PortableServer::ObjectId &id,
                                          PortableServer::Servant p_servant,
                                          CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void deactivate_object_i (const PortableServer::ObjectId &oid,
                                    CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Object_ptr create_reference_i (const char *intf,
                                                CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ObjectId *servant_to_id_i (PortableServer::Servant servant,
                                                     CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant id_to_servant_i (const PortableServer::ObjectId &oid,
                                                   CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual CORBA::Object_ptr id_to_reference_i (const PortableServer::ObjectId &oid,
                                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void forward_object_i (const PortableServer::ObjectId &oid,
                                 CORBA::Object_ptr forward_to,
                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual ACE_Lock &lock (void);

  virtual TAO_POA_Policies &policies (void);

  virtual TAO_Active_Object_Map &active_object_map (void) const;

  virtual void delete_child (const String &child,
                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void delete_child_i (const String &child,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual String complete_name (void);

  virtual void set_complete_name (void);

  virtual int leaf_poa_name (const String &adapter_name,
                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void parse_poa_name (const TAO_POA::String &adapter_name,
                               TAO_POA::String &topmost_poa_name,
                               TAO_POA::String &tail_poa_name,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::ObjectId *create_object_id (PortableServer::Servant servant,
                                                      CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_ObjectKey *create_object_key (const PortableServer::ObjectId &id);

  virtual CORBA::ULong system_id_size (void) const;

  virtual int is_poa_generated_id (const PortableServer::ObjectId &id);

  virtual int is_poa_generated_key (const TAO_ObjectKey &key);

  virtual int parse_key (const TAO_ObjectKey &key,
                         String &poa_name,
                         PortableServer::ObjectId &id,
                         CORBA::Boolean &persistent,
                         CORBA::Boolean &system_id,
                         TAO_Temporary_Creation_Time &poa_creation_time);

  virtual int rfind (const TAO_ObjectKey &key,
                     char c,
                     int pos = TAO_POA::String::npos) const;

  // Should really be protected, but some compilers complain
public:
  enum LOCATION_RESULT
  {
    FOUND,
    DEFAULT_SERVANT,
    SERVANT_MANAGER,
    NOT_FOUND
  };

protected:
  virtual LOCATION_RESULT locate_servant_i (const TAO_ObjectKey &key,
                                            PortableServer::Servant &servant,
                                            CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual PortableServer::Servant locate_poa_and_servant_i (const TAO_ObjectKey &key,
                                                            const char *operation,
                                                            PortableServer::ObjectId &id,
                                                            TAO_POA *&poa_impl,
                                                            TAO_ORB_Core *orb_core,
                                                            CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual TAO_POA *locate_poa_i (const TAO_ObjectKey &key,
                                 PortableServer::ObjectId &id,
                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void dispatch_servant_i (const TAO_ObjectKey &key,
                                   CORBA::ServerRequest &req,
                                   void *context,
                                   TAO_ORB_Core *orb_core,
                                   CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void pre_invoke (const TAO_ObjectKey &key,
                           const PortableServer::ObjectId &id,
                           PortableServer::Servant servant,
                           TAO_POA_Current *poa_current,
                           CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void post_invoke (PortableServer::Servant servant,
                            const char *operation,
                            TAO_POA_Current *poa_current,
                            CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual const TAO_Creation_Time &creation_time (void);

  virtual CORBA::Boolean persistent (void);

  virtual char persistent_key_type (void);

  static char persistent_key_char (void);

  static char transient_key_char (void);

  static CORBA::ULong persistent_key_type_length (void);

  virtual CORBA::Boolean system_id (void);

  virtual char system_id_key_type (void);

  static char system_id_key_char (void);

  static char user_id_key_char (void);

  static CORBA::ULong system_id_key_type_length (void);

  virtual void create_internal_lock (void);

  virtual void create_active_object_map (void);

  String name_;

  String complete_name_;

  TAO_POA_Manager &poa_manager_;

  TAO_POA_Policies policies_;

  TAO_POA *parent_;

  TAO_Active_Object_Map *active_object_map_;

  int delete_active_object_map_;

  PortableServer::AdapterActivator_var adapter_activator_;

  PortableServer::ServantActivator_var servant_activator_;

  PortableServer::ServantLocator_var servant_locator_;

  PortableServer::Servant default_servant_;

  typedef ACE_Hash_Map_Manager<ACE_CString, TAO_POA *, ACE_Null_Mutex>
          CHILDREN;

  CHILDREN children_;

  ACE_Lock *lock_;

  int closing_down_;

  int persistent_;

  int system_id_;

  TAO_Creation_Time creation_time_;
};

class TAO_Export TAO_POA_Manager : public POA_PortableServer::POAManager
{
  friend class TAO_POA;

public:
  enum Processing_State
  {
    ACTIVE,
    DISCARDING,
    HOLDING,
    INACTIVE,
    UNKNOWN
  };

  virtual void activate (CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void hold_requests (CORBA::Boolean wait_for_completion,
                              CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void discard_requests (CORBA::Boolean wait_for_completion,
                                 CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void deactivate (CORBA::Boolean etherealize_objects,
                           CORBA::Boolean wait_for_completion,
                           CORBA_Environment &_env = CORBA_Environment::default_environment ());

  TAO_POA_Manager (void);

  virtual TAO_POA_Manager *clone (void);

  virtual ~TAO_POA_Manager (void);

  virtual Processing_State state (CORBA_Environment &_env = CORBA_Environment::default_environment ());

protected:

  virtual ACE_Lock &lock (void);

  virtual void remove_poa (TAO_POA *poa,
                           CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void remove_poa_i (TAO_POA *poa,
                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void register_poa (TAO_POA *poa,
                             CORBA_Environment &_env = CORBA_Environment::default_environment ());

  virtual void register_poa_i (TAO_POA *poa,
                               CORBA_Environment &_env = CORBA_Environment::default_environment ());

  Processing_State state_;

  int closing_down_;

  ACE_Lock *lock_;

  typedef ACE_Unbounded_Set<TAO_POA *> POA_COLLECTION;

  POA_COLLECTION poa_collection_;
};

class TAO_Export TAO_Adapter_Activator : public POA_PortableServer::AdapterActivator
{
public:

  virtual CORBA::Boolean unknown_adapter (PortableServer::POA_ptr parent,
                                          const char *name,
                                          CORBA_Environment &_env = CORBA_Environment::default_environment ());
};

class TAO_Export TAO_POA_Current : public POA_PortableServer::Current
{
  // = TITLE
  //
  // Implementation of the PortableServer::Current object.
  //
  // = DESCRIPTION
  //
  // Objects of this class hold state information regarding the
  // current POA invocation.  Savvy readers will notice that this
  // contains substantially more methods than the POA spec shows; they
  // exist because the ORB either (a) needs them or (b) finds them
  // useful for implementing a more efficient ORB.
  //
  // The intent is that instances of this class are held in
  // Thread-Specific Storage so that upcalls can get context
  // information regarding their invocation.  The POA itself must
  // insure that all <set_*> operations are performed in the execution
  // thread so that the proper <TAO_POA_Current> pointer is obtained
  // from TSS.

public:
  // = Specification-mandated methods

  virtual PortableServer::POA_ptr get_POA (CORBA_Environment &_env = CORBA_Environment::default_environment ());
  // Return pointer to the invoking POA.  Raises the
  // <CORBA::NoContext> exception.

  virtual PortableServer::ObjectId *get_object_id (CORBA_Environment &_env = CORBA_Environment::default_environment ());
  // Return pointer to the object id through which this was invoked.
  // This may be necessary in cases where a <Servant> is serving under
  // the guise of multiple object ids.  This has _out semantics Raises
  // the <CORBA::NoContext> exception.

  // = TAO Extensions

  virtual void clear (void);
  // Clear any prior settings made.  This will make things which can
  // throw the <CORBA::NoContext> exception raise it if invoked
  // without a corresponding <set_*> operation.

  virtual int context_is_valid (void);
  // Returns non-zero if the context is valid, i.e., if it would be
  // impossible for a <CORBA::NoContext> exception to be raised.

  virtual void POA_impl (TAO_POA *impl);
  // Set the POA implementation.

  virtual TAO_POA *POA_impl (void) const;
  // Get the POA imeplemantation

  virtual void object_id (const PortableServer::ObjectId &id);
  // Set the object ID.

  virtual const PortableServer::ObjectId &object_id (void) const;
  // Get the object ID.

  virtual void object_key (const TAO_ObjectKey &key);
  // Set the object key.

  virtual const TAO_ObjectKey &object_key (void) const;
  // Get the object key.

  virtual void servant (PortableServer::Servant servant);
  // Set the servant for the current upcall.

  virtual PortableServer::Servant servant (void) const;
  // Get the servant for the current upcall.

  virtual int in_upcall (void) const;
  // Get whether we're in an upcall (non-zero is yes).

  virtual PortableServer::ServantLocator::Cookie locator_cookie (void) const;
  // Get the Servant Locator's cookie

  virtual void locator_cookie (PortableServer::ServantLocator::Cookie cookie);
  // Set the Servant Locator's cookie

  TAO_POA_Current (void);
  // Constructor

  TAO_POA_Current (TAO_POA *impl,
                   const TAO_ObjectKey &key,
                   const PortableServer::ObjectId &id,
                   PortableServer::Servant servant);
  // Convenience constructor combining construction & initialization.

  virtual ~TAO_POA_Current (void);
  // Destructor

protected:
  TAO_POA *poa_impl_;
  // The POA implementation invoking an upcall

  const PortableServer::ObjectId *object_id_;
  // The object ID of the current context.

  const TAO_ObjectKey *object_key_;
  // The object key of the current context.

  PortableServer::ServantLocator::Cookie cookie_;
  // Servant Locator's cookie

  PortableServer::Servant servant_;
  // The servant for the current upcall.

  // = Hidden because we don't allow these
  TAO_POA_Current (const TAO_POA_Current &);
  void operator= (const TAO_POA_Current &);
};

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

#endif /* TAO_POA_H */