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
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
|
/* -*- C++ -*- */
// $Id$
// ============================================================================
//
// = LIBRARY
// TAO
//
// = FILENAME
// sequence_T.h
//
// = AUTHOR
// Carlos O'Ryan and Aniruddha Gokhale
//
// ============================================================================
#ifndef TAO_SEQUENCE_T_H
#define TAO_SEQUENCE_T_H
#include "ace/pre.h"
#include "tao/Sequence.h"
template <class T>
class TAO_Unbounded_Sequence : public TAO_Unbounded_Base_Sequence
{
// = TITLE
// Parametrized implementation of IDL unbounded sequences.
//
// = DESCRIPTION
// This class completes the implementation for TAO_Base_Sequence
// for the unbounded case.
public:
// = Initialization and termination methods.
TAO_Unbounded_Sequence (void);
// Default constructor.
TAO_Unbounded_Sequence (CORBA::ULong max);
// Constructor using a maximum length value.
TAO_Unbounded_Sequence (CORBA::ULong max,
CORBA::ULong length,
T *data,
CORBA::Boolean release = 0);
// Constructor using the data and memory management flag. Memory
// *must* be allocated using the ::allocbuf static method, since in
// the future this classes may use a global ACE_Allocator.
TAO_Unbounded_Sequence (const TAO_Unbounded_Sequence<T> &);
// Copy constructor.
TAO_Unbounded_Sequence<T> &operator= (const TAO_Unbounded_Sequence<T> &);
// Assignment operator.
~TAO_Unbounded_Sequence (void);
// Dtor.
// = Accessors.
T &operator[] (CORBA::ULong);
// operator []
const T &operator[] (CORBA::ULong) const;
// operator []
// = Static operations.
static T *allocbuf (CORBA::ULong);
// Allocate storage for the sequence.
static void freebuf (T *);
// Free the sequence.
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
// Implement the TAO_Base_Sequence methods (see Sequence.h)
// = orbos/98-01-11 proposed extensions.
T *get_buffer (CORBA::Boolean orphan = 0);
// Allows read-write access to the underlying buffer. If <orphan>
// is FALSE the sequence returns a pointer to its buffer, allocating
// one if it has not yet done so. The number of elements in the
// buffer can be determined from the sequence <length> accessor.
//
// If the <orphan> argument to <get_buffer> is FALSE, the sequence
// maintains ownership of the underlying buffer. Elements in the
// returned buffer may be directly replaced by the caller. For
// sequences of strings, wide strings, and object references, the
// caller must use the sequence <release> accessor to determine
// whether elements should be freed (using <string_free>,
// <wstring_free>, or <CORBA::release> for strings, wide straings,
// and object references, respective) before being directly assigned
// to.
//
// If the <orphan> argument to <get_buffer> is TRUE, the sequence
// yields ownership of the buffer to the caller. If <orphan> is
// TRUE and the sequence does not own its buffer (i.e., its
// <release> flag is FALSE), the return value is a null pointer. If
// the buffer is taken from the sequence using this form of
// <get_buffer>, the sequence reverts to the same state it would
// have if constructed using its default constructor. The caller
// becomes responsible for eventually freeing each element of the
// returned buffer (for strings, wide string, and object
// references), and then freeing the returned buffer itself using
// <freebuf>.
const T *get_buffer (void) const;
// This function allows read-only access to the sequence buffer.
// The sequence returns its buffer, allocating one of one has not
// yet been allocated. No direct modification of the returned
// buffer by the caller is permitted.
void replace (CORBA::ULong max,
CORBA::ULong length,
T *data,
CORBA::Boolean release = 0);
// Allows the buffer underlying a sequence to be replaced. The
// parameters to <replace> are identical in type, order, and purpose
// to those for the <T *data> constructor for the sequence.
};
template <class T, size_t MAX>
class TAO_Bounded_Sequence : public TAO_Bounded_Base_Sequence
{
// = TITLE
// Parametric bounded sequence.
//
// = DESCRIPTION
// This class completes the implementation for TAO_Base_Sequence
// for the bounded case.
public:
// = Initialization and termination methods.
TAO_Bounded_Sequence (void);
// Default constructor.
TAO_Bounded_Sequence (CORBA::ULong length,
T *data,
CORBA::Boolean release=0);
// Constructor using the data and memory management flag.
TAO_Bounded_Sequence (const TAO_Bounded_Sequence<T,MAX> &);
// Copy constructor.
TAO_Bounded_Sequence<T,MAX> &operator= (const TAO_Bounded_Sequence<T,MAX> &);
// Assignment operator.
~TAO_Bounded_Sequence (void);
// Dtor.
// = Accessors.
T &operator[] (CORBA::ULong);
// operator []
const T &operator[] (CORBA::ULong) const;
// operator []
// = Static operations.
static T *allocbuf (CORBA::ULong);
// Allocate storage for the sequence.
static void freebuf (T *);
// Free the sequence.
virtual void _allocate_buffer (CORBA::ULong length);
// allocate a buffer of the requested length. The buffer is allocated for the
// right type
virtual void _deallocate_buffer (void);
// deallocate the buffer
// = orbos/98-01-11 proposed extensions.
T *get_buffer (CORBA::Boolean orphan = 0);
// Allows read-write access to the underlying buffer. If <orphan>
// is FALSE the sequence returns a pointer to its buffer, allocating
// one if it has not yet done so. The size of the returned buffer
// is equal to the sequence bound, which can be determined with the
// <maximum> accessor. The number of elements in the buffer can be
// determined from the sequence <length> accessor.
//
// If the <orphan> argument to <get_buffer> is FALSE, the sequence
// maintains ownership of the underlying buffer. Elements in the
// returned buffer may be directly replaced by the caller. For
// sequences of strings, wide strings, and object references, the
// caller must use the sequence <release> accessor to determine
// whether elements should be freed (using <string_free>,
// <wstring_free>, or <CORBA::release> for strings, wide straings,
// and object references, respective) before being directly assigned
// to.
//
// If the <orphan> argument to <get_buffer> is TRUE, the sequence
// yields ownership of the buffer to the caller. If <orphan> is
// TRUE and the sequence does not own its buffer (i.e., its
// <release> flag is FALSE), the return value is a null pointer. If
// the buffer is taken from the sequence using this form of
// <get_buffer>, the sequence reverts to the same state it would
// have if constructed using its default constructor. The caller
// becomes responsible for eventually freeing each element of the
// returned buffer (for strings, wide string, and object
// references), and then freeing the returned buffer itself using
// <freebuf>.
const T *get_buffer (void) const;
// This function allows read-only access to the sequence buffer.
// The sequence returns its buffer, allocating one of one has not
// yet been allocated. No direct modification of the returned
// buffer by the caller is permitted.
void replace (CORBA::ULong max,
CORBA::ULong length,
T *data,
CORBA::Boolean release = 0);
// Allows the buffer underlying a sequence to be replaced. The
// parameters to <replace> are identical in type, order, and purpose
// to those for the <T *data> constructor for the sequence.
};
// *************************************************************
template<class T,class T_var> class TAO_Unbounded_Object_Sequence;
template<class T,class T_var> class TAO_Unbounded_Pseudo_Sequence;
template<class T, class T_var, size_t MAX> class TAO_Bounded_Object_Sequence;
template<size_t MAX> class TAO_Bounded_String_Sequence;
// *************************************************************
template<class T, class T_var>
class TAO_Object_Manager
{
// = TITLE
// Manager for Objects.
//
// = DESCRIPTION
// The mapping for sequences of objects (and other pseudo objects)
// requires an auxiliar class or <Manager> to handle the reference
// count on the object, (a kind of smart pointer).
// The main difference with respect to T_var classes is that
// automatic release is not controlled on a per-item basis, but
// for the sequence as a whole.
// Further the class must implement "transparent" assignment into
// the sequence, for instance, operator[] returns a managed
// object, but:
//
// object_sequence[i] = foo;
//
// must change the state of the sequence.
//
// This class implements the generic object manager and is used to
// instantiate the proper sequence types.
//
// = NOTES
// It has been proposed that the class should be parametric on
// both T and T_ptr, IMHO this is no necesary: though the IDL spec
// says that T_ptr *could* map to a type different to T* in the
// particular case of TAO it does map to <T*>.
//
friend class TAO_Unbounded_Object_Sequence<T,T_var>;
public:
// @@ Use partial template specialization here to give access only
// to the right kind of sequence.
// friend template<CORBA::ULong MAX>
// class TAO_Bounded_Object_Sequence<T,MAX>;
// = Initialization and termination methods.
TAO_Object_Manager (const TAO_Object_Manager<T,T_var> &rhs);
// Copy constructor, the semantics are non-trivial:
// + The referenced element is duplicated or not according to the
// release value on the <rhs>.
// + In any case a new reference to the same object is created.
TAO_Object_Manager (T **, CORBA::Boolean release);
// Constructor from address of an element, it should be private and
// only TAO_*_Object_Sequence would use it, but we have some
// problems with friendship and templates.
~TAO_Object_Manager (void);
// Destructor, only releases the object if <release_> is true.
TAO_Object_Manager<T,T_var> &operator= (const TAO_Object_Manager<T,T_var> &rhs);
// Assignment from another managed type, only release if
// <this->release_> is true.
// @@ TODO what happens if rhs.release_ is true an this->relase_ is
// false?
TAO_Object_Manager<T,T_var> &operator= (T *);
// Assignment from T *.
TAO_Object_Manager<T,T_var> &operator= (T_var &);
// Assignment from T *.
T * operator-> (void) const;
// Return pointer.
operator const T *() const;
// Cast (read-only).
operator T *&();
// Cast.
operator const T_var () const;
T *in (void) const;
// for in parameter.
T *&inout (void);
// for inout parameter.
T *&out (void);
// for out parameter.
T *_retn (void);
// for return type
private:
T **ptr_;
// data member, notice that it is a pointer, to implement the
// reference behavior for assignment.
CORBA::Boolean release_;
// release flag based on parent's flag
};
template<class T, class T_var>
class TAO_Pseudo_Object_Manager
{
// = TITLE
// Manager for Pseudo Objects.
//
// = DESCRIPTION
//
friend class TAO_Unbounded_Pseudo_Sequence<T,T_var>;
public:
// @@ Use partial template specialization here to give access only
// to the right kind of sequence.
// friend template<CORBA::ULong MAX>
// class TAO_Bounded_Object_Sequence<T,MAX>;
// = Initialization and termination methods.
TAO_Pseudo_Object_Manager (const TAO_Pseudo_Object_Manager<T,T_var> &rhs);
// Copy constructor, the semantics are non-trivial:
// + The referenced element is duplicated or not according to the
// release value on the <rhs>.
// + In any case a new reference to the same object is created.
TAO_Pseudo_Object_Manager (T **, CORBA::Boolean release);
// Constructor from address of an element, it should be private and
// only TAO_*_Object_Sequence would use it, but we have some
// problems with friendship and templates.
~TAO_Pseudo_Object_Manager (void);
// Destructor, only releases the object if <release_> is true.
TAO_Pseudo_Object_Manager<T,T_var> &operator= (const TAO_Pseudo_Object_Manager<T,T_var> &rhs);
// Assignment from another managed type, only release if
// <this->release_> is true.
// @@ TODO what happens if rhs.release_ is true an this->relase_ is
// false?
TAO_Pseudo_Object_Manager<T,T_var> &operator= (T *);
// Assignment from T *.
TAO_Pseudo_Object_Manager<T,T_var> &operator= (T_var &);
// Assignment from T *.
T * operator-> (void) const;
// Return pointer.
operator const T *() const;
// Cast (read-only).
operator T *&();
// Cast.
T *in (void) const;
// for in parameter.
T *&inout (void);
// for inout parameter.
T *&out (void);
// for out parameter.
T *_retn (void);
// for return type
private:
T **ptr_;
// data member, notice that it is a pointer, to implement the
// reference behavior for assignment.
CORBA::Boolean release_;
// release flag based on parent's flag
};
// *************************************************************
template<class T,class T_var>
class TAO_Unbounded_Object_Sequence : public TAO_Unbounded_Base_Sequence
{
// = TITLE
// Parametric sequence for types that require managers.
//
// = DESCRIPTION
// Some IDL types require that sequences on them have a "manager"
// class, in charge of handling the object lifetime, examples are
// pseudo objects, object references and strings.
// = SPEC
// 16.8 Mapping for Structured Types
// The mapping for struct, union, and sequence (but not array) is a
// C++ struct or class with a default constructor, a copy
// constructor, an assignment operator, and a destructor.
//
public:
// = Initialization and termination methods.
TAO_Unbounded_Object_Sequence (void);
// {orbos/97-05-15:16.8}
// The default constructor initializes object reference members to
// appropriately typed nil object references and string members to
// NULL; all other members are initialized via their default
// constructors.
//
// {orbos/97-05-15:16.11}
// For both bounded and unbounded sequences, the default constructor
// (as shown in the example above) sets the sequence length equal to
// 0.
TAO_Unbounded_Object_Sequence (CORBA::ULong max);
// Unbounded sequences provide a constructor that allows only the
// initial value of the maximum length to be set (the ``maximum
// constructor'' shown in the example above). This allows
// applications to control how much buffer space is initially
// allocated by the sequence. This constructor also sets the length
// to 0 and the release flag to TRUE.
TAO_Unbounded_Object_Sequence (CORBA::ULong maximum,
CORBA::ULong length,
T* *data,
CORBA::Boolean release=0);
// The ``T *data'' constructor (as shown in the example above)
// allows the length and contents of a bounded or unbounded sequence
// to be set. For unbounded sequences, it also allows the initial
// value of the maximum length to be set. For this constructor,
// ownership of the contents vector is determined by the release
// parameter---FALSE means the caller owns the storage, while TRUE
// means that the sequence assumes ownership of the storage.
// If release is TRUE, the contents vector must have been allocated
// using the sequence allocbuf function, and the sequence will pass
// it to freebuf when finished with it.
TAO_Unbounded_Object_Sequence(const TAO_Unbounded_Object_Sequence<T,T_var> &);
// The copy constructor performs a deep copy from the existing
// structure to create a new structure, including calling _duplicate
// on all object reference members and performing the necessary
// heap allocations for all string members.
//
// The copy constructor creates a new sequence with the same maximum
// and length as the given sequence, copies each of its current
// elements (items zero through length-1), and sets the release
// flag to TRUE.
~TAO_Unbounded_Object_Sequence (void);
// The destructor releases all object reference memebrs and frees
// all string members.
TAO_Unbounded_Object_Sequence<T,T_var> &operator= (const TAO_Unbounded_Object_Sequence <T,T_var> &);
// The assignment operator first releases all object reference
// members and frees all string members, and then performs a
// deepcopy to create a new structure.
//
// The assignment operator deepcopies its parameter, releasing old
// storage if necessary. It behaves as if the original sequence is
// destroyed via its destructor and then the source sequence copied
// using the copy constructor. If release=TRUE, the destructor
// destroys each of the current elements (items zero through
// length--1). For an unbounded sequence, if a reallocation is
// necessary due to a change in the length and the sequence was
// created using the release=TRUE parameter in its constructor, the
// sequence will deallocate the old storage. If release is FALSE
// under these circumstances, old storage will not be freed before
// the reallocation is performed. After reallocation, the release
// flag is always set to TRUE.
TAO_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
// read-write accessor
static T **allocbuf (CORBA::ULong);
// The allocbuf function allocates a vector of T elements that can
// be passed to the T *data constructor. The length of the vector is
// given by the nelems function argument. The allocbuf function
// initializes each element using its default constructor, except
// for strings, which are initialized to null pointers, and object
// references, which are initialized to suitably typed nil object
// references. A null pointer is returned if allocbuf for some
// reason cannot allocate the requested vector. Vectors allocated by
// allocbuf should be freed using the freebuf function.
static void freebuf (T **);
// The freebuf function ensures that the destructor for each element
// is called before the buffer is destroyed, except for string
// elements, which are freed using string_free(), and object
// reference elements, which are freed using release(). The freebuf
// function will ignore null pointers passed to it.
// The Base_Sequence functions, please see "tao/Sequence.h"
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
virtual void _shrink_buffer (CORBA::ULong new_length,
CORBA::ULong old_length);
virtual void _downcast (void* target,
CORBA_Object* src,
CORBA_Environment &ACE_TRY_ENV =
TAO_default_environment ());
// No default to workaround egcs problem with templates and
// namespaces
virtual CORBA_Object* _upcast (void* src) const;
};
// *************************************************************
template<class T, class T_var, size_t MAX>
class TAO_Bounded_Object_Sequence : public TAO_Bounded_Base_Sequence
{
// = TITLE
// Parametric sequence for types that require managers.
//
// = DESCRIPTION
// Please see the documentation for the unbounded case.
//
public:
// = Initialization and termination methods.
TAO_Bounded_Object_Sequence (void);
// For bounded sequences, the maximum length is part of the type and
// cannot be set or modified, while for unbounded sequences, the
// default constructor also sets the maximum length to 0. The
// default constructor for a bounded sequence always allocates a
// contents vector, so it always sets the release flag to TRUE.
TAO_Bounded_Object_Sequence (CORBA::ULong length,
T* *value,
CORBA::Boolean release=0);
// Constructor from data.
TAO_Bounded_Object_Sequence (const TAO_Bounded_Object_Sequence<T,T_var,MAX> &);
// Copy constructor.
~TAO_Bounded_Object_Sequence (void);
// destructor
TAO_Bounded_Object_Sequence &operator= (const TAO_Bounded_Object_Sequence<T,T_var,MAX> &);
// Assignment from another Bounded sequence.
TAO_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
// Read-write accessor.
static T **allocbuf (CORBA::ULong length);
// Allocate storage for a sequence..
static void freebuf (T **buffer);
// Free a buffer allocated by allocbuf() and release each element on
// it.
// The Base_Sequence functions, please see "tao/sequence.h"
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
virtual void _shrink_buffer (CORBA::ULong new_length,
CORBA::ULong old_length);
virtual void _downcast (void* target,
CORBA_Object* src,
CORBA_Environment &ACE_TRY_ENV =
TAO_default_environment ());
// No default to workaround egcs problem with templates and
// namespaces
virtual CORBA_Object* _upcast (void* src) const;
};
// *************************************************************
template<class T,class T_var>
class TAO_Unbounded_Pseudo_Sequence : public TAO_Unbounded_Base_Sequence
{
// = TITLE
// Parametric sequence for pseudo objects.
//
// = DESCRIPTION
// Some IDL types (including pseudo objects) require that
// sequences on them have a "manager" class, in charge of handling
// the object lifetime.
// This parametric class implements those sequences. In general
// the sequence is similar to Object_Sequente, except for some
// TAO internal details. The complete documentation of each method
// is provided in TAO_Unbounded_Object_Sequece
public:
// = Initialization and termination methods.
TAO_Unbounded_Pseudo_Sequence (void);
// default ctor
TAO_Unbounded_Pseudo_Sequence (CORBA::ULong max);
// Constructor with a "hint" for the maximum capacity.
TAO_Unbounded_Pseudo_Sequence (CORBA::ULong maximum,
CORBA::ULong length,
T* *data,
CORBA::Boolean release=0);
// Constructor with a given buffer.
TAO_Unbounded_Pseudo_Sequence(const TAO_Unbounded_Pseudo_Sequence<T,T_var> &);
// Copy ctor, deep copies.
~TAO_Unbounded_Pseudo_Sequence (void);
// dtor releases all the contained elements.
TAO_Unbounded_Pseudo_Sequence<T,T_var> &operator= (const TAO_Unbounded_Pseudo_Sequence <T,T_var> &);
// The assignment operator first releases all object reference
// members and frees all string members, and then performs a
// deepcopy to create a new structure.
TAO_Pseudo_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
// read-write accessor
static T **allocbuf (CORBA::ULong);
// The allocbuf function allocates a vector of T elements that can
// be passed to the T *data constructor.
static void freebuf (T **);
// Release all the elements.
// The Base_Sequence functions, please see "tao/Sequence.h"
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
virtual void _shrink_buffer (CORBA::ULong new_length,
CORBA::ULong old_length);
};
// *************************************************************
template<class T, class T_var, size_t MAX>
class TAO_Bounded_Pseudo_Sequence : public TAO_Bounded_Base_Sequence
{
// = TITLE
// Bounded version of TAO_Unbounded_Pseudo_Sequence.
//
// = DESCRIPTION
// Please see the documentation for the unbounded case.
//
public:
// = Initialization and termination methods.
TAO_Bounded_Pseudo_Sequence (void);
// default ctor.
TAO_Bounded_Pseudo_Sequence (CORBA::ULong length,
T* *value,
CORBA::Boolean release=0);
// Constructor from data.
TAO_Bounded_Pseudo_Sequence (const TAO_Bounded_Pseudo_Sequence<T,T_var,MAX> &);
// Copy constructor.
~TAO_Bounded_Pseudo_Sequence (void);
// destructor
TAO_Bounded_Pseudo_Sequence &operator= (const TAO_Bounded_Pseudo_Sequence<T,T_var,MAX> &);
// Assignment from another Bounded sequence.
TAO_Pseudo_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
// Read-write accessor.
static T **allocbuf (CORBA::ULong length);
// Allocate storage for a sequence..
static void freebuf (T **buffer);
// Free a buffer allocated by allocbuf() and release each element on
// it.
// The Base_Sequence functions, please see "tao/sequence.h"
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
virtual void _shrink_buffer (CORBA::ULong new_length,
CORBA::ULong old_length);
};
// *************************************************************
template<class T, class T_var>
class TAO_Unbounded_Array_Sequence : public TAO_Unbounded_Base_Sequence
{
// = TITLE
// Parametric sequence for arrays.
//
// = DESCRIPTION
// The IDL mapping for arrays includes some unique allocation,
// deallocation, and copying functions, and precludes
// direct assignment of one array to another. Also, the
// Any and CDR operators use a special class derived from
// the array. For these reasons, we use a special class for
// sequences of arrays, parametrized on the array element type.
public:
// = Initialization and termination methods.
TAO_Unbounded_Array_Sequence (void);
// default ctor
TAO_Unbounded_Array_Sequence (CORBA::ULong max);
// Constructor with a "hint" for the maximum capacity.
TAO_Unbounded_Array_Sequence (CORBA::ULong maximum,
CORBA::ULong length,
T *data,
CORBA::Boolean release=0);
// Constructor with a given buffer.
TAO_Unbounded_Array_Sequence(const TAO_Unbounded_Array_Sequence<T, T_var> &);
// Copy ctor, deep copies.
~TAO_Unbounded_Array_Sequence (void);
// dtor releases all the contained elements.
TAO_Unbounded_Array_Sequence<T, T_var> &operator= (
const TAO_Unbounded_Array_Sequence <T, T_var> &
);
// The assignment operator first releases all object reference
// members and frees all string members, and then performs a
// deepcopy to create a new structure.
// = Accessors.
T &operator[] (CORBA::ULong);
// operator []
const T &operator[] (CORBA::ULong) const;
// operator []
static T *allocbuf (CORBA::ULong);
// The allocbuf function allocates a vector of T elements that can
// be passed to the T *data constructor.
static void freebuf (T *);
// Release all the elements.
virtual void _allocate_buffer (CORBA::ULong length);
// allocate a buffer of the requested length. The buffer is allocated for the
// right type
virtual void _deallocate_buffer (void);
// deallocate the buffer
// = orbos/98-01-11 proposed extensions.
T *get_buffer (CORBA::Boolean orphan = 0);
// Allows read-write access to the underlying buffer. If <orphan>
// is FALSE the sequence returns a pointer to its buffer, allocating
// one if it has not yet done so. The number of elements in the
// buffer can be determined from the sequence <length> accessor.
//
// If the <orphan> argument to <get_buffer> is FALSE, the sequence
// maintains ownership of the underlying buffer. Elements in the
// returned buffer may be directly replaced by the caller.
//
// If the <orphan> argument to <get_buffer> is TRUE, the sequence
// yields ownership of the buffer to the caller. If <orphan> is
// TRUE and the sequence does not own its buffer (i.e., its
// <release> flag is FALSE), the return value is a null pointer. If
// the buffer is taken from the sequence using this form of
// <get_buffer>, the sequence reverts to the same state it would
// have if constructed using its default constructor. The caller
// becomes responsible for eventually freeing each element of the
// returned buffer (for strings, wide string, and object
// references), and then freeing the returned buffer itself using
// <freebuf>.
const T *get_buffer (void) const;
// This function allows read-only access to the sequence buffer.
// The sequence returns its buffer, allocating one of one has not
// yet been allocated. No direct modification of the returned
// buffer by the caller is permitted.
void replace (CORBA::ULong max,
CORBA::ULong length,
T *data,
CORBA::Boolean release = 0);
// Allows the buffer underlying a sequence to be replaced. The
// parameters to <replace> are identical in type, order, and purpose
// to those for the <T *data> constructor for the sequence.
};
// *************************************************************
template<class T, class T_var, size_t MAX>
class TAO_Bounded_Array_Sequence : public TAO_Bounded_Base_Sequence
{
// = TITLE
// Bounded version of TAO_Unbounded_Array_Sequence.
//
// = DESCRIPTION
// Please see the documentation for the unbounded case.
//
public:
// = Initialization and termination methods.
TAO_Bounded_Array_Sequence (void);
// default ctor.
TAO_Bounded_Array_Sequence (CORBA::ULong length,
T *value,
CORBA::Boolean release=0);
// Constructor from data.
TAO_Bounded_Array_Sequence (const TAO_Bounded_Array_Sequence<T, T_var, MAX> &);
// Copy constructor.
~TAO_Bounded_Array_Sequence (void);
// destructor
TAO_Bounded_Array_Sequence &operator= (const TAO_Bounded_Array_Sequence<T, T_var, MAX> &);
// Assignment from another Bounded sequence.
// = Accessors.
T &operator[] (CORBA::ULong);
// operator []
const T &operator[] (CORBA::ULong) const;
// operator []
static T *allocbuf (CORBA::ULong length);
// Allocate storage for a sequence..
static void freebuf (T *buffer);
// Free a buffer allocated by allocbuf() and release each element on
// it.
virtual void _allocate_buffer (CORBA::ULong length);
// allocate a buffer of the requested length. The buffer is allocated for the
// right type
virtual void _deallocate_buffer (void);
// deallocate the buffer
// = orbos/98-01-11 proposed extensions.
T *get_buffer (CORBA::Boolean orphan = 0);
// Allows read-write access to the underlying buffer. If <orphan>
// is FALSE the sequence returns a pointer to its buffer, allocating
// one if it has not yet done so. The number of elements in the
// buffer can be determined from the sequence <length> accessor.
//
// If the <orphan> argument to <get_buffer> is FALSE, the sequence
// maintains ownership of the underlying buffer. Elements in the
// returned buffer may be directly replaced by the caller.
//
// If the <orphan> argument to <get_buffer> is TRUE, the sequence
// yields ownership of the buffer to the caller. If <orphan> is
// TRUE and the sequence does not own its buffer (i.e., its
// <release> flag is FALSE), the return value is a null pointer. If
// the buffer is taken from the sequence using this form of
// <get_buffer>, the sequence reverts to the same state it would
// have if constructed using its default constructor. The caller
// becomes responsible for eventually freeing each element of the
// returned buffer (for strings, wide string, and object
// references), and then freeing the returned buffer itself using
// <freebuf>.
const T *get_buffer (void) const;
// This function allows read-only access to the sequence buffer.
// The sequence returns its buffer, allocating one of one has not
// yet been allocated. No direct modification of the returned
// buffer by the caller is permitted.
void replace (CORBA::ULong max,
CORBA::ULong length,
T *data,
CORBA::Boolean release = 0);
// Allows the buffer underlying a sequence to be replaced. The
// parameters to <replace> are identical in type, order, and purpose
// to those for the <T *data> constructor for the sequence.
};
// *************************************************************
template<size_t MAX>
class TAO_Bounded_String_Sequence : public TAO_Bounded_Base_Sequence
{
// = TITLE
// Bounded sequence of strings.
//
// = DESCRIPTION
// As its unbounded counterpart it duplicates and releases strings
// (via CORBA::string_dup and CORBA::string_free) under the
// control of a per sequence flag, but the capacity of the
// sequence is bound on the type.
public:
TAO_Bounded_String_Sequence (void);
// {SPEC}
// For bounded sequences, the maximum length is part of the type and
// cannot be set or modified, while for unbounded sequences, the
// default constructor also sets the maximum length to 0. The
// default constructor for a bounded sequence always allocates a
// contents vector, so it always sets the release flag to TRUE.
TAO_Bounded_String_Sequence (CORBA::ULong length,
char* *value,
CORBA::Boolean release = 0);
// {SPEC}
// The ``T *data'' constructor (as shown in the example above)
// allows the length and contents of a bounded or unbounded sequence
// to be set. For unbounded sequences, it also allows the initial
// value of the maximum length to be set. For this constructor,
// ownership of the contents vector is determined by the release
// parameter---FALSE means the caller owns the storage, while TRUE
// means that the sequence assumes ownership of the storage.
//
// If release is TRUE, the contents vector must have been allocated
// using the sequence allocbuf function, and the sequence will pass
// it to freebuf when finished with it.
TAO_Bounded_String_Sequence (const TAO_Bounded_String_Sequence<MAX> &);
// {SPEC}
// Management Functions'' on page 16. The copy constructor creates a
// new sequence with the same maximum and length as the given
// sequence, copies each of its current elements (items zero through
// length--1), and sets the release flag to TRUE.
TAO_Bounded_String_Sequence &operator= (const TAO_Bounded_String_Sequence<MAX> &);
// {SPEC}
// The assignment operator deep copies its parameter, releasing
// old storage if necessary. It behaves as if the original sequence
// is destroyed via its destructor and then the source sequence
// copied using the copy constructor.
~TAO_Bounded_String_Sequence (void);
// {SPEC}
// If release=TRUE, the destructor destroys each of the current
// elements (items zero through length-1).
TAO_SeqElem_String_Manager operator[] (CORBA::ULong slot) const;
// read-write accessor
static char **allocbuf (CORBA::ULong length);
// {SPEC}
// The allocbuf function allocates a vector of T elements that can
// be passed to the T *data constructor. The length of the vector is
// given by the nelems function argument. The allocbuf function
// initializes each element using its default constructor, except
// for strings, which are initialized to null pointers, and object
// references, which are initialized to suitably typed nil object
// references. A null pointer is returned if allocbuf for some
// reason cannot allocate the requested vector. Vectors allocated by
// allocbuf should be freed using the freebuf function.
static void freebuf (char **buffer);
// {SPEC}
// The freebuf function ensures that the destructor for each element
// is called before the buffer is destroyed, except for string
// elements, which are freed using string_free(), and object
// reference elements, which are freed using release(). The freebuf
// function will ignore null pointers passed to it.
// Functions to create, destroy, and adjust the underlying buffer.
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
virtual void _shrink_buffer (CORBA::ULong new_length,
CORBA::ULong old_length);
};
// *************************************************************
template<size_t MAX>
class TAO_Bounded_WString_Sequence : public TAO_Bounded_Base_Sequence
{
// = TITLE
// Bounded sequence of wstrings.
//
// = DESCRIPTION
// As its unbounded counterpart it duplicates and releases strings
// (via CORBA::wstring_dup and CORBA::wstring_free) under the
// control of a per sequence flag, but the capacity of the
// sequence is bound on the type.
public:
TAO_Bounded_WString_Sequence (void);
// {SPEC}
// For bounded sequences, the maximum length is part of the type and
// cannot be set or modified, while for unbounded sequences, the
// default constructor also sets the maximum length to 0. The
// default constructor for a bounded sequence always allocates a
// contents vector, so it always sets the release flag to TRUE.
TAO_Bounded_WString_Sequence (CORBA::ULong length,
CORBA::WChar* *value,
CORBA::Boolean release = 0);
// {SPEC}
// The ``T *data'' constructor (as shown in the example above)
// allows the length and contents of a bounded or unbounded sequence
// to be set. For unbounded sequences, it also allows the initial
// value of the maximum length to be set. For this constructor,
// ownership of the contents vector is determined by the release
// parameter---FALSE means the caller owns the storage, while TRUE
// means that the sequence assumes ownership of the storage.
//
// If release is TRUE, the contents vector must have been allocated
// using the sequence allocbuf function, and the sequence will pass
// it to freebuf when finished with it.
TAO_Bounded_WString_Sequence (const TAO_Bounded_WString_Sequence<MAX> &);
// {SPEC}
// Management Functions'' on page 16. The copy constructor creates a
// new sequence with the same maximum and length as the given
// sequence, copies each of its current elements (items zero through
// length--1), and sets the release flag to TRUE.
TAO_Bounded_WString_Sequence &operator= (const TAO_Bounded_WString_Sequence<MAX> &);
// {SPEC}
// The assignment operator deep copies its parameter, releasing
// old storage if necessary. It behaves as if the original sequence
// is destroyed via its destructor and then the source sequence
// copied using the copy constructor.
~TAO_Bounded_WString_Sequence (void);
// {SPEC}
// If release=TRUE, the destructor destroys each of the current
// elements (items zero through length-1).
TAO_SeqElem_WString_Manager operator[] (CORBA::ULong slot) const;
// read-write accessor
static CORBA::WChar **allocbuf (CORBA::ULong length);
// {SPEC}
// The allocbuf function allocates a vector of T elements that can
// be passed to the T *data constructor. The length of the vector is
// given by the nelems function argument. The allocbuf function
// initializes each element using its default constructor, except
// for (w)strings, which are initialized to null pointers, and object
// references, which are initialized to suitably typed nil object
// references. A null pointer is returned if allocbuf for some
// reason cannot allocate the requested vector. Vectors allocated by
// allocbuf should be freed using the freebuf function.
static void freebuf (CORBA::WChar **buffer);
// {SPEC}
// The freebuf function ensures that the destructor for each element
// is called before the buffer is destroyed, except for string
// elements, which are freed using wstring_free(), and object
// reference elements, which are freed using release(). The freebuf
// function will ignore null pointers passed to it.
// Functions to create, destroy, and adjust the underlying buffer.
virtual void _allocate_buffer (CORBA::ULong length);
virtual void _deallocate_buffer (void);
virtual void _shrink_buffer (CORBA::ULong new_length,
CORBA::ULong old_length);
};
// *************************************************************
#if defined (__ACE_INLINE__)
#include "tao/Sequence_T.i"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "tao/Sequence_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Sequence_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include "ace/post.h"
#endif /* TAO_SEQUENCE_T_H */
|