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

Managed_Types.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Managed_Types.h
00006  *
00007  *  $Id: Managed_Types.h,v 1.1.1.3 2001/12/04 14:34:46 chad Exp $
00008  *
00009  *  @author Aniruddha Gokhale
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_MANAGED_TYPES_H
00015 #define TAO_MANAGED_TYPES_H
00016 #include "ace/pre.h"
00017 
00018 #include "tao/corbafwd.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 /****************************************************************/
00025 
00026 /**
00027  * @class TAO_String_Manager
00028  *
00029  * @brief Manager for strings.
00030  *
00031  * This class implements the generic string manager and is used in the C++
00032  * mapping of "struct" members that are of type "string". The difference
00033  * between this class and the CORBA::String_var class is that the default
00034  * conctructor initializes the underlying string to an empty string in this
00035  * class whereas it is a NUL string for the _var class.
00036  */
00037 class TAO_Export TAO_String_Manager
00038 {
00039 public:
00040 
00041   /// default CTOR will initialize the underlying ptr_ to empty string.
00042   TAO_String_Manager (void);
00043 
00044   /// copy constructor
00045   TAO_String_Manager (const TAO_String_Manager &);
00046 
00047   /// destructor
00048   ~TAO_String_Manager (void);
00049 
00050   /// assignment from another managed type
00051   TAO_String_Manager &operator= (const TAO_String_Manager&);
00052 
00053   /// assignment from var type will make a copy
00054   TAO_String_Manager &operator= (const CORBA::String_var&);
00055 
00056   /// assignment from a constant char* will make a copy
00057   TAO_String_Manager &operator= (const char *);
00058 
00059   /// assignment from char* will not make a copy. The String_Manager will now
00060   /// own the string.
00061   TAO_String_Manager &operator= (char *);
00062 
00063   /// cast  (read-only)
00064   operator const char*() const;
00065 
00066   /// for in parameter.
00067   const char *in (void) const;
00068 
00069   /// for inout parameter.
00070   char *&inout (void);
00071 
00072   /// for out parameter.
00073   char *&out (void);
00074 
00075   /// for string of return type.
00076   char *_retn (void);
00077 
00078 private:
00079   /// The underlying string
00080   char *ptr_;
00081 
00082 };
00083 
00084 /****************************************************************/
00085 
00086 /**
00087  * @class TAO_SeqElem_String_Manager
00088  *
00089  * @brief TAO_SeqElem_String_Manager
00090  *
00091  * Manager for strings that are the element type of sequences.
00092  * Similar to the mapping for sequences of objects (and other
00093  * pseudo objects) the mapping for sequences of strings requires
00094  * an auxiliar class or <Manager> to handle the allocation and
00095  * deallocation of the string.  The main difference with respect
00096  * to String_var classes is that automatic release is not
00097  * controlled on a per-item basis, but for the sequence as a
00098  * whole.  The difference wrt Object_Manager is that strings are
00099  * duplicated using CORBA::string_dup () as opposed to
00100  * T::_duplicate(), and released using CORBA::string_free()
00101  * instead of CORBA::release()
00102  * This class implements the generic string manager and is used to
00103  * instantiate the proper sequence types.
00104  * This class will have the same semantics as the string manager classes
00105  * defined earlier with respect to the various assignment
00106  * operators. However, the freeing of old storage will be dependent on the
00107  * "release" value of the parent sequence class.
00108  */
00109 class TAO_Export TAO_SeqElem_String_Manager
00110 {
00111 public:
00112   friend class TAO_Unbounded_String_Sequence;
00113 
00114   // @@ Giving friendship to a template is not implemented on several
00115   // compilers:
00116   // friend template<CORBA::ULong MAX>
00117   //   class TAO_Bounded_String_Sequence<TAO_SeqElem_String_Manager,MAX>;
00118 
00119   /// copy constructor
00120   TAO_SeqElem_String_Manager (const TAO_SeqElem_String_Manager &);
00121 
00122   /// constructor from address of an element
00123   TAO_SeqElem_String_Manager (char **buffer, CORBA::Boolean release);
00124 
00125   /// destructor
00126   ~TAO_SeqElem_String_Manager (void);
00127 
00128   /// assignment from another managed type
00129   TAO_SeqElem_String_Manager &operator= (const TAO_SeqElem_String_Manager&);
00130 
00131   /// assignment from var type will make a copy
00132   TAO_SeqElem_String_Manager &operator= (const CORBA::String_var&);
00133 
00134   /// assignment from a constant char* will make a copy
00135   TAO_SeqElem_String_Manager &operator= (const char *);
00136 
00137   /// assignment from char* will not make a copy. The SeqElem_String_Manager will now
00138   /// own the string.
00139   TAO_SeqElem_String_Manager &operator= (char *);
00140 
00141   /// cast  (read-only)
00142   operator const char*() const;
00143 
00144   /// for in parameter.
00145   const char *in (void) const;
00146 
00147   /// for inout parameter.
00148   char *&inout (void);
00149 
00150   /// for out parameter.
00151   char *&out (void);
00152 
00153   /// for string of return type.
00154   char *_retn (void);
00155 
00156 private:
00157   /// Address of string element from the parent's buffer.
00158   char **ptr_;
00159 
00160   /// control memory managment semantics.
00161   CORBA::Boolean release_;
00162 
00163   // following are now allowed since these managed class will be used only by
00164   // the [] operator of the sequence class. The [] operator will not use the
00165   // following ctors to instantiate the managed instance
00166 
00167   /// default ctor
00168   TAO_SeqElem_String_Manager (void);
00169 
00170 };
00171 
00172 // ****************************************************************
00173 
00174 /**
00175  * @class TAO_WString_Manager
00176  *
00177  * @brief Manager for wide strings.
00178  *
00179  * This class implements the generic wstring manager and is used
00180  * in the C++ mapping of "struct" members that are of type
00181  * "wstring".
00182  * The difference between this class and the CORBA::WString_var
00183  * class is that the default constructor initializes the
00184  * underlying wstring to an empty string in this class whereas it
00185  * is a NUL wstring for the _var class.
00186  */
00187 class TAO_Export TAO_WString_Manager
00188 {
00189 public:
00190 
00191   /// default CTOR will initialize the underlying ptr_ to empty string.
00192   TAO_WString_Manager (void);
00193 
00194   /// copy constructor
00195   TAO_WString_Manager (const TAO_WString_Manager &);
00196 
00197   /// destructor
00198   ~TAO_WString_Manager (void);
00199 
00200   /// assignment from another managed type
00201   TAO_WString_Manager &operator= (const TAO_WString_Manager&);
00202 
00203   /// assignment from var type will make a copy
00204   TAO_WString_Manager &operator= (const CORBA::WString_var&);
00205 
00206   /// assignment from a constant wchar* will make a copy
00207   TAO_WString_Manager &operator= (const CORBA::WChar *);
00208 
00209   /// assignment from wchar* will not make a copy. The WString_Manager
00210   /// will now own the string.
00211   TAO_WString_Manager &operator= (CORBA::WChar *);
00212 
00213   /// cast  (read-only)
00214   operator const CORBA::WChar*() const;
00215 
00216   /// for in parameter.
00217   const CORBA::WChar *in (void) const;
00218 
00219   /// for inout parameter.
00220   CORBA::WChar *&inout (void);
00221 
00222   /// for out parameter.
00223   CORBA::WChar *&out (void);
00224 
00225   /// for string of return type.
00226   CORBA::WChar *_retn (void);
00227 
00228 private:
00229   /// The underlying wide string
00230   CORBA::WChar *ptr_;
00231 
00232 };
00233 
00234 /****************************************************************/
00235 
00236 /**
00237  * @class TAO_SeqElem_WString_Manager
00238  *
00239  * @brief TAO_SeqElem_WString_Manager
00240  *
00241  * Manager for strings that are the element type of sequences.
00242  * Similar to the mapping for sequences of objects (and other
00243  * pseudo objects) the mapping for sequences of strings requires
00244  * an auxiliar class or <Manager> to handle the allocation and
00245  * deallocation of the string.  The main difference with respect
00246  * to WString_var classes is that automatic release is not
00247  * controlled on a per-item basis, but for the sequence as a
00248  * whole.  The difference wrt Object_Manager is that strings are
00249  * duplicated using CORBA::WString_dup () as opposed to
00250  * T::_duplicate(), and released using CORBA::WString_free()
00251  * instead of CORBA::release()
00252  * This class implements the generic string manager and is used to
00253  * instantiate the proper sequence types.
00254  * This class will have the same semantics as the string manager
00255  * classes defined earlier with respect to the various assignment
00256  * operators. However, the freeing of old storage will be
00257  * dependent on the "release" value of the parent sequence class.
00258  */
00259 class TAO_Export TAO_SeqElem_WString_Manager
00260 {
00261 public:
00262   friend class TAO_Unbounded_WString_Sequence;
00263 
00264   // @@ Giving friendship to a template is not implemented on several
00265   // compilers:
00266   // friend template<CORBA::ULong MAX>
00267   //   class TAO_Bounded_WString_Sequence<TAO_SeqElem_WString_Manager,MAX>;
00268 
00269   /// constructor from address of an element
00270   TAO_SeqElem_WString_Manager (CORBA::WChar **buffer,
00271                                CORBA::Boolean release);
00272 
00273   /// copy constructor
00274   TAO_SeqElem_WString_Manager (const TAO_SeqElem_WString_Manager &);
00275 
00276   /// destructor
00277   ~TAO_SeqElem_WString_Manager (void);
00278 
00279   /// assignment from another managed type
00280   TAO_SeqElem_WString_Manager &operator= (const TAO_SeqElem_WString_Manager&);
00281 
00282   /// assignment from var type will make a copy
00283   TAO_SeqElem_WString_Manager &operator= (const CORBA::WString_var&);
00284 
00285   /// assignment from a constant char* will make a copy
00286   TAO_SeqElem_WString_Manager &operator= (const CORBA::WChar *);
00287 
00288   /// assignment from char* will not make a copy. The
00289   /// SeqElem_WString_Manager will now own the string.
00290   TAO_SeqElem_WString_Manager &operator= (CORBA::WChar *);
00291 
00292   /// cast  (read-only)
00293   operator const CORBA::WChar*() const;
00294 
00295   /// for in parameter.
00296   const CORBA::WChar *in (void) const;
00297 
00298   /// for inout parameter.
00299   CORBA::WChar *&inout (void);
00300 
00301   /// for out parameter.
00302   CORBA::WChar *&out (void);
00303 
00304   /// for string of return type.
00305   CORBA::WChar *_retn (void);
00306 
00307 private:
00308   /// Address of string element from the parent's buffer.
00309   CORBA::WChar **ptr_;
00310 
00311   /// control memory managment semantics.
00312   CORBA::Boolean release_;
00313 
00314   // following are now allowed since these managed class will be used only by
00315   // the [] operator of the sequence class. The [] operator will not use the
00316   // following ctors to instantiate the managed instance
00317 
00318   /// default ctor
00319   TAO_SeqElem_WString_Manager (void);
00320 
00321 };
00322 
00323 #if defined (__ACE_INLINE__)
00324 #include "tao/Managed_Types.i"
00325 #endif /* __ACE_INLINE__ */
00326 
00327 #include "ace/post.h"
00328 #endif /* TAO_MANAGED_TYPES_H */

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