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

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    Managed_Types.h
//
// = AUTHOR
//
//    Aniruddha Gokhale
//
// ============================================================================

#ifndef TAO_MANAGED_TYPES_H
#define TAO_MANAGED_TYPES_H

#include "tao/corbafwd.h"
#include "tao/ORB.h"

/****************************************************************/

class TAO_Export TAO_String_Manager
{
  // = TITLE
  //   Manager for strings.
  //
  // = DESCRIPTION
  //
  //   This class implements the generic string manager and is used in the C++
  //   mapping of "struct" members that are of type "string". The difference
  //   between this class and the CORBA::String_var class is that the default
  //   conctructor initializes the underlying string to an empty string in this
  //   class whereas it is a NUL string for the _var class.
  //
public:

  TAO_String_Manager (void);
  // default CTOR will initialize the underlying ptr_ to empty string. 

  TAO_String_Manager (const TAO_String_Manager &);
  // copy constructor

  ~TAO_String_Manager (void);
  // destructor

  TAO_String_Manager &operator= (const TAO_String_Manager&);
  // assignment from another managed type

  TAO_String_Manager &operator= (const CORBA::String_var&);
  // assignment from var type will make a copy

  TAO_String_Manager &operator= (const char *);
  // assignment from a constant char* will make a copy

  TAO_String_Manager &operator= (char *);
  // assignment from char* will not make a copy. The String_Manager will now
  // own the string.

  operator const char*() const;
  // cast  (read-only)

  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_;
  // The underlying string

};

/****************************************************************/

class TAO_Export TAO_SeqElem_String_Manager
{
  // = TITLE
  //   TAO_SeqElem_String_Manager
  //
  // = DESCRIPTION
  //   Manager for strings that are the element type of sequences.
  //
  //   Similar to the mapping for sequences of objects (and other
  //   pseudo objects) the mapping for sequences of strings requires
  //   an auxiliar class or <Manager> to handle the allocation and
  //   deallocation of the string.  The main difference with respect
  //   to String_var classes is that automatic release is not
  //   controlled on a per-item basis, but for the sequence as a
  //   whole.  The difference wrt Object_Manager is that strings are
  //   duplicated using CORBA::string_dup () as opposed to
  //   T::_duplicate(), and released using CORBA::string_free()
  //   instead of CORBA::release()
  //
  //   This class implements the generic string manager and is used to
  //   instantiate the proper sequence types.
  //
  //   This class will have the same semantics as the string manager classes
  //   defined earlier with respect to the various assignment
  //   operators. However, the freeing of old storage will be dependent on the
  //   "release" value of the parent sequence class.
  //
public:
  friend class TAO_Unbounded_String_Sequence;

  // @@ Giving friendship to a template is not implemented on several
  // compilers:
  // friend template<CORBA::ULong MAX>
  //   class TAO_Bounded_String_Sequence<TAO_SeqElem_String_Manager,MAX>;

  TAO_SeqElem_String_Manager (const TAO_SeqElem_String_Manager &);
  // copy constructor

  TAO_SeqElem_String_Manager (char **buffer, CORBA::Boolean release);
  // constructor from address of an element

  ~TAO_SeqElem_String_Manager (void);
  // destructor

  TAO_SeqElem_String_Manager &operator= (const TAO_SeqElem_String_Manager&);
  // assignment from another managed type

  TAO_SeqElem_String_Manager &operator= (const CORBA::String_var&);
  // assignment from var type will make a copy

  TAO_SeqElem_String_Manager &operator= (const char *);
  // assignment from a constant char* will make a copy

  TAO_SeqElem_String_Manager &operator= (char *);
  // assignment from char* will not make a copy. The SeqElem_String_Manager will now
  // own the string.

  operator const char*() const;
  // cast  (read-only)

  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_;
  // Address of string element from the parent's buffer.

  CORBA::Boolean release_;
  // control memory managment semantics.

  // following are now allowed since these managed class will be used only by
  // the [] operator of the sequence class. The [] operator will not use the
  // following ctors to instantiate the managed instance

  TAO_SeqElem_String_Manager (void);
  // default ctor

};

#if 0 /* WString_var not implemented in TAO yet - 01/03/1999 */
/****************************************************************/

