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

// ============================================================================
//
// = LIBRARY
//    TAO
// 
// = FILENAME
//    roa.h
//
// = DESCRIPTION
//     
// = AUTHOR
//     Chris Cleeland & David Brownell
// 
// ============================================================================

#if !defined (ACE_ROA_H)
#  define ACE_ROA_H

#  include "ace/INET_Addr.h"

#  include "tao/boa.h"
#  include "tao/params.h"
#  include "tao/connect.h"

class ACE_Svc_Export ROA;
typedef ROA* ROA_ptr;

extern "C" const IID IID_ROA;

class ACE_Svc_Export ROA : public CORBA_BOA
// = TITLE
//     Realtime Object Adapter class.
{
public:
  // = ROA Support
  static ROA_ptr init (CORBA_ORB_ptr which_orb, 
		       ACE_INET_Addr &addr,
		       CORBA_Environment &env);
  // NON-STANDARD CALL.  According to CORBA V2.0, this functionality
  // should really be <ROA_ptr ORB::ROA_init (argc,argv,ident)>.
  //
  // The current signature is residue from when this code was part of
  // the SunSoft IIOP reference implementation.


  void clean_shutdown (CORBA_Environment &env);
  // NON-STANDARD CALL.  OA user asks for a clean shutdown of the OA
  // after currently active calls complete.  OA "requester" (calls
  // <get_request>) asks if we're shutting down, and if so closes down
  // transport cleanly.

  CORBA_Boolean shutting_down (void);
  // NON-STANDARD CALL.  Returns <TRUE> if we're in the process of
  // shutting down.

  CORBA_OctetSeq *get_key (CORBA_Object_ptr obj,
			   CORBA_Environment &env);
  // NON-STANDARD CALL.  When dispatching a request to an object, you
  // need to be able to get the object key you used to create the
  // reference.  It's the main way servers distinguish two object
  // references from each other.
    
  virtual CORBA_ORB_ptr orb (void) const;
  // Returns pointer to the ORB with which this OA is associated.
  // SHOULD PROBABLY MOVE TO BOA!

  // @@ Please make sure that all macros start with TAO_ ...
#if defined (ROA_NEEDS_REQ_KEY)
  CORBA_OctetSeq *get_target_key (CORBA_Environment &env);
  CORBA_Principal_ptr get_client_principal (CORBA_Environment &env);
#endif /* ROA_NEEDSS_REQ_KEY */

  virtual int handle_message (TAO_Dispatch_Context &context,
                              CORBA_Environment &env);
  // Reads incoming GIOP messages, dispatches them, and sends back any
  // required replies.  Returns 1 for success, 0==EOF, -1==error.

  // = BOA Support
  // @@ Please add comments.
  CORBA_Object_ptr create (CORBA_OctetSeq &obj_id,
			   CORBA_String type_id,
			   CORBA_Environment &env);

  void register_dir (CORBA_BOA::dsi_handler handler,
		     void *context,
		     CORBA_Environment &env);
    
  void please_shutdown (CORBA_Environment &env);

  // = COM IUnknown Support
  ULONG __stdcall AddRef (void);
  ULONG __stdcall Release (void);
  HRESULT __stdcall QueryInterface (REFIID riid, void** ppv);

  ROA (CORBA_ORB_ptr orb_arg,
       CORBA_Environment &env);
  virtual ~ROA (void);

  virtual ACE_INET_Addr get_addr (void) const;
  
private:
  ACE_INET_Addr addr_;		
  // The address of the endpoint on which we're listening for
  // connections and requests.

  CORBA_Boolean do_exit_;	
  // Flag set by <clean_shutdown ()>.

  ROA_Acceptor client_acceptor_;
  // The acceptor listening for requests.

  CORBA_ORB_ptr orb_;		
  // Pointer to our ORB.

  u_int call_count_;		
  // Used by COM stuff

  u_int refcount_;		
  // Used by COM stuff

  CORBA_BOA::dsi_handler skeleton_;	
  // Skeleton function

  void *context_;		
  // Who knows!?!

  ACE_SYNCH_MUTEX lock_;	
  // Locks critical sections within ROA code methods (was
  // tcpoa_mutex).

  ACE_SYNCH_MUTEX com_lock_;	
  // Locks critical sections in COM-related code (was tcpoa_lock).

#if defined (ROA_NEEDS_REQ_KEY)
  ACE_thread_key_t req_key_;	
  // Key into TSS for a thread's request header
#endif

  // = Copy and assignment:  just say no
  ROA (const ROA &src);
  ROA &operator= (const ROA &src);
};

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

#endif /* TAO_ROA_H */