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

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    varout.h
//
// = DESCRIPTION
//     Templates for _var and _out types
//
// = AUTHOR
//
//   Aniruddha Gokhale
// ============================================================================

#ifndef TAO_VAROUT_H
#define TAO_VAROUT_H

class CORBA_Object;

template <class T>
class TAO_Object_Field_T : public TAO_Object_Field
{
  // = TITLE
  //   Parametric class to implement structure fields corresponding to
  //   object references.
  //
  // = DESCRIPTION
  //   When an object reference appears in a structure the marshaling
  //   and demarhsaling of the structure gets complicated:
  //   the interpreter can only marshal CORBA_Object_ptr when it
  //   dermarshal it creates on of those objects.
  //   The downcasting to the right type must be executed by classes
  //   with compile-time knowledge of the object type.
  //   The solution addopted in TAO is to create a special manager
  //   class for that field,
public:
  TAO_Object_Field_T (void);
  // default constructor

  TAO_Object_Field_T (T* object);
  // constructor from a T*, assumes ownership of <object> i.e. it
  // *will* release it.

  TAO_Object_Field_T (const TAO_Object_Field_T<T> &);
  // copy constructor

  virtual ~TAO_Object_Field_T (void);
  // destructor

  TAO_Object_Field_T<T> &operator= (T* object);
  // Assignment from a T*, it assumes ownership of <object>.

  TAO_Object_Field_T<T> &operator= (const TAO_Object_Field_T<T> &);
  // Assignment operator, in duplicates the underlying objects.

  T* operator-> (void) const;
  // smart pointer (const)

  operator T* const &() const;
  // cast operator

  operator T* &();
  // cast operator

  // = operations for parameter passing modes

  T* in (void) const;
  // for in type parameter

  T* &inout (void);
  // for inout type parameter

  T* &out (void);
  // for out parameter

  T* _retn (void);
  // for return type

  T* ptr (void) const;
  // TAO extension for access to the underlying pointer.

  virtual void _downcast (CORBA_Object* base_ptr,
                          CORBA_Environment &_env = CORBA_Environment::default_environment ());
  virtual CORBA_Object* _upcast (void);
  virtual void _release (void);
  // Implement the TAO_Object_Field methods.

private:
  T* ptr_;
};

// ****************************************************************
// The following classes are experimental, some of them do *not*
// compile and produce errors in compilers that check templates before
// instantiation time. In the future we may use them to implement
// several classes generated by IDL compiler, possibly reducing the
// complexity of the compiler.
// ****************************************************************
#if 0
template <class T>
class TAO_Fixed_var
  // = TITLE
  //    template<class T> TAO_Fixed_var
  //
  // = DESCRIPTION
  //    Provides a parametrized version of the _var class for fixed
  //    length data structs and unions.
{
public:
  // = Operations

  TAO_Fixed_var (void);
  // default constructor

  TAO_Fixed_var (T *);
  // constructor from a pointer to T

  TAO_Fixed_var (const TAO_Fixed_var<T> &);
  // copy constructor

  ~TAO_Fixed_var (void);
  // destructor

  TAO_Fixed_var<T> &operator= (T *);
  // assignment from a pointer to T

  TAO_Fixed_var<T> &operator= (const TAO_Fixed_var<T> &);
  // assignment from a TAO_Fixed_var

  T *operator-> (void);
  // smart pointer

  const T *operator-> (void) const;
  // smart pointer (const)

  operator const T *&() const;
  // cast operator

  operator T *&();
  // cast operator

  // = Operations for parameter passing modes.

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T &out (void);
  // for out parameter

  T _retn (void);
  // for return type

private:
  T *ptr_;
  // instance
};

template <class T>
class TAO_Variable_var
  // = TITLE
  //   template<class T> TAO_Variable_var
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for Variable
  //   length data structs and unions.
{
public:
  // = Operations

  TAO_Variable_var (void);
  // default constructor

  TAO_Variable_var (T *);
  // constructor from a pointer to T

  TAO_Variable_var (const TAO_Variable_var<T> &);
  // copy constructor

  ~TAO_Variable_var (void);
  // destructor

  TAO_Variable_var<T> &operator= (T *);
  // assignment from a pointer to T

  TAO_Variable_var<T> &operator= (const TAO_Variable_var<T> &);
  // assignment from a TAO_Variable_var

  T *operator-> (void);
  // smart pointer

  const T *operator-> (void) const;
  // smart pointer (const)

  operator const T *&() const;
  // cast operator

  operator T *&();
  // cast operator

  // = operations for parameter passing modes

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T *&out (void);
  // for out parameter

  T *_retn (void);
  // for return type

private:
  T *ptr_;
};