class TAO_Export TAO_WString_Manager
{
  // = TITLE
  //   Manager for wide strings.
  //
  // = DESCRIPTION
  //
  //   This class implements the generic wstring manager and is used in the C++
  //   mapping of "struct" members that are of type "wstring". The difference
  //   between this class and the CORBA::WString_var class is that the default
  //   conctructor initializes the underlying wstring to an empty string in this
  //   class whereas it is a NUL wstring for the _var class.
  //
public:

  TAO_WString_Manager (void);
  // default CTOR will initialize the underlying ptr_ to empty string. 

  TAO_WString_Manager (const TAO_WString_Manager &);
  // copy constructor

  ~TAO_WString_Manager (void);
  // destructor

  TAO_WString_Manager &operator= (const TAO_WString_Manager&);
  // assignment from another managed type

  TAO_WString_Manager &operator= (const CORBA::WString_var&);
  // assignment from var type will make a copy

  TAO_WString_Manager &operator= (const CORBA::WChar *);
  // assignment from a constant wchar* will make a copy

  TAO_WString_Manager &operator= (CORBA::WChar *);
  // assignment from wchar* will not make a copy. The WString_Manager will now
  // own the string.

  operator const CORBA::WChar*() const;
  // cast  (read-only)

  const CORBA::WChar *in (void) const;
  // for in parameter.

  CORBA::WChar *&inout (void);
  // for inout parameter.

  CORBA::WChar *&out (void);
  // for out parameter.

  CORBA::WChar *_retn (void);
  // for string of return type.

private:
  CORBA::WChar *ptr_;
  // The underlying wide string

};

/****************************************************************/

class TAO_Export TAO_SeqElem_WString_Manager
{
  // = TITLE
  //   TAO_SeqElem_WString_Manager
  //
  // = DESCRIPTION
  //   Manager for strings that are the element type of sequences.
  //
  //   Similar to the mapping for sequences of objects (and other
  //   pseudo objects) the mapping for sequences of strings requires
  //   an auxiliar class or <Manager> to handle the allocation and
  //   deallocation of the string.  The main difference with respect
  //   to WString_var classes is that automatic release is not
  //   controlled on a per-item basis, but for the sequence as a
  //   whole.  The difference wrt Object_Manager is that strings are
  //   duplicated using CORBA::WString_dup () as opposed to
  //   T::_duplicate(), and released using CORBA::WString_free()
  //   instead of CORBA::release()
  //
  //   This class implements the generic string manager and is used to
  //   instantiate the proper sequence types.
  //
  //   This class will have the same semantics as the string manager classes
  //   defined earlier with respect to the various assignment
  //   operators. However, the freeing of old storage will be dependent on the
  //   "release" value of the parent sequence class.
  //
public:
  friend class TAO_Unbounded_WString_Sequence;

  // @@ Giving friendship to a template is not implemented on several
  // compilers:
  // friend template<CORBA::ULong MAX>
  //   class TAO_Bounded_WString_Sequence<TAO_SeqElem_WString_Manager,MAX>;

  TAO_SeqElem_WString_Manager (char **buffer, CORBA::Boolean release);
  // constructor from address of an element

  ~TAO_SeqElem_WString_Manager (void);
  // destructor

  TAO_SeqElem_WString_Manager &operator= (const TAO_SeqElem_WString_Manager&);
  // assignment from another managed type

  TAO_SeqElem_WString_Manager &operator= (const CORBA::WString_var&);
  // assignment from var type will make a copy

  TAO_SeqElem_WString_Manager &operator= (const char *);
  // assignment from a constant char* will make a copy

  TAO_SeqElem_WString_Manager &operator= (char *);
  // assignment from char* will not make a copy. The SeqElem_WString_Manager will now
  // own the string.

  operator const char*() const;
  // cast  (read-only)

  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_;
  // Address of string element from the parent's buffer.

  CORBA::Boolean release_;
  // control memory managment semantics.

  // following are now allowed since these managed class will be used only by
  // the [] operator of the sequence class. The [] operator will not use the
  // following ctors to instantiate the managed instance

  TAO_SeqElem_WString_Manager (void);
  // default ctor

  TAO_SeqElem_WString_Manager (const TAO_SeqElem_WString_Manager &);
  // copy constructor

};
#endif /* 0 */

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

#endif /* TAO_MANAGED_TYPES_H */