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

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    Context.h
//
// = DESCRIPTION
//    Header file for CORBA Context class.
//
// = AUTHOR
//     Jeff Parsons <parsons@cs.wustl.edu>
//
// ============================================================================

#ifndef TAO_CONTEXT_H
#define TAO_CONTEXT_H

#include "tao/corbafwd.h"

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

#if !defined (TAO_HAS_MINIMUM_CORBA)

class TAO_Export CORBA_Context
{
  // = TITLE
  //   CORBA_Context
  //
  // = DESCRIPTION
  //   TAO's minimal implementation of the Context interface.  Since
  //   Contexts are inherently un-typesafe, there use is deprecated
  //   and the feature may eventaully disappear from CORBA. It is
  //   implemented only to make the arg list of
  //   CORBA_Object::_create_request() compliant. The only (pointer)
  //   value that should be passed is 0.
  //
public:
  // = Initialization and termination methods.
  CORBA_Context (void);
  // Constructor.

  ~CORBA_Context (void);
  // Destructor.

  // = Pseudo-object methods
  static CORBA_Context *_duplicate (CORBA_Context*);
  static CORBA_Context *_nil (void);

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

  // = All the spec-required functions below will just throw a
  //   CORBA::NO_IMPLEMENT exception and do nothing else.

  const char *context_name (CORBA::Environment &ACE_TRY_ENV =
                            TAO_default_environment ()) const;

  CORBA_Context_ptr parent (CORBA::Environment &ACE_TRY_ENV =
                            TAO_default_environment ()) const;

  void create_child (const char *child_ctx_name,
                     CORBA_Context_out child_ctx,
                     CORBA::Environment &ACE_TRY_ENV =
                       TAO_default_environment ());

  void set_one_value (const char *propname,
                      const CORBA_Any &propvalue,
                      CORBA::Environment &ACE_TRY_ENV =
                        TAO_default_environment ());

  void set_values (CORBA::NVList_ptr values,
                   CORBA::Environment &ACE_TRY_ENV =
                     TAO_default_environment ());

  void delete_values (const char *propname,
                      CORBA::Environment &ACE_TRY_ENV =
                        TAO_default_environment ());

  void get_values (const char *start_scope,
                   CORBA::Flags op_flags,
                   const char *pattern,
                   CORBA::NVList_ptr &values,
                   CORBA::Environment &ACE_TRY_ENV =
                     TAO_default_environment ());

#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
  typedef CORBA_Context_ptr _ptr_type;
  typedef CORBA_Context_var _var_type;
#endif /* __GNUC__ */
  // Useful for template programming.

private:
  CORBA::ULong refcount_;
  // Reference counting.

  ACE_SYNCH_MUTEX refcount_lock_;
  // Protect the reference count.
};

typedef CORBA_Context* CORBA_Context_ptr;

class TAO_Export CORBA_Context_var
{
  // = TITLE
  //   The T_var class for Context
  //
  // = DESCRIPTION
  //   As any other pseudo object Context must have a T_var class,
  //   the interface an semantics are specified in the CORBA spec.
  //
  //   We use <CORBA_Context_ptr> as the _ptr type instead of
  //   <CORBA::Context_ptr> in an attempt to reduced the cyclic
  //   dependencies in TAO.
public:
  CORBA_Context_var (void);
  CORBA_Context_var (CORBA_Context_ptr);
  CORBA_Context_var (const CORBA_Context_var &);
  ~CORBA_Context_var (void);

  CORBA_Context_var &operator= (CORBA_Context_ptr);
  CORBA_Context_var &operator= (const CORBA_Context_var &);
  CORBA_Context_ptr operator-> (void) const;

  operator const CORBA_Context_ptr &() const;
  operator CORBA_Context_ptr &();
  // in, inout, out, _retn
  CORBA_Context_ptr in (void) const;
  CORBA_Context_ptr &inout (void);
  CORBA_Context_ptr &out (void);
  CORBA_Context_ptr _retn (void);
  CORBA_Context_ptr ptr (void) const;

private:
  CORBA_Context_ptr ptr_;
};

class TAO_Export CORBA_Context_out
{
  // = TITLE
  //   The T_out class for Context
  //
  // = DESCRIPTION
  //   As any other pseudo object Context must have a T_out class,
  //   the interface an semantics are specified in the CORBA spec.
  //
  //   We use <CORBA_Context_ptr> as the _ptr type instead of
  //   <CORBA::Context_ptr> in an attempt to reduced the cyclic
  //   dependencies in TAO.
public:
  CORBA_Context_out (CORBA_Context_ptr &);
  CORBA_Context_out (CORBA_Context_var &);
  CORBA_Context_out (CORBA_Context_out &);
  CORBA_Context_out &operator= (CORBA_Context_out &);
  CORBA_Context_out &operator= (const CORBA_Context_var &);
  CORBA_Context_out &operator= (CORBA_Context_ptr);
  operator CORBA_Context_ptr &();
  CORBA_Context_ptr &ptr (void);
  CORBA_Context_ptr operator-> (void);

private:
  CORBA_Context_ptr &ptr_;
};