template <class T>
class TAO_Sequence_var
  // = TITLE
  //   template<class T> TAO_Sequence_var
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for Sequence
  //   data type.  CORBA sequences are considered to always be
  //   variable length.
{
public:
  // = Operations

  TAO_Sequence_var (void);
  // default constructor

  TAO_Sequence_var (T *);
  // constructor from a pointer to T

  TAO_Sequence_var (const TAO_Sequence_var &);
  // copy constructor

  ~TAO_Sequence_var (void);
  // destructor

  TAO_Sequence_var<T> &operator= (T *);
  // assignment from a pointer to T

  TAO_Sequence_var<T> &operator= (const TAO_Sequence_var &);
  // assignment from a TAO_Sequence_var

  T *operator-> (void);
  // smart pointer

  const T *operator-> (void) const;
  // smart pointer (const)

  operator const T *&() const;
  // cast operator

  operator T *&();
  // cast operator

  // = additional operators for sequence

  T::ElemType &operator[] (CORBA::ULong);
  // operator [] that passes the argument to the [] operator of T

  // = operations for parameter passing modes

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T *&out (void);
  // for out parameter

  T *_retn (void);
  // for return type

private:
  T *ptr_;
  // seq instance
};

template <class T, class T_ptr>
class TAO_Object_var
  // = TITLE
  //   template<class T, class T_ptr> TAO_Object_var
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for obj
  //   references.
{
public:
  // =Operations

  TAO_Object_var (void);
  // default constructor

  TAO_Object_var (T_ptr);
  // constructor from a pointer to T

  TAO_Object_var (const TAO_Object_var<T,T_ptr> &);
  // copy constructor

  ~TAO_Object_var (void);
  // destructor

  TAO_Object_var<T_ptr> &operator= (T_ptr);
  // assignment from a pointer to T

  TAO_Object_var<T_ptr> &operator= (const TAO_Object_var<T,T_ptr> &);
  // assignment from a TAO_Object_var

  T_ptr operator-> (void) const;
  // smart pointer (const)

  operator const T_ptr &() const;
  // cast operator

  operator T_ptr &();
  // cast operator

  // = operations for parameter passing modes

  const T_ptr &in (void);
  // for in type parameter

  T_ptr &inout (void);
  // for inout type parameter

  T_ptr &out (void);
  // for out parameter

  T_ptr _retn (void);
  // for return type

private:
  T_ptr ptr_;
};

template <class T, class T_slice>
class TAO_FixedArray_var
  // = TITLE
  //   template<class T, class T_slice> TAO_FixedArray_var
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for obj
  //   references.
{
public:
  // = Operations

  TAO_FixedArray_var (void);
  // default constructor

  TAO_FixedArray_var (T_slice *);
  // constructor from a pointer to T

  TAO_FixedArray_var (const TAO_FixedArray_var<T, T_slice> &);
  // copy constructor

  ~TAO_FixedArray_var (void);
  // destructor

  TAO_FixedArray_var<T, T_slice> &operator= (T_slice *);
  // assignment from a pointer to T

  TAO_FixedArray_var<T, T_slice> &operator= (const TAO_FixedArray_var<T, T_slice> &);
  // assignment from a TAO_FixedArray_var

  T_slice &operator[] (CORBA::ULong);
  // index

  const T_slice &operator[] (CORBA::ULong) const;
  // index

  operator const T_slice &() const;
  // cast operator

  operator T_slice &();
  // cast operator

  // = operations for parameter passing modes

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T &out (void);
  // for out parameter

  T_slice *_retn (void);
  // for return type

private:
  T_slice *ptr_;
};

template <class T, class T_slice>
class TAO_VariableArray_var
  // = TITLE
  //   template<class T, class T_slice> TAO_VariableArray_var
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for obj
  //   references.
{
public:
  // = Operations

  TAO_VariableArray_var (void);
  // default constructor

  TAO_VariableArray_var (T_slice *);
  // constructor from a pointer to T

  TAO_VariableArray_var (const TAO_VariableArray_var<T, T_slice> &);
  // copy constructor

  ~TAO_VariableArray_var (void);
  // destructor

  TAO_VariableArray_var<T, T_slice> &operator= (T_slice *);
  // assignment from a pointer to T

  TAO_VariableArray_var<T, T_slice> &operator= (const TAO_VariableArray_var<T, T_slice> &);
  // assignment from a TAO_VariableArray_var

  T_slice &operator[] (CORBA::ULong);
  // index

  const T_slice &operator[] (CORBA::ULong) const;
  // index

  operator const T_slice &() const;
  // cast operator

  operator T_slice &();
  // cast operator

  // = operations for parameter passing modes

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T_slice *&out (void);
  // for out parameter

  T_slice *_retn (void);
  // for return type

private:
  T_slice *ptr_;
};

