Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Sequence_T.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Sequence_T.h
00006  *
00007  *  $Id: Sequence_T.h,v 1.1.1.4 2003/02/21 18:36:45 chad Exp $
00008  *
00009  *  @author Carlos O'Ryan and Aniruddha Gokhale
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_SEQUENCE_T_H
00015 #define TAO_SEQUENCE_T_H
00016 
00017 #include "ace/pre.h"
00018 
00019 #include "tao/Sequence.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 /**
00026  * @class TAO_Unbounded_Sequence
00027  *
00028  * @brief Parametrized implementation of IDL unbounded sequences.
00029  *
00030  * This class completes the implementation for TAO_Base_Sequence
00031  * for the unbounded case.
00032  */
00033 template <class T>
00034 class TAO_Unbounded_Sequence : public TAO_Unbounded_Base_Sequence
00035 {
00036 public:
00037   // = Initialization and termination methods.
00038 
00039   /// Default constructor.
00040   TAO_Unbounded_Sequence (void);
00041 
00042   /// Constructor using a maximum length value.
00043   TAO_Unbounded_Sequence (CORBA::ULong max);
00044 
00045   /**
00046    * Constructor using the data and memory management flag.  Memory
00047    * *must* be allocated using the ::allocbuf static method, since in
00048    * the future this classes may use a global ACE_Allocator.
00049    */
00050   TAO_Unbounded_Sequence (CORBA::ULong max,
00051                           CORBA::ULong length,
00052                           T *data,
00053                           CORBA::Boolean release = 0);
00054 
00055   /// Copy constructor.
00056   TAO_Unbounded_Sequence (const TAO_Unbounded_Sequence<T> &);
00057 
00058   /// Assignment operator.
00059   TAO_Unbounded_Sequence<T> &operator= (const TAO_Unbounded_Sequence<T> &);
00060 
00061   /// Dtor.
00062   ~TAO_Unbounded_Sequence (void);
00063 
00064   // = Accessors.
00065 
00066   /// operator []
00067   T &operator[] (CORBA::ULong);
00068 
00069   /// operator []
00070   const T &operator[] (CORBA::ULong) const;
00071 
00072   // = Static operations.
00073 
00074   /// Allocate storage for the sequence.
00075   static T *allocbuf (CORBA::ULong);
00076 
00077   /// Free the sequence.
00078   static void freebuf (T *);
00079 
00080   /// Implement the TAO_Base_Sequence methods (see Sequence.h)
00081   virtual void _allocate_buffer (CORBA::ULong length);
00082   virtual void _deallocate_buffer (void);
00083 
00084   // = orbos/98-01-11 proposed extensions.
00085   /**
00086    * Allows read-write access to the underlying buffer.  If <orphan>
00087    * is FALSE the sequence returns a pointer to its buffer, allocating
00088    * one if it has not yet done so.  The number of elements in the
00089    * buffer can be determined from the sequence <length> accessor.
00090    *
00091    * If the <orphan> argument to <get_buffer> is FALSE, the sequence
00092    * maintains ownership of the underlying buffer.  Elements in the
00093    * returned buffer may be directly replaced by the caller.  For
00094    * sequences of strings, wide strings, and object references, the
00095    * caller must use the sequence <release> accessor to determine
00096    * whether elements should be freed (using <string_free>,
00097    * <wstring_free>, or <CORBA::release> for strings, wide straings,
00098    * and object references, respective) before being directly assigned
00099    * to.
00100    *
00101    * If the <orphan> argument to <get_buffer> is TRUE, the sequence
00102    * yields ownership of the buffer to the caller.  If <orphan> is
00103    * TRUE and the sequence does not own its buffer (i.e., its
00104    * <release> flag is FALSE), the return value is a null pointer.  If
00105    * the buffer is taken from the sequence using this form of
00106    * <get_buffer>, the sequence reverts to the same state it would
00107    * have if constructed using its default constructor.  The caller
00108    * becomes responsible for eventually freeing each element of the
00109    * returned buffer (for strings, wide string, and object
00110    * references), and then freeing the returned buffer itself using
00111    * <freebuf>.
00112    */
00113   T *get_buffer (CORBA::Boolean orphan = 0);
00114 
00115   /**
00116    * This function allows read-only access to the sequence buffer.
00117    * The sequence returns its buffer, allocating one of one has not
00118    * yet been allocated.  No direct modification of the returned
00119    * buffer by the caller is permitted.
00120    */
00121   const T *get_buffer (void) const;
00122 
00123   /**
00124    * Allows the buffer underlying a sequence to be replaced.  The
00125    * parameters to <replace> are identical in type, order, and purpose
00126    * to those for the <T *data> constructor for the sequence.
00127    */
00128   void replace (CORBA::ULong max,
00129                 CORBA::ULong length,
00130                 T *data,
00131                 CORBA::Boolean release = 0);
00132 };
00133 
00134 // *************************************************************
00135 
00136 /**
00137  * @class TAO_Bounded_Sequence
00138  *
00139  * @brief Parametric bounded sequence.
00140  *
00141  * This class completes the implementation for TAO_Base_Sequence
00142  * for the bounded case.
00143  */
00144 template <class T, size_t MAX>
00145 class TAO_Bounded_Sequence : public TAO_Bounded_Base_Sequence
00146 {
00147 public:
00148   // = Initialization and termination methods.
00149   /// Default constructor.
00150   TAO_Bounded_Sequence (void);
00151 
00152   /// Constructor using the data and memory management flag.
00153   TAO_Bounded_Sequence (CORBA::ULong length,
00154                         T *data,
00155                         CORBA::Boolean release=0);
00156 
00157   /// Copy constructor.
00158   TAO_Bounded_Sequence (const TAO_Bounded_Sequence<T,MAX> &);
00159 
00160   /// Assignment operator.
00161   TAO_Bounded_Sequence<T,MAX> &operator= (
00162       const TAO_Bounded_Sequence<T,MAX> &
00163     );
00164 
00165   /// Dtor.
00166   ~TAO_Bounded_Sequence (void);
00167 
00168   // = Accessors.
00169   /// operator []
00170   T &operator[] (CORBA::ULong);
00171 
00172   /// operator []
00173   const T &operator[] (CORBA::ULong) const;
00174 
00175   // = Static operations.
00176 
00177   /// Allocate storage for the sequence.
00178   static T *allocbuf (CORBA::ULong);
00179 
00180   /// Free the sequence.
00181   static void freebuf (T *);
00182 
00183   /// allocate a buffer of the requested length. The buffer is allocated for
00184   /// the right type
00185   virtual void _allocate_buffer (CORBA::ULong length);
00186 
00187   /// deallocate the buffer
00188   virtual void _deallocate_buffer (void);
00189 
00190   // = orbos/98-01-11 proposed extensions.
00191   /**
00192    * Allows read-write access to the underlying buffer.  If <orphan>
00193    * is FALSE the sequence returns a pointer to its buffer, allocating
00194    * one if it has not yet done so.  The size of the returned buffer
00195    * is equal to the sequence bound, which can be determined with the
00196    * <maximum> accessor.  The number of elements in the buffer can be
00197    * determined from the sequence <length> accessor.
00198    *
00199    * If the <orphan> argument to <get_buffer> is FALSE, the sequence
00200    * maintains ownership of the underlying buffer.  Elements in the
00201    * returned buffer may be directly replaced by the caller.  For
00202    * sequences of strings, wide strings, and object references, the
00203    * caller must use the sequence <release> accessor to determine
00204    * whether elements should be freed (using <string_free>,
00205    * <wstring_free>, or <CORBA::release> for strings, wide straings,
00206    * and object references, respective) before being directly assigned
00207    * to.
00208    *
00209    * If the <orphan> argument to <get_buffer> is TRUE, the sequence
00210    * yields ownership of the buffer to the caller.  If <orphan> is
00211    * TRUE and the sequence does not own its buffer (i.e., its
00212    * <release> flag is FALSE), the return value is a null pointer.  If
00213    * the buffer is taken from the sequence using this form of
00214    * <get_buffer>, the sequence reverts to the same state it would
00215    * have if constructed using its default constructor.  The caller
00216    * becomes responsible for eventually freeing each element of the
00217    * returned buffer (for strings, wide string, and object
00218    * references), and then freeing the returned buffer itself using
00219    * <freebuf>.
00220    */
00221   T *get_buffer (CORBA::Boolean orphan = 0);
00222 
00223   /**
00224    * This function allows read-only access to the sequence buffer.
00225    * The sequence returns its buffer, allocating one of one has not
00226    * yet been allocated.  No direct modification of the returned
00227    * buffer by the caller is permitted.
00228    */
00229   const T *get_buffer (void) const;
00230 
00231   /**
00232    * Allows the buffer underlying a sequence to be replaced.  The
00233    * parameters to <replace> are identical in type, order, and purpose
00234    * to those for the <T *data> constructor for the sequence.
00235    */
00236   void replace (CORBA::ULong max,
00237                 CORBA::ULong length,
00238                 T *data,
00239                 CORBA::Boolean release = 0);
00240 };
00241 
00242 // *************************************************************
00243 
00244 template<class T,class T_var> class TAO_Unbounded_Object_Sequence;
00245 template<class T,class T_var> class TAO_Unbounded_Pseudo_Sequence;
00246 template<class T,class T_var> class TAO_Unbounded_Valuetype_Sequence;
00247 template<class T, class T_var, size_t MAX> class TAO_Bounded_Object_Sequence;
00248 template<class T, class T_var, size_t MAX> class TAO_Bounded_Valuetype_Sequence;
00249 template<size_t MAX> class TAO_Bounded_String_Sequence;
00250 
00251 // *************************************************************
00252 
00253   /**
00254    * @class TAO_Object_Manager
00255    *
00256    * @brief Manager for Objects.
00257    *
00258    * The mapping for sequences of objects (and other pseudo objects)
00259    * requires an auxiliar class or <Manager> to handle the reference
00260    * count on the object, (a kind of smart pointer).
00261    * The main difference with respect to T_var classes is that
00262    * automatic release is not controlled on a per-item basis, but
00263    * for the sequence as a whole.
00264    * Further the class must implement "transparent" assignment into
00265    * the sequence, for instance, operator[] returns a managed
00266    * object, but:
00267    * object_sequence[i] = foo;
00268    * must change the state of the sequence.
00269    * This class implements the generic object manager and is used to
00270    * instantiate the proper sequence types.
00271    * = NOTES
00272    * It has been proposed that the class should be parametric on
00273    * both T and T_ptr, IMHO this is no necesary: though the IDL spec
00274    * says that T_ptr *could* map to a type different to T* in the
00275    * particular case of TAO it does map to <T*>.
00276    */
00277 template<class T, class T_var>
00278 class TAO_Object_Manager
00279 {
00280   friend class TAO_Unbounded_Object_Sequence<T,T_var>;
00281 public:
00282   // @@ Use partial template specialization here to give access only
00283   // to the right kind of sequence.
00284   // friend template<CORBA::ULong MAX>
00285   //    class TAO_Bounded_Object_Sequence<T,MAX>;
00286 
00287   // = Initialization and termination methods.
00288   /**
00289    * Copy constructor, the semantics are non-trivial:
00290    *   + The referenced element is duplicated or not according to the
00291    *   release value on the <rhs>.
00292    *   + In any case a new reference to the same object is created.
00293    */
00294   TAO_Object_Manager (const TAO_Object_Manager<T,T_var> &rhs);
00295 
00296   /**
00297    * Constructor from address of an element, it should be private and
00298    * only TAO_*_Object_Sequence would use it, but we have some
00299    * problems with friendship and templates.
00300    */
00301   TAO_Object_Manager (T **, CORBA::Boolean release);
00302 
00303   /// Destructor, only releases the object if <release_> is true.
00304   ~TAO_Object_Manager (void);
00305 
00306   /**
00307    * Assignment from another managed type, only release if
00308    * <this->release_> is true.
00309    * @@ TODO what happens if rhs.release_ is true an this->relase_ is
00310    * false?
00311    */
00312   TAO_Object_Manager<T,T_var> &operator= (const TAO_Object_Manager<T,T_var> &rhs);
00313 
00314   /// Assignment from T *.
00315   TAO_Object_Manager<T,T_var> &operator= (T *);
00316 
00317   /// Assignment from T_var.
00318   TAO_Object_Manager<T,T_var> &operator= (const T_var &);
00319 
00320   /// Return pointer.
00321   T * operator-> (void) const;
00322 
00323   /// Cast (read-only).
00324   operator const T *() const;
00325 
00326   /// Cast.
00327   operator T *&();
00328 
00329   /// Cast (read-only) so that assignment from a structured
00330   /// type to a T_var will make a copy.
00331   operator const T_var() const;
00332 
00333   /// for in parameter.
00334   T *in (void) const;
00335 
00336   /// for inout parameter.
00337   T *&inout (void);
00338 
00339   /// for out parameter.
00340   T *&out (void);
00341 
00342   /// for return type
00343   T *_retn (void);
00344 
00345 private:
00346   /// data member, notice that it is a pointer, to implement the
00347   /// reference behavior for assignment.
00348   T **ptr_;
00349 
00350   /// release flag based on parent's flag
00351   CORBA::Boolean release_;
00352 };
00353 
00354 // *************************************************************
00355 
00356   /**
00357    * @class TAO_Pseudo_Object_Manager
00358    *
00359    * @brief Manager for Pseudo Objects.
00360    *
00361    */
00362 template<class T, class T_var>
00363 class TAO_Pseudo_Object_Manager
00364 {
00365   friend class TAO_Unbounded_Pseudo_Sequence<T,T_var>;
00366 public:
00367   // @@ Use partial template specialization here to give access only
00368   // to the right kind of sequence.
00369   // friend template<CORBA::ULong MAX>
00370   //    class TAO_Bounded_Object_Sequence<T,MAX>;
00371 
00372   // = Initialization and termination methods.
00373   /**
00374    * Copy constructor, the semantics are non-trivial:
00375    *   + The referenced element is duplicated or not according to the
00376    *   release value on the <rhs>.
00377    *   + In any case a new reference to the same object is created.
00378    */
00379   TAO_Pseudo_Object_Manager (const TAO_Pseudo_Object_Manager<T,T_var> &rhs);
00380 
00381   /**
00382    * Constructor from address of an element, it should be private and
00383    * only TAO_*_Object_Sequence would use it, but we have some
00384    * problems with friendship and templates.
00385    */
00386   TAO_Pseudo_Object_Manager (T **, CORBA::Boolean release);
00387 
00388   /// Destructor, only releases the object if <release_> is true.
00389   ~TAO_Pseudo_Object_Manager (void);
00390 
00391   /**
00392    * Assignment from another managed type, only release if
00393    * <this->release_> is true.
00394    * @@ TODO what happens if rhs.release_ is true an this->relase_ is
00395    * false?
00396    */
00397   TAO_Pseudo_Object_Manager<T,T_var> &operator= (const TAO_Pseudo_Object_Manager<T,T_var> &rhs);
00398 
00399   /// Assignment from T *.
00400   TAO_Pseudo_Object_Manager<T,T_var> &operator= (T *);
00401 
00402   /// Assignment from T_var.
00403   TAO_Pseudo_Object_Manager<T,T_var> &operator= (const T_var &);
00404 
00405   /// Return pointer.
00406   T * operator-> (void) const;
00407 
00408   /// Cast (read-only).
00409   operator const T *() const;
00410 
00411   /// Cast.
00412   operator T *&();
00413 
00414   /// for in parameter.
00415   T *in (void) const;
00416 
00417   /// for inout parameter.
00418   T *&inout (void);
00419 
00420   /// for out parameter.
00421   T *&out (void);
00422 
00423   /// for return type
00424   T *_retn (void);
00425 
00426 private:
00427   /// data member, notice that it is a pointer, to implement the
00428   /// reference behavior for assignment.
00429   T **ptr_;
00430 
00431   /// release flag based on parent's flag
00432   CORBA::Boolean release_;
00433 };
00434 
00435 // *************************************************************
00436 
00437   /**
00438    * @class TAO_Valuetype_Manager
00439    *
00440    * @brief Manager for valuetypes.
00441    *
00442    * According to the spec., valuetypes are handled similarly to object
00443    * references, so a manager class is needed.
00444    *
00445    * @see TAO_Object_Manager
00446    */
00447 template<class T, class T_var>
00448 class TAO_Valuetype_Manager
00449 {
00450   friend class TAO_Unbounded_Valuetype_Sequence<T,T_var>;
00451 public:
00452   // @@ Use partial template specialization here to give access only
00453   // to the right kind of sequence.
00454   // friend template<CORBA::ULong MAX>
00455   //    class TAO_Bounded_Valuetype_Sequence<T,MAX>;
00456 
00457   // = Initialization and termination methods.
00458   /**
00459    * Copy constructor, the semantics are non-trivial:
00460    *   + The referenced element is duplicated or not according to the
00461    *   release value on the <rhs>.
00462    *   + In any case a new reference to the same object is created.
00463    */
00464   TAO_Valuetype_Manager (const TAO_Valuetype_Manager<T,T_var> &rhs);
00465 
00466   /**
00467    * Constructor from address of an element, it should be private and
00468    * only TAO_*_Object_Sequence would use it, but we have some
00469    * problems with friendship and templates.
00470    */
00471   TAO_Valuetype_Manager (T **, 
00472                          CORBA::Boolean release);
00473 
00474   /// Destructor, only releases the object if <release_> is true.
00475   ~TAO_Valuetype_Manager (void);
00476 
00477   /**
00478    * Assignment from another managed type, only release if
00479    * <this->release_> is true.
00480    * @@ TODO what happens if rhs.release_ is true an this->relase_ is
00481    * false?
00482    */
00483   TAO_Valuetype_Manager<T,T_var> &operator= (const TAO_Valuetype_Manager<T,T_var> &rhs);
00484 
00485   /// Assignment from T *.
00486   TAO_Valuetype_Manager<T,T_var> &operator= (T *);
00487 
00488   /// Assignment from T_var.
00489   TAO_Valuetype_Manager<T,T_var> &operator= (const T_var &);
00490 
00491   /// Return pointer.
00492   T * operator-> (void) const;
00493 
00494   /// Cast (read-only).
00495   operator const T *() const;
00496 
00497   /// Cast.
00498   operator T *&();
00499 
00500   /// Cast (read-only) so that assignment from a structured
00501   /// type to a T_var will make a copy.
00502   operator const T_var() const;
00503 
00504   /// for in parameter.
00505   T *in (void) const;
00506 
00507   /// for inout parameter.
00508   T *&inout (void);
00509 
00510   /// for out parameter.
00511   T *&out (void);
00512 
00513   /// for return type
00514   T *_retn (void);
00515 
00516 private:
00517   /// data member, notice that it is a pointer, to implement the
00518   /// reference behavior for assignment.
00519   T **ptr_;
00520 
00521   /// release flag based on parent's flag
00522   CORBA::Boolean release_;
00523 };
00524 
00525 // *************************************************************
00526 
00527   /**
00528    * @class TAO_Abstract_Manager
00529    *
00530    * @brief Manager for abstract intefaces.
00531    *
00532    * An abstract interface can be either a valuetype or an object
00533    * references, so a manager class is needed.
00534    *
00535    * @see TAO_Object_Manager
00536    */
00537 template<class T, class T_var>
00538 class TAO_Abstract_Manager
00539 {
00540 //  friend class TAO_Unbounded_Abstract_Sequence<T,T_var>;
00541 public:
00542   // = Initialization and termination methods.
00543   /**
00544    * Copy constructor, the semantics are non-trivial:
00545    *   + The referenced element is duplicated or not according to the
00546    *   release value on the <rhs>.
00547    *   + In any case a new reference to the same object is created.
00548    */
00549   TAO_Abstract_Manager (const TAO_Abstract_Manager<T,T_var> &rhs);
00550 
00551   /**
00552    * Constructor from address of an element, it should be private and
00553    * only TAO_*_Object_Sequence would use it, but we have some
00554    * problems with friendship and templates.
00555    */
00556   TAO_Abstract_Manager (T **, 
00557                         CORBA::Boolean release);
00558 
00559   /// Destructor, only releases the object if <release_> is true.
00560   ~TAO_Abstract_Manager (void);
00561 
00562   /**
00563    * Assignment from another managed type, only release if
00564    * <this->release_> is true.
00565    * @@ TODO what happens if rhs.release_ is true an this->relase_ is
00566    * false?
00567    */
00568   TAO_Abstract_Manager<T,T_var> &operator= (const TAO_Abstract_Manager<T,T_var> &rhs);
00569 
00570   /// Assignment from T *.
00571   TAO_Abstract_Manager<T,T_var> &operator= (T *);
00572 
00573   /// Assignment from T_var.
00574   TAO_Abstract_Manager<T,T_var> &operator= (const T_var &);
00575 
00576   /// Return pointer.
00577   T *operator-> (void) const;
00578 
00579   /// Cast (read-only).
00580   operator const T *() const;
00581 
00582   /// Cast.
00583   operator T *&();
00584 
00585   /// Cast (read-only) so that assignment from a structured
00586   /// type to a T_var will make a copy.
00587   operator const T_var () const;
00588 
00589   /// for in parameter.
00590   T *in (void) const;
00591 
00592   /// for inout parameter.
00593   T *& inout (void);
00594 
00595   /// for out parameter.
00596   T *& out (void);
00597 
00598   /// for return type
00599   T *_retn (void);
00600 
00601 private:
00602   /// data member, notice that it is a pointer, to implement the
00603   /// reference behavior for assignment.
00604   T **ptr_;
00605 
00606   /// release flag based on parent's flag
00607   CORBA::Boolean release_;
00608 };
00609 
00610 // *************************************************************
00611 
00612 /**
00613  * @class TAO_Unbounded_Object_Sequence
00614  *
00615  * @brief Parametric sequence for types that require managers.
00616  *
00617  * Some IDL types require that sequences on them have a "manager"
00618  * class, in charge of handling the object lifetime, examples are
00619  * pseudo objects, object references, valuetypes, and strings.
00620  */
00621 template<class T,class T_var>
00622 class TAO_Unbounded_Object_Sequence : public TAO_Unbounded_Base_Sequence
00623 {
00624 
00625   // = SPEC
00626   //   16.8 Mapping for Structured Types
00627   //   The mapping for struct, union, and sequence (but not array) is a
00628   //   C++ struct or class with a default constructor, a copy
00629   //   constructor, an assignment operator, and a destructor.
00630   //
00631 public:
00632   // = Initialization and termination methods.
00633 
00634   /**
00635    * {orbos/97-05-15:16.8}
00636    * The default constructor initializes object reference members to
00637    * appropriately typed nil object references and string members to
00638    * NULL; all other members are initialized via their default
00639    * constructors.
00640    *
00641    * {orbos/97-05-15:16.11}
00642    * For both bounded and unbounded sequences, the default constructor
00643    * (as shown in the example above) sets the sequence length equal to
00644    * 0.
00645    */
00646   TAO_Unbounded_Object_Sequence (void);
00647 
00648   /**
00649    * Unbounded sequences provide a constructor that allows only the
00650    * initial value of the maximum length to be set (the ``maximum
00651    * constructor'' shown in the example above). This allows
00652    * applications to control how much buffer space is initially
00653    * allocated by the sequence. This constructor also sets the length
00654    * to 0 and the release flag to TRUE.
00655    */
00656   TAO_Unbounded_Object_Sequence (CORBA::ULong max);
00657 
00658   /**
00659    * The ``T *data'' constructor (as shown in the example above)
00660    * allows the length and contents of a bounded or unbounded sequence
00661    * to be set. For unbounded sequences, it also allows the initial
00662    * value of the maximum length to be set. For this constructor,
00663    * ownership of the contents vector is determined by the release
00664    * parameter---FALSE means the caller owns the storage, while TRUE
00665    * means that the sequence assumes ownership of the storage.
00666    * If release is TRUE, the contents vector must have been allocated
00667    * using the sequence allocbuf function, and the sequence will pass
00668    * it to freebuf when finished with it.
00669    */
00670   TAO_Unbounded_Object_Sequence (CORBA::ULong maximum,
00671                                  CORBA::ULong length,
00672                                  T* *data,
00673                                  CORBA::Boolean release=0);
00674 
00675   /**
00676    * The copy constructor performs a deep copy from the existing
00677    * structure to create a new structure, including calling _duplicate
00678    * on all object  reference members and performing the necessary
00679    * heap allocations for all string members.
00680    *
00681    * The copy constructor creates a new sequence with the same maximum
00682    * and length as the given sequence, copies each of its current
00683    * elements (items zero through length-1), and sets the release
00684    * flag to TRUE.
00685    */
00686   TAO_Unbounded_Object_Sequence(const TAO_Unbounded_Object_Sequence<T,T_var> &);
00687 
00688   /// The destructor releases all object reference memebrs and frees
00689   /// all string members.
00690   ~TAO_Unbounded_Object_Sequence (void);
00691 
00692   /**
00693    * The assignment operator first releases all object reference
00694    * members and frees all string members, and then performs a
00695    * deepcopy to create a new structure.
00696    *
00697    * The assignment operator deepcopies its parameter, releasing old
00698    * storage if necessary. It behaves as if the original sequence is
00699    * destroyed via its destructor and then the source sequence copied
00700    * using the copy constructor. If release=TRUE, the destructor
00701    * destroys each of the current elements (items zero through
00702    * length--1).  For an unbounded sequence, if a reallocation is
00703    * necessary due to a change in the length and the sequence was
00704    * created using the release=TRUE parameter in its constructor, the
00705    * sequence will deallocate the old storage. If release is FALSE
00706    * under these circumstances, old storage will not be freed before
00707    * the reallocation is performed. After reallocation, the release
00708    * flag is always set to TRUE.
00709    */
00710   TAO_Unbounded_Object_Sequence<T,T_var> &operator= (const TAO_Unbounded_Object_Sequence <T,T_var> &);
00711 
00712   /// read-write accessor
00713   TAO_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
00714 
00715   /**
00716    * The allocbuf function allocates a vector of T elements that can
00717    * be passed to the T *data constructor. The length of the vector is
00718    * given by the nelems function argument.  The allocbuf function
00719    * initializes each element using its default constructor, except
00720    * for strings, which are initialized to null pointers, and object
00721    * references, which are initialized to suitably typed nil object
00722    * references. A null pointer is returned if allocbuf for some
00723    * reason cannot allocate the requested vector. Vectors allocated by
00724    * allocbuf should be freed using the freebuf function.
00725    */
00726   static T **allocbuf (CORBA::ULong);
00727 
00728   /**
00729    * The freebuf function ensures that the destructor for each element
00730    * is called before the buffer is destroyed, except for string
00731    * elements, which are freed using string_free(), and object
00732    * reference elements, which are freed using release(). The freebuf
00733    * function will ignore null pointers passed to it.
00734    */
00735   static void freebuf (T **);
00736 
00737   // The Base_Sequence functions, please see "tao/Sequence.h"
00738   /// No default to workaround egcs problem with templates and
00739   /// namespaces
00740   virtual void _allocate_buffer (CORBA::ULong length);
00741   virtual void _deallocate_buffer (void);
00742   virtual void _shrink_buffer (CORBA::ULong new_length,
00743                                CORBA::ULong old_length);
00744   virtual void _downcast (void* target,
00745                           CORBA_Object* src
00746                           ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00747   virtual CORBA_Object* _upcast (void* src) const;
00748 };
00749 
00750 // *************************************************************
00751 
00752 /**
00753  * @class TAO_Bounded_Object_Sequence
00754  *
00755  * @brief Parametric sequence for types that require managers.
00756  *
00757  * Please see the documentation for the unbounded case.
00758  */
00759 template<class T, class T_var, size_t MAX>
00760 class TAO_Bounded_Object_Sequence : public TAO_Bounded_Base_Sequence
00761 {
00762 public:
00763   // = Initialization and termination methods.
00764 
00765   /**
00766    * For bounded sequences, the maximum length is part of the type and
00767    * cannot be set or modified, while for unbounded sequences, the
00768    * default constructor also sets the maximum length to 0. The
00769    * default constructor for a bounded sequence always allocates a
00770    * contents vector, so it always sets the release flag to TRUE.
00771    */
00772   TAO_Bounded_Object_Sequence (void);
00773 
00774   /// Constructor from data.
00775   TAO_Bounded_Object_Sequence (CORBA::ULong length,
00776                                T* *value,
00777                                CORBA::Boolean release=0);
00778 
00779   /// Copy constructor.
00780   TAO_Bounded_Object_Sequence (const TAO_Bounded_Object_Sequence<T,T_var,MAX> &);
00781 
00782   /// destructor
00783   ~TAO_Bounded_Object_Sequence (void);
00784 
00785   /// Assignment from another Bounded sequence.
00786   TAO_Bounded_Object_Sequence &operator= (const TAO_Bounded_Object_Sequence<T,T_var,MAX> &);
00787 
00788   /// Read-write accessor.
00789   TAO_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
00790 
00791   /// Allocate storage for a sequence..
00792   static T **allocbuf (CORBA::ULong length);
00793 
00794   /// Free a buffer allocated by allocbuf() and release each element on
00795   /// it.
00796   static void freebuf (T **buffer);
00797 
00798   // The Base_Sequence functions, please see "tao/sequence.h"
00799   /// No default to workaround egcs problem with templates and
00800   /// namespaces
00801   virtual void _allocate_buffer (CORBA::ULong length);
00802   virtual void _deallocate_buffer (void);
00803   virtual void _shrink_buffer (CORBA::ULong new_length,
00804                                CORBA::ULong old_length);
00805   virtual void _downcast (void* target,
00806                           CORBA_Object* src
00807                           ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00808   virtual CORBA_Object* _upcast (void* src) const;
00809 };
00810 
00811 // *************************************************************
00812 
00813 /**
00814  * @class TAO_Unbounded_Pseudo_Sequence
00815  *
00816  * @brief Parametric sequence for pseudo objects.
00817  *
00818  * Some IDL types (including pseudo objects) require that
00819  * sequences on them have a "manager" class, in charge of handling
00820  * the object lifetime.
00821  * This parametric class implements those sequences. In general
00822  * the sequence is similar to Object_Sequente, except for some
00823  * TAO internal details. The complete documentation of each method
00824  * is provided in TAO_Unbounded_Object_Sequece
00825  */
00826 template<class T,class T_var>
00827 class TAO_Unbounded_Pseudo_Sequence : public TAO_Unbounded_Base_Sequence
00828 {
00829 public:
00830   // = Initialization and termination methods.
00831 
00832   /// default ctor
00833   TAO_Unbounded_Pseudo_Sequence (void);
00834 
00835   /// Constructor with a "hint" for the maximum capacity.
00836   TAO_Unbounded_Pseudo_Sequence (CORBA::ULong max);
00837 
00838   /// Constructor with a given buffer.
00839   TAO_Unbounded_Pseudo_Sequence (CORBA::ULong maximum,
00840                                  CORBA::ULong length,
00841                                  T* *data,
00842                                  CORBA::Boolean release=0);
00843 
00844   /// Copy ctor, deep copies.
00845   TAO_Unbounded_Pseudo_Sequence(const TAO_Unbounded_Pseudo_Sequence<T,T_var> &);
00846 
00847   /// dtor releases all the contained elements.
00848   ~TAO_Unbounded_Pseudo_Sequence (void);
00849 
00850   /**
00851    * The assignment operator first releases all object reference
00852    * members and frees all string members, and then performs a
00853    * deepcopy to create a new structure.
00854    */
00855   TAO_Unbounded_Pseudo_Sequence<T,T_var> &operator= (const TAO_Unbounded_Pseudo_Sequence <T,T_var> &);
00856 
00857   /// read-write accessor
00858   TAO_Pseudo_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
00859 
00860   /// The allocbuf function allocates a vector of T elements that can
00861   /// be passed to the T *data constructor.
00862   static T **allocbuf (CORBA::ULong);
00863 
00864   /// Release all the elements.
00865   static void freebuf (T **);
00866 
00867   // The Base_Sequence functions, please see "tao/Sequence.h"
00868   virtual void _allocate_buffer (CORBA::ULong length);
00869   virtual void _deallocate_buffer (void);
00870   virtual void _shrink_buffer (CORBA::ULong new_length,
00871                                CORBA::ULong old_length);
00872 };
00873 
00874 // *************************************************************
00875 
00876 /**
00877  * @class TAO_Bounded_Pseudo_Sequence
00878  *
00879  * @brief Bounded version of TAO_Unbounded_Pseudo_Sequence.
00880  *
00881  * Please see the documentation for the unbounded case.
00882  */
00883 template<class T, class T_var, size_t MAX>
00884 class TAO_Bounded_Pseudo_Sequence : public TAO_Bounded_Base_Sequence
00885 {
00886 public:
00887   // = Initialization and termination methods.
00888 
00889   /// default ctor.
00890   TAO_Bounded_Pseudo_Sequence (void);
00891 
00892   /// Constructor from data.
00893   TAO_Bounded_Pseudo_Sequence (CORBA::ULong length,
00894                                T* *value,
00895                                CORBA::Boolean release=0);
00896 
00897   /// Copy constructor.
00898   TAO_Bounded_Pseudo_Sequence (const TAO_Bounded_Pseudo_Sequence<T,T_var,MAX> &);
00899 
00900   /// destructor
00901   ~TAO_Bounded_Pseudo_Sequence (void);
00902 
00903   /// Assignment from another Bounded sequence.
00904   TAO_Bounded_Pseudo_Sequence &operator= (const TAO_Bounded_Pseudo_Sequence<T,T_var,MAX> &);
00905 
00906   /// Read-write accessor.
00907   TAO_Pseudo_Object_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
00908 
00909   /// Allocate storage for a sequence..
00910   static T **allocbuf (CORBA::ULong length);
00911 
00912   /// Free a buffer allocated by allocbuf() and release each element on
00913   /// it.
00914   static void freebuf (T **buffer);
00915 
00916   // The Base_Sequence functions, please see "tao/sequence.h"
00917   virtual void _allocate_buffer (CORBA::ULong length);
00918   virtual void _deallocate_buffer (void);
00919   virtual void _shrink_buffer (CORBA::ULong new_length,
00920                                CORBA::ULong old_length);
00921 };
00922 
00923 // *************************************************************
00924 
00925 /**
00926  * @class TAO_Unbounded_Valuetype_Sequence
00927  *
00928  * @brief Parametric sequence for valuetypes
00929  *
00930  * @see TAO_Unbounded_Object_Sequence
00931  */
00932 template<class T,class T_var>
00933 class TAO_Unbounded_Valuetype_Sequence : public TAO_Unbounded_Base_Sequence
00934 {
00935 public:
00936   // = Initialization and termination methods.
00937 
00938   // Default ctor.
00939   TAO_Unbounded_Valuetype_Sequence (void);
00940 
00941   /// Constructor with a "hint" for the maximum capacity.
00942   TAO_Unbounded_Valuetype_Sequence (CORBA::ULong max);
00943 
00944   /// Constructor with a given buffer.
00945   TAO_Unbounded_Valuetype_Sequence (CORBA::ULong maximum,
00946                                     CORBA::ULong length,
00947                                     T* *data,
00948                                     CORBA::Boolean release=0);
00949 
00950   /// Copy ctor, deep copies.
00951   TAO_Unbounded_Valuetype_Sequence (
00952       const TAO_Unbounded_Valuetype_Sequence<T,T_var> &
00953     );
00954 
00955   /// The destructor releases all object reference memebrs and frees
00956   /// all string members.
00957   ~TAO_Unbounded_Valuetype_Sequence (void);
00958 
00959   /**
00960    * The assignment operator first releases all object reference
00961    * members and frees all string members, and then performs a
00962    * deepcopy to create a new structure.
00963    */
00964   TAO_Unbounded_Valuetype_Sequence<T,T_var> &operator= (
00965       const TAO_Unbounded_Valuetype_Sequence <T,T_var> &
00966     );
00967 
00968   /// read-write accessor
00969   TAO_Valuetype_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
00970 
00971   /// The allocbuf function allocates a vector of T elements that can
00972   /// be passed to the T *data constructor.
00973   static T **allocbuf (CORBA::ULong);
00974 
00975   /// Release all the elements.
00976   static void freebuf (T **);
00977 
00978   // The Base_Sequence functions, please see "tao/Sequence.h"
00979   /// No default to workaround egcs problem with templates and
00980   /// namespaces
00981   virtual void _allocate_buffer (CORBA::ULong length);
00982   virtual void _deallocate_buffer (void);
00983   virtual void _shrink_buffer (CORBA::ULong new_length,
00984                                CORBA::ULong old_length);
00985 };
00986 
00987 // *************************************************************
00988 
00989 /**
00990  * @class TAO_Bounded_Valuetype_Sequence
00991  *
00992  * @brief Parametric sequence for types that require managers.
00993  *
00994  * Please see the documentation for the unbounded case.
00995  */
00996 template<class T, class T_var, size_t MAX>
00997 class TAO_Bounded_Valuetype_Sequence : public TAO_Bounded_Base_Sequence
00998 {
00999 public:
01000   // = Initialization and termination methods.
01001 
01002   // Default ctor.
01003   TAO_Bounded_Valuetype_Sequence (void);
01004 
01005   /// Constructor from data.
01006   TAO_Bounded_Valuetype_Sequence (CORBA::ULong length,
01007                                   T* *value,
01008                                   CORBA::Boolean release=0);
01009 
01010   /// Copy constructor.
01011   TAO_Bounded_Valuetype_Sequence (
01012       const TAO_Bounded_Valuetype_Sequence<T,T_var,MAX> &
01013     );
01014 
01015   /// destructor
01016   ~TAO_Bounded_Valuetype_Sequence (void);
01017 
01018   /// Assignment from another Bounded sequence.
01019   TAO_Bounded_Valuetype_Sequence &operator= (
01020       const TAO_Bounded_Valuetype_Sequence<T,T_var,MAX> &
01021     );
01022 
01023   /// Read-write accessor.
01024   TAO_Valuetype_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
01025 
01026   /// Allocate storage for a sequence..
01027   static T **allocbuf (CORBA::ULong length);
01028 
01029   /// Free a buffer allocated by allocbuf() and release each element on
01030   /// it.
01031   static void freebuf (T **buffer);
01032 
01033   // The Base_Sequence functions, please see "tao/sequence.h"
01034   /// No default to workaround egcs problem with templates and
01035   /// namespaces
01036   virtual void _allocate_buffer (CORBA::ULong length);
01037   virtual void _deallocate_buffer (void);
01038   virtual void _shrink_buffer (CORBA::ULong new_length,
01039                                CORBA::ULong old_length);
01040 };
01041 
01042 // *************************************************************
01043 
01044 /**
01045  * @class TAO_Unbounded_Abstract_Sequence
01046  *
01047  * @brief Parametric sequence for abstract interfaces
01048  *
01049  * @see TAO_Unbounded_Object_Sequence
01050  */
01051 template<class T,class T_var>
01052 class TAO_Unbounded_Abstract_Sequence : public TAO_Unbounded_Base_Sequence
01053 {
01054 public:
01055   // = Initialization and termination methods.
01056 
01057   // Default ctor.
01058   TAO_Unbounded_Abstract_Sequence (void);
01059 
01060   /// Constructor with a "hint" for the maximum capacity.
01061   TAO_Unbounded_Abstract_Sequence (CORBA::ULong max);
01062 
01063   /// Constructor with a given buffer.
01064   TAO_Unbounded_Abstract_Sequence (CORBA::ULong maximum,
01065                                    CORBA::ULong length,
01066                                    T* *data,
01067                                    CORBA::Boolean release=0);
01068 
01069   /// Copy ctor, deep copies.
01070   TAO_Unbounded_Abstract_Sequence (
01071       const TAO_Unbounded_Abstract_Sequence<T,T_var> &
01072     );
01073 
01074   /// The destructor releases all object reference memebrs and frees
01075   /// all string members.
01076   ~TAO_Unbounded_Abstract_Sequence (void);
01077 
01078   /**
01079    * The assignment operator first releases all object reference
01080    * members and frees all string members, and then performs a
01081    * deepcopy to create a new structure.
01082    */
01083   TAO_Unbounded_Abstract_Sequence<T,T_var> &operator= (
01084       const TAO_Unbounded_Abstract_Sequence <T,T_var> &
01085     );
01086 
01087   /// read-write accessor
01088   TAO_Abstract_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
01089 
01090   /// The allocbuf function allocates a vector of T elements that can
01091   /// be passed to the T *data constructor.
01092   static T **allocbuf (CORBA::ULong);
01093 
01094   /// Release all the elements.
01095   static void freebuf (T **);
01096 
01097   // The Base_Sequence functions, please see "tao/Sequence.h"
01098   /// No default to workaround egcs problem with templates and
01099   /// namespaces
01100   virtual void _allocate_buffer (CORBA::ULong length);
01101   virtual void _deallocate_buffer (void);
01102   virtual void _shrink_buffer (CORBA::ULong new_length,
01103                                CORBA::ULong old_length);
01104 };
01105 
01106 // *************************************************************
01107 
01108 /**
01109  * @class TAO_Bounded_Abstract_Sequence
01110  *
01111  * @brief Parametric sequence for types that require managers.
01112  *
01113  * Please see the documentation for the unbounded case.
01114  */
01115 template<class T, class T_var, size_t MAX>
01116 class TAO_Bounded_Abstract_Sequence : public TAO_Bounded_Base_Sequence
01117 {
01118 public:
01119   // = Initialization and termination methods.
01120 
01121   // Default ctor.
01122   TAO_Bounded_Abstract_Sequence (void);
01123 
01124   /// Constructor from data.
01125   TAO_Bounded_Abstract_Sequence (CORBA::ULong length,
01126                                  T* *value,
01127                                  CORBA::Boolean release=0);
01128 
01129   /// Copy constructor.
01130   TAO_Bounded_Abstract_Sequence (
01131       const TAO_Bounded_Abstract_Sequence<T,T_var,MAX> &
01132     );
01133 
01134   /// destructor
01135   ~TAO_Bounded_Abstract_Sequence (void);
01136 
01137   /// Assignment from another Bounded sequence.
01138   TAO_Bounded_Abstract_Sequence &operator= (
01139       const TAO_Bounded_Abstract_Sequence<T,T_var,MAX> &
01140     );
01141 
01142   /// Read-write accessor.
01143   TAO_Abstract_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
01144 
01145   /// Allocate storage for a sequence..
01146   static T **allocbuf (CORBA::ULong length);
01147 
01148   /// Free a buffer allocated by allocbuf() and release each element on
01149   /// it.
01150   static void freebuf (T **buffer);
01151 
01152   // The Base_Sequence functions, please see "tao/sequence.h"
01153   /// No default to workaround egcs problem with templates and
01154   /// namespaces
01155   virtual void _allocate_buffer (CORBA::ULong length);
01156   virtual void _deallocate_buffer (void);
01157   virtual void _shrink_buffer (CORBA::ULong new_length,
01158                                CORBA::ULong old_length);
01159 };
01160 
01161 // *************************************************************
01162 
01163 /**
01164  * @class TAO_Unbounded_Array_Sequence
01165  *
01166  * @brief Parametric sequence for arrays.
01167  *
01168  * The IDL mapping for arrays includes some unique allocation,
01169  * deallocation, and copying functions, and precludes
01170  * direct assignment of one array to another. Also, the
01171  * Any and CDR operators use a special class derived from
01172  * the array. For these reasons, we use a special class for
01173  * sequences of arrays, parametrized on the array element type.
01174  */
01175 template<class T, class T_var>
01176 class TAO_Unbounded_Array_Sequence : public TAO_Unbounded_Base_Sequence
01177 {
01178 public:
01179   // = Initialization and termination methods.
01180 
01181   /// default ctor
01182   TAO_Unbounded_Array_Sequence (void);
01183 
01184   /// Constructor with a "hint" for the maximum capacity.
01185   TAO_Unbounded_Array_Sequence (CORBA::ULong max);
01186 
01187   /// Constructor with a given buffer.
01188   TAO_Unbounded_Array_Sequence (CORBA::ULong maximum,
01189                                 CORBA::ULong length,
01190                                 T *data,
01191                                 CORBA::Boolean release=0);
01192 
01193   /// Copy ctor, deep copies.
01194   TAO_Unbounded_Array_Sequence(const TAO_Unbounded_Array_Sequence<T, T_var> &);
01195 
01196   /// dtor releases all the contained elements.
01197   ~TAO_Unbounded_Array_Sequence (void);
01198 
01199   /**
01200    * The assignment operator first releases all object reference
01201    * members and frees all string members, and then performs a
01202    * deepcopy to create a new structure.
01203    */
01204   TAO_Unbounded_Array_Sequence<T, T_var> &operator= (
01205       const TAO_Unbounded_Array_Sequence <T, T_var> &
01206     );
01207 
01208   // = Accessors.
01209   /// operator []
01210   T &operator[] (CORBA::ULong);
01211 
01212   /// operator []
01213   const T &operator[] (CORBA::ULong) const;
01214 
01215   /// The allocbuf function allocates a vector of T elements that can
01216   /// be passed to the T *data constructor.
01217   static T *allocbuf (CORBA::ULong);
01218 
01219   /// Release all the elements.
01220   static void freebuf (T *);
01221 
01222   /// allocate a buffer of the requested length. The buffer is allocated for the
01223   /// right type
01224   virtual void _allocate_buffer (CORBA::ULong length);
01225 
01226   /// deallocate the buffer
01227   virtual void _deallocate_buffer (void);
01228 
01229   // = orbos/98-01-11 proposed extensions.
01230   /**
01231    * Allows read-write access to the underlying buffer.  If <orphan>
01232    * is FALSE the sequence returns a pointer to its buffer, allocating
01233    * one if it has not yet done so.  The number of elements in the
01234    * buffer can be determined from the sequence <length> accessor.
01235    *
01236    * If the <orphan> argument to <get_buffer> is FALSE, the sequence
01237    * maintains ownership of the underlying buffer.  Elements in the
01238    * returned buffer may be directly replaced by the caller.
01239    *
01240    * If the <orphan> argument to <get_buffer> is TRUE, the sequence
01241    * yields ownership of the buffer to the caller.  If <orphan> is
01242    * TRUE and the sequence does not own its buffer (i.e., its
01243    * <release> flag is FALSE), the return value is a null pointer.  If
01244    * the buffer is taken from the sequence using this form of
01245    * <get_buffer>, the sequence reverts to the same state it would
01246    * have if constructed using its default constructor.  The caller
01247    * becomes responsible for eventually freeing each element of the
01248    * returned buffer (for strings, wide string, and object
01249    * references), and then freeing the returned buffer itself using
01250    * <freebuf>.
01251    */
01252   T *get_buffer (CORBA::Boolean orphan = 0);
01253 
01254   /**
01255    * This function allows read-only access to the sequence buffer.
01256    * The sequence returns its buffer, allocating one of one has not
01257    * yet been allocated.  No direct modification of the returned
01258    * buffer by the caller is permitted.
01259    */
01260   const T *get_buffer (void) const;
01261 
01262   /**
01263    * Allows the buffer underlying a sequence to be replaced.  The
01264    * parameters to <replace> are identical in type, order, and purpose
01265    * to those for the <T *data> constructor for the sequence.
01266    */
01267   void replace (CORBA::ULong max,
01268                 CORBA::ULong length,
01269                 T *data,
01270                 CORBA::Boolean release = 0);
01271 };
01272 
01273 // *************************************************************
01274 
01275 /**
01276  * @class TAO_Bounded_Array_Sequence
01277  *
01278  * @brief Bounded version of TAO_Unbounded_Array_Sequence.
01279  *
01280  * Please see the documentation for the unbounded case.
01281  */
01282 template<class T, class T_var, size_t MAX>
01283 class TAO_Bounded_Array_Sequence : public TAO_Bounded_Base_Sequence
01284 {
01285 public:
01286   // = Initialization and termination methods.
01287 
01288   /// default ctor.
01289   TAO_Bounded_Array_Sequence (void);
01290 
01291   /// Constructor from data.
01292   TAO_Bounded_Array_Sequence (CORBA::ULong length,
01293                               T *value,
01294                               CORBA::Boolean release=0);
01295 
01296   /// Copy constructor.
01297   TAO_Bounded_Array_Sequence (const TAO_Bounded_Array_Sequence<T, T_var, MAX> &);
01298 
01299   /// destructor
01300   ~TAO_Bounded_Array_Sequence (void);
01301 
01302   /// Assignment from another Bounded sequence.
01303   TAO_Bounded_Array_Sequence &operator= (const TAO_Bounded_Array_Sequence<T, T_var, MAX> &);
01304 
01305   // = Accessors.
01306   /// operator []
01307   T &operator[] (CORBA::ULong);
01308 
01309   /// operator []
01310   const T &operator[] (CORBA::ULong) const;
01311 
01312   /// Allocate storage for a sequence..
01313   static T *allocbuf (CORBA::ULong length);
01314 
01315   /// Free a buffer allocated by allocbuf() and release each element on
01316   /// it.
01317   static void freebuf (T *buffer);
01318 
01319   /// allocate a buffer of the requested length. The buffer is allocated for the
01320   /// right type
01321   virtual void _allocate_buffer (CORBA::ULong length);
01322 
01323   /// deallocate the buffer
01324   virtual void _deallocate_buffer (void);
01325 
01326   // = orbos/98-01-11 proposed extensions.
01327   /**
01328    * Allows read-write access to the underlying buffer.  If <orphan>
01329    * is FALSE the sequence returns a pointer to its buffer, allocating
01330    * one if it has not yet done so.  The number of elements in the
01331    * buffer can be determined from the sequence <length> accessor.
01332    *
01333    * If the <orphan> argument to <get_buffer> is FALSE, the sequence
01334    * maintains ownership of the underlying buffer.  Elements in the
01335    * returned buffer may be directly replaced by the caller.
01336    *
01337    * If the <orphan> argument to <get_buffer> is TRUE, the sequence
01338    * yields ownership of the buffer to the caller.  If <orphan> is
01339    * TRUE and the sequence does not own its buffer (i.e., its
01340    * <release> flag is FALSE), the return value is a null pointer.  If
01341    * the buffer is taken from the sequence using this form of
01342    * <get_buffer>, the sequence reverts to the same state it would
01343    * have if constructed using its default constructor.  The caller
01344    * becomes responsible for eventually freeing each element of the
01345    * returned buffer (for strings, wide string, and object
01346    * references), and then freeing the returned buffer itself using
01347    * <freebuf>.
01348    */
01349   T *get_buffer (CORBA::Boolean orphan = 0);
01350 
01351   /**
01352    * This function allows read-only access to the sequence buffer.
01353    * The sequence returns its buffer, allocating one of one has not
01354    * yet been allocated.  No direct modification of the returned
01355    * buffer by the caller is permitted.
01356    */
01357   const T *get_buffer (void) const;
01358 
01359   /**
01360    * Allows the buffer underlying a sequence to be replaced.  The
01361    * parameters to <replace> are identical in type, order, and purpose
01362    * to those for the <T *data> constructor for the sequence.
01363    */
01364   void replace (CORBA::ULong max,
01365                 CORBA::ULong length,
01366                 T *data,
01367                 CORBA::Boolean release = 0);
01368 };
01369 
01370 // *************************************************************
01371 
01372 /**
01373  * @class TAO_Bounded_String_Sequence
01374  *
01375  * @brief Bounded sequence of strings.
01376  *
01377  * As its unbounded counterpart it duplicates and releases strings
01378  * (via CORBA::string_dup and CORBA::string_free) under the
01379  * control of a per sequence flag, but the capacity of the
01380  * sequence is bound on the type.
01381  */
01382 template<size_t MAX>
01383 class TAO_Bounded_String_Sequence : public TAO_Bounded_Base_Sequence
01384 {
01385 public:
01386   /**
01387    * {SPEC}
01388    * For bounded sequences, the maximum length is part of the type and
01389    * cannot be set or modified, while for unbounded  sequences, the
01390    * default constructor also sets the maximum length to 0. The
01391    * default constructor for a bounded sequence always allocates a
01392    * contents vector, so it always sets the release flag to TRUE.
01393    */
01394   TAO_Bounded_String_Sequence (void);
01395 
01396   /**
01397    * {SPEC}
01398    * The ``T *data'' constructor (as shown in the example above)
01399    * allows the length and contents of a bounded or unbounded sequence
01400    * to be set. For unbounded sequences, it also allows the initial
01401    * value of the maximum length to be set. For this constructor,
01402    * ownership of the contents vector is determined by the release
01403    * parameter---FALSE means the caller owns the storage, while TRUE
01404    * means that the sequence assumes ownership of the storage.
01405    *
01406    * If release is TRUE, the contents vector must have been allocated
01407    * using the sequence  allocbuf function, and the sequence will pass
01408    * it to freebuf when finished with it.
01409    */
01410   TAO_Bounded_String_Sequence (CORBA::ULong length,
01411                                char* *value,
01412                                CORBA::Boolean release = 0);
01413 
01414   /**
01415    * {SPEC}
01416    * Management Functions'' on page 16. The copy constructor creates a
01417    * new sequence with the same maximum and length as the given
01418    * sequence, copies each of its current elements (items zero through
01419    * length--1), and sets the release flag to TRUE.
01420    */
01421   TAO_Bounded_String_Sequence (const TAO_Bounded_String_Sequence<MAX> &);
01422 
01423   /**
01424    * {SPEC}
01425    * The assignment operator deep copies its parameter, releasing
01426    * old storage if necessary. It behaves as if the original sequence
01427    * is destroyed via its destructor and then the source sequence
01428    * copied using the copy constructor.
01429    */
01430   TAO_Bounded_String_Sequence &operator= (const TAO_Bounded_String_Sequence<MAX> &);
01431 
01432   /**
01433    * {SPEC}
01434    * If release=TRUE, the destructor destroys each of the current
01435    * elements (items zero through length-1).
01436    */
01437   ~TAO_Bounded_String_Sequence (void);
01438 
01439   /// read-write accessor
01440   TAO_SeqElem_String_Manager operator[] (CORBA::ULong slot) const;
01441 
01442   /**
01443    * {SPEC}
01444    * The allocbuf function allocates a vector of T elements that can
01445    * be passed to the T *data constructor. The length of the vector is
01446    * given by the nelems function argument.  The allocbuf function
01447    * initializes each element using its default constructor, except
01448    * for strings, which are initialized to null pointers, and object
01449    * references, which are initialized to suitably typed nil object
01450    * references. A null pointer is returned if allocbuf for some
01451    * reason cannot allocate the requested vector. Vectors allocated by
01452    * allocbuf should be freed using the freebuf function.
01453    */
01454   static char **allocbuf (CORBA::ULong length);
01455 
01456   /**
01457    * {SPEC}
01458    * The freebuf function ensures that the destructor for each element
01459    * is called before the buffer is destroyed, except for string
01460    * elements, which are freed using string_free(), and object
01461    * reference elements, which are freed using release(). The freebuf
01462    * function will ignore null pointers passed to it.
01463    */
01464   static void freebuf (char **buffer);
01465 
01466   // Functions to create, destroy, and adjust the underlying buffer.
01467   virtual void _allocate_buffer (CORBA::ULong length);
01468   virtual void _deallocate_buffer (void);
01469   virtual void _shrink_buffer (CORBA::ULong new_length,
01470                                CORBA::ULong old_length);
01471 
01472   // Parameters work the same as in constructor of the same signature.
01473   void replace (CORBA::ULong length,
01474                 char* *value,
01475                 CORBA::Boolean release = 0);
01476 };
01477 
01478 // *************************************************************
01479 
01480 /**
01481  * @class TAO_Bounded_WString_Sequence
01482  *
01483  * @brief Bounded sequence of wstrings.
01484  *
01485  * As its unbounded counterpart it duplicates and releases strings
01486  * (via CORBA::wstring_dup and CORBA::wstring_free) under the
01487  * control of a per sequence flag, but the capacity of the
01488  * sequence is bound on the type.
01489  */
01490 template<size_t MAX>
01491 class TAO_Bounded_WString_Sequence : public TAO_Bounded_Base_Sequence
01492 {
01493 public:
01494   /**
01495    * {SPEC}
01496    * For bounded sequences, the maximum length is part of the type and
01497    * cannot be set or modified, while for unbounded  sequences, the
01498    * default constructor also sets the maximum length to 0. The
01499    * default constructor for a bounded sequence always allocates a
01500    * contents vector, so it always sets the release flag to TRUE.
01501    */
01502   TAO_Bounded_WString_Sequence (void);
01503 
01504   /**
01505    * {SPEC}
01506    * The ``T *data'' constructor (as shown in the example above)
01507    * allows the length and contents of a bounded or unbounded sequence
01508    * to be set. For unbounded sequences, it also allows the initial
01509    * value of the maximum length to be set. For this constructor,
01510    * ownership of the contents vector is determined by the release
01511    * parameter---FALSE means the caller owns the storage, while TRUE
01512    * means that the sequence assumes ownership of the storage.
01513    *
01514    * If release is TRUE, the contents vector must have been allocated
01515    * using the sequence  allocbuf function, and the sequence will pass
01516    * it to freebuf when finished with it.
01517    */
01518   TAO_Bounded_WString_Sequence (CORBA::ULong length,
01519                                 CORBA::WChar* *value,
01520                                 CORBA::Boolean release = 0);
01521 
01522   /**
01523    * {SPEC}
01524    * Management Functions'' on page 16. The copy constructor creates a
01525    * new sequence with the same maximum and length as the given
01526    * sequence, copies each of its current elements (items zero through
01527    * length--1), and sets the release flag to TRUE.
01528    */
01529   TAO_Bounded_WString_Sequence (const TAO_Bounded_WString_Sequence<MAX> &);
01530 
01531   /**
01532    * {SPEC}
01533    * The assignment operator deep copies its parameter, releasing
01534    * old storage if necessary. It behaves as if the original sequence
01535    * is destroyed via its destructor and then the source sequence
01536    * copied using the copy constructor.
01537    */
01538   TAO_Bounded_WString_Sequence &operator= (const TAO_Bounded_WString_Sequence<MAX> &);
01539 
01540   /**
01541    * {SPEC}
01542    * If release=TRUE, the destructor destroys each of the current
01543    * elements (items zero through length-1).
01544    */
01545   ~TAO_Bounded_WString_Sequence (void);
01546 
01547   /// read-write accessor
01548   TAO_SeqElem_WString_Manager operator[] (CORBA::ULong slot) const;
01549 
01550   /**
01551    * {SPEC}
01552    * The allocbuf function allocates a vector of T elements that can
01553    * be passed to the T *data constructor. The length of the vector is
01554    * given by the nelems function argument.  The allocbuf function
01555    * initializes each element using its default constructor, except
01556    * for (w)strings, which are initialized to null pointers, and object
01557    * references, which are initialized to suitably typed nil object
01558    * references. A null pointer is returned if allocbuf for some
01559    * reason cannot allocate the requested vector. Vectors allocated by
01560    * allocbuf should be freed using the freebuf function.
01561    */
01562   static CORBA::WChar **allocbuf (CORBA::ULong length);
01563 
01564   /**
01565    * {SPEC}
01566    * The freebuf function ensures that the destructor for each element
01567    * is called before the buffer is destroyed, except for string
01568    * elements, which are freed using wstring_free(), and object
01569    * reference elements, which are freed using release(). The freebuf
01570    * function will ignore null pointers passed to it.
01571    */
01572   static void freebuf (CORBA::WChar **buffer);
01573 
01574   // Functions to create, destroy, and adjust the underlying buffer.
01575   virtual void _allocate_buffer (CORBA::ULong length);
01576   virtual void _deallocate_buffer (void);
01577   virtual void _shrink_buffer (CORBA::ULong new_length,
01578                                CORBA::ULong old_length);
01579 
01580   // Parameters work the same as in constructor of the same signature.
01581   void replace (CORBA::ULong length,
01582                 CORBA::WChar* *value,
01583                 CORBA::Boolean release = 0);
01584 };
01585 
01586 // *************************************************************
01587 
01588 #if defined (__ACE_INLINE__)
01589 #include "tao/Sequence_T.i"
01590 
01591 #if !defined (ACE_LACKS_PRAGMA_ONCE)
01592 # pragma once
01593 #endif /* ACE_LACKS_PRAGMA_ONCE */
01594 
01595 #endif /* __ACE_INLINE__ */
01596 
01597 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
01598 #include "tao/Sequence_T.cpp"
01599 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
01600 
01601 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
01602 #pragma implementation ("Sequence_T.cpp")
01603 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
01604 
01605 #include "ace/post.h"
01606 
01607 #endif /* TAO_SEQUENCE_T_H */

Generated on Mon Jun 16 13:49:48 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002