class CORBA_ContextList
{
  // = TITLE
  //   ContextList definition taken from CORBA v2.3a Dec 1998
  //
  // = DESCRIPTION
  //   Maintains a list of strings for Contexts.
public:
  CORBA_ContextList (void);
  // Constructor.

  CORBA_ContextList (CORBA::ULong len,
                     char **ctx_list);
  // Constructor - initialize given a length and an array of
  // strings.

  ~CORBA_ContextList (void);
  // destructor

  CORBA::ULong count ();
  // return the number of elements

  CORBA_ContextList_ptr _duplicate (void);
  // Increment the reference count.

  static CORBA_ContextList_ptr _duplicate (CORBA_ContextList *);
  // Increment the reference count.

  void _destroy (void);
  // Decrement the reference count and delete if it is 0.

  static CORBA_ContextList_ptr _nil ();
  // Return null pointer of this type.

  void add (char *ctx);
  // Add a string to the list.

  void add_consume (char *ctx);
  // Add and consume a string to the list.

  char *item (CORBA::ULong slot,
              CORBA_Environment &ACE_TRY_ENV =
                TAO_default_environment ());
  // Return the typecode at slot i. Raises the "Bounds" exception.

  void remove (CORBA::ULong slot,
               CORBA_Environment &ACE_TRY_ENV =
                TAO_default_environment ());
  // remove the typecode at slot i. Raises the "Bounds" exception

  void _incr_refcnt (void);
  void  _decr_refcnt (void);
  // Increment and decrement ref counts

#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
  typedef CORBA::ContextList_ptr _ptr_type;
  typedef CORBA::ContextList_var _var_type;
#endif /* __GNUC__ */
  // Useful for template programming.

private:
  // Not allowed.
  CORBA_ContextList (const CORBA_ContextList &);
  CORBA_ContextList &operator= (const CORBA_ContextList &);

  ACE_Atomic_Op<ACE_SYNCH_MUTEX, CORBA::ULong> ref_count_;
  // Reference counter.

  ACE_Unbounded_Queue<char *> ctx_list_;
  // Internal list of typecodes.
};

class TAO_Export CORBA_ContextList_var
{
public:
  CORBA_ContextList_var (void); // default constructor
  CORBA_ContextList_var (CORBA_ContextList_ptr);
  CORBA_ContextList_var (const CORBA_ContextList_var &); // copy constructor
  ~CORBA_ContextList_var (void); // destructor

  CORBA_ContextList_var &operator= (CORBA_ContextList_ptr);
  CORBA_ContextList_var &operator= (const CORBA_ContextList_var &);
  CORBA_ContextList_ptr operator-> (void) const;

  operator const CORBA_ContextList_ptr &() const;
  operator CORBA_ContextList_ptr &();
  // in, inout, out, _retn
  CORBA_ContextList_ptr in (void) const;
  CORBA_ContextList_ptr &inout (void);
  CORBA_ContextList_ptr &out (void);
  CORBA_ContextList_ptr _retn (void);
  CORBA_ContextList_ptr ptr (void) const;

private:
  CORBA_ContextList_ptr ptr_;
};

class TAO_Export CORBA_ContextList_out
{
  // = TITLE
  //   The T_out class for ContextList
  //
  // = DESCRIPTION
  //   As any other pseudo object ContextList must have a T_out class,
  //   the interface an semantics are specified in the CORBA spec.
  //
  // = NOTE
  //   We use CORBA_ContextList_ptr as the _ptr type instead of
  //   CORBA::ContextList_ptr, this is an attempt to reduced the cyclic
  //   dependencies in TAO.
  //
public:
  CORBA_ContextList_out (CORBA_ContextList_ptr &);
  CORBA_ContextList_out (CORBA_ContextList_var &);
  CORBA_ContextList_out (CORBA_ContextList_out &);
  CORBA_ContextList_out &operator= (CORBA_ContextList_out &);
  CORBA_ContextList_out &operator= (const CORBA_ContextList_var &);
  CORBA_ContextList_out &operator= (CORBA_ContextList_ptr);
  operator CORBA_ContextList_ptr &();
  CORBA_ContextList_ptr &ptr (void);
  CORBA_ContextList_ptr operator-> (void);

private:
  CORBA_ContextList_ptr &ptr_;
};

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

#endif /* TAO_HAS_MINIMUM_CORBA */
#endif /* TAO_CONTEXT_H */