template <class T, class T_slice>
class TAO_FixedArray_forany
  // = TITLE
  //   template<class T, class T_slice> TAO_FixedArray_forany
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for obj
  //   references.
{
public:
  // =Operations

  TAO_FixedArray_forany (void);
  // default constructor

  TAO_FixedArray_forany (T_slice *, CORBA::Boolean nocopy=0);
  // constructor from a pointer to T slice

  TAO_FixedArray_forany (const TAO_FixedArray_forany<T, T_slice> &);
  // copy constructor

  ~TAO_FixedArray_forany (void);
  // destructor

  TAO_FixedArray_forany<T, T_slice> &operator= (T_slice *);
  // assignment from a pointer to T

  TAO_FixedArray_forany<T, T_slice> &operator= (const TAO_FixedArray_forany<T, T_slice> &);
  // assignment from a TAO_FixedArray_forany

  T_slice &operator[] (CORBA::ULong);
  // index

  const T_slice &operator[] (CORBA::ULong) const;
  // index

  operator const T_slice &() const;
  // cast operator

  operator T_slice &();
  // cast operator

  // =operations for parameter passing modes

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T &out (void);
  // for out parameter

  T_slice *_retn (void);
  // for return type

private:
  T_slice *ptr_;
};

template <class T, class T_slice>
class TAO_VariableArray_forany
  // = TITLE
  //   template<class T, class T_slice> TAO_VariableArray_forany
  //
  // = DESCRIPTION
  //   Provides a parametrized version of the _var class for obj
  //   references.
{
public:
  // =Operations

  TAO_VariableArray_forany (void);
  // default constructor

  TAO_VariableArray_forany (T_slice *, CORBA::Boolean nocopy=0);
  // constructor from a pointer to T slice

  TAO_VariableArray_forany (const TAO_VariableArray_forany<T, T_slice> &);
  // copy constructor

  ~TAO_VariableArray_forany (void);
  // destructor

  TAO_VariableArray_forany<T, T_slice> &operator= (T_slice *);
  // assignment from a pointer to T

  TAO_VariableArray_forany<T, T_slice> &operator= (const TAO_VariableArray_forany<T, T_slice> &);
  // assignment from a TAO_VariableArray_forany

  T_slice &operator[] (CORBA::ULong);
  // index

  const T_slice &operator[] (CORBA::ULong) const;
  // index

  operator const T_slice &() const;
  // cast operator

  operator T_slice &();
  // cast operator

  // =operations for parameter passing modes

  const T &in (void);
  // for in type parameter

  T &inout (void);
  // for inout type parameter

  T_slice *&out (void);
  // for out parameter

  T_slice *_retn (void);
  // for return type

private:
  T_slice *ptr_;
};

template <class T, class T_var>
class TAO_Variable_out
  // = TITLE
  //   TAO_Variable_out
  //
  // = Description
  //  _out class definition for variable size struct/union.
{
public:
  TAO_Variable_out (T *&);
  // constructor

  TAO_Variable_out (T_var &);
  // constructor

  TAO_Variable_out (TAO_Variable_out <T,T_var> &);
  // copy constructor

  TAO_Variable_out<T,T_var> &operator= (TAO_Variable_out<T,T_var> &);
  // assignment operator

  TAO_Variable_out<T,T_var> &operator= (T *);
  // assignment

  operator T *&();
  // cast

  T *&ptr (void);
  // ptr method, returns a pointer to class T

  T *operator-> (void);
  // arrow operator (smart pointer)

private:
  T *&ptr_;
};

template <class T, class T_var>
class TAO_Sequence_out
  // = TITLE
  //   TAO_Sequence_out
  //
  // = Description
  //   _out class definition for Sequence
{
public:
  TAO_Sequence_out (T *&);
  // constructor

  TAO_Sequence_out (T_var &);
  // constructor

  TAO_Sequence_out (TAO_Sequence_out <T,T_var> &);
  // copy constructor

  TAO_Sequence_out<T,T_var> &operator= (TAO_Sequence_out<T,T_var> &);
  // assignment operator

  TAO_Sequence_out<T,T_var> &operator= (T *);
  // assignment

  operator T *&();
  // cast

  T *&ptr (void);
  // ptr method, returns a pointer to class T

  T *operator-> (void);
  // arrow operator (smart pointer)

  T::ElemType operator[] (CORBA::ULong);
  // return the element at index i

private:
  T *&ptr_;
};

template <class T_ptr, class T_var>
class TAO_Object_out
{
  // = TITLE
  //   TAO_Object_out
  //
  // = Description
  //   _out class definition for Object
public:
  TAO_Object_out (T_ptr &);
  // constructor

  TAO_Object_out (T_var &);
  // constructor

  TAO_Object_out (TAO_Object_out <T_ptr,T_var> &);
  // copy constructor

  TAO_Object_out<T_ptr,T_var> &operator= (TAO_Object_out<T_ptr,T_var> &);
  // assignment operator

  TAO_Object_out<T_ptr,T_var> &operator= (const T_var &);
  // assignment operator

  TAO_Object_out<T_ptr,T_var> &operator= (T_ptr);
  // assignment

  operator T_ptr &();
  // cast

  T_ptr &ptr (void);
  // ptr method, returns a pointer to class T

  T_ptr operator-> (void);
  // arrow operator (smart pointer)

private:
  T_ptr &ptr_;
};
#endif /* 0 */

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

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "tao/varout.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("varout.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#endif /* TAO_VAROUT_H */