Recursive_Type_TypeCode.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Recursive_Type_TypeCode.h
00006  *
00007  *  $Id: Recursive_Type_TypeCode.h 77528 2007-03-05 11:11:05Z johnnyw $
00008  *
00009  *  Header file for a recursive type (@c struct, @c union or
00010  *  @c valuetype) CORBA::TypeCode.
00011  *
00012  *  @author Ossama Othman
00013  */
00014 //=============================================================================
00015 
00016 #ifndef TAO_RECURSIVE_TYPE_TYPECODE_H
00017 #define TAO_RECURSIVE_TYPE_TYPECODE_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "tao/Basic_Types.h"
00022 #include "tao/Typecode_typesC.h"
00023 #include "ace/Recursive_Thread_Mutex.h"
00024 
00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00026 
00027 namespace TAO
00028 {
00029   namespace TypeCode
00030   {
00031 
00032     /**
00033      * @class Recursive_Type
00034      *
00035      * @brief Recursive type @c TypeCode decorator template.
00036      *
00037      * This class template decorates the underlying @c TypeCode
00038      * implementation @a TypeCodeBase to provide support for IDL
00039      * defined recursive types.  Only IDL an @c struct, @c union or
00040      * @c valuetype may be recursive, which is why this decorator only
00041      * supports constructors for the corresponding @c TypeCode
00042      * implementations.
00043      */
00044     template <class TypeCodeBase,
00045               typename TypeCodeType,
00046               typename MemberArrayType>
00047     class Recursive_Type
00048       : public TypeCodeBase
00049     {
00050     public:
00051 
00052       /// Recursive @c struct constructor.
00053       Recursive_Type (CORBA::TCKind kind,
00054                       char const * id,
00055                       char const * name,
00056                       MemberArrayType const & fields,
00057                       CORBA::ULong nfields);
00058 
00059       /// Recursive @c union constructor.
00060       Recursive_Type (char const * id,
00061                       char const * name,
00062 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x572)
00063                       // Borland C++ currently can't handle a
00064                       // reference to const pointer to const
00065                       // CORBA::TypeCode_ptr.
00066                       TypeCodeType discriminant_type,
00067 #else
00068                       TypeCodeType const & discriminant_type,
00069 #endif
00070                       MemberArrayType const & cases,
00071                       CORBA::ULong ncases,
00072                       CORBA::Long default_index);
00073 
00074       /// Recursive @c valuetype constructor.
00075       Recursive_Type (CORBA::TCKind kind,
00076                       char const * id,
00077                       char const * name,
00078                       CORBA::ValueModifier modifier,
00079 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x572)
00080                       // Borland C++ currently can't handle a
00081                       // reference to const pointer to const
00082                       // CORBA::TypeCode_ptr.
00083                       TypeCodeType concrete_base,
00084 #else
00085                       TypeCodeType const & concrete_base,
00086 #endif
00087                       MemberArrayType const & fields,
00088                       CORBA::ULong nfields);
00089 
00090       /// Dynamic @c Recursive_Type TypeCode constructor.
00091       Recursive_Type (CORBA::TCKind kind,
00092                       char const * id);
00093 
00094       /**
00095        * @name TAO-specific @c CORBA::TypeCode Methods
00096        *
00097        * Methods required by TAO's implementation of the
00098        * @c CORBA::TypeCode class.
00099        *
00100        * @par
00101        *
00102        * These are recursive type @c TypeCode marshaling operation
00103        * overrides.
00104        *
00105        * @see @c CORBA::TypeCode
00106        */
00107       //@{
00108       virtual bool tao_marshal_kind (TAO_OutputCDR & cdr) const;
00109       virtual bool tao_marshal (TAO_OutputCDR & cdr,
00110                                 CORBA::ULong offset) const;
00111       //@}
00112 
00113     protected:
00114 
00115       /**
00116        * @name TAO @c CORBA::TypeCode Template Methods
00117        *
00118        * Recursive type @c CORBA::TypeCode -specific
00119        * template methods.
00120        *
00121        * @see @c CORBA::TypeCode
00122        */
00123       //@{
00124       virtual CORBA::Boolean equal_i (CORBA::TypeCode_ptr tc) const;
00125       virtual CORBA::Boolean equivalent_i (CORBA::TypeCode_ptr tc) const;
00126       //@}
00127 
00128     public:
00129 
00130       /// Set @c struct @c TypeCode parameters.
00131       void struct_parameters (char const * name,
00132                               MemberArrayType const & fields,
00133                               CORBA::ULong nfields);
00134 
00135       /// Set @c union @c TypeCode parameters.
00136       void union_parameters (
00137                              char const * name,
00138 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x572)
00139                              // Borland C++ currently can't handle a
00140                              // reference to const pointer to const
00141                              // CORBA::TypeCode_ptr.
00142                              TypeCodeType discriminant_type,
00143 #else
00144                              TypeCodeType const & discriminant_type,
00145 #endif
00146                              MemberArrayType const & cases,
00147                              CORBA::ULong ncases,
00148                              CORBA::Long default_index);
00149 
00150       /// Set @c valuetype or @c eventtype @c TypeCode parameters.
00151       void valuetype_parameters (char const * name,
00152                                  CORBA::ValueModifier modifier,
00153 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x572)
00154                                  // Borland C++ currently can't handle a
00155                                  // reference to const pointer to const
00156                                  // CORBA::TypeCode_ptr.
00157                                  TypeCodeType concrete_base,
00158 #else
00159                                  TypeCodeType const & concrete_base,
00160 #endif
00161                                  MemberArrayType const & fields,
00162                                  CORBA::ULong nfields);
00163 
00164     private:
00165 
00166       /**
00167        * @class Reset
00168        *
00169        * @brief Reset flag to false in an exception-safe manner.
00170        *
00171        * Reset flag to false in an exception-safe manner.
00172        */
00173       class Reset
00174       {
00175       public:
00176         Reset (bool & flag) : flag_ (flag) { }
00177         ~Reset (void) { this->flag_ = false; }
00178       private:
00179         bool & flag_;
00180       };
00181 
00182     private:
00183 
00184       /// Internal state thread synchronization mutex.
00185       mutable TAO_SYNCH_RECURSIVE_MUTEX lock_;
00186 
00187       /// @c true if equality or equivalence is being determined
00188       /// recursively.
00189       /**
00190        * This flag is used to prevent @c TypeCode equality and
00191        * equivalence operations from recursing indefinitely.
00192        */
00193       mutable bool in_recursion_;
00194 
00195     };
00196 
00197   }  // End namespace TypeCode
00198 }  // End namespace TAO
00199 
00200 TAO_END_VERSIONED_NAMESPACE_DECL
00201 
00202 
00203 #ifdef __ACE_INLINE__
00204 # include "tao/AnyTypeCode/Recursive_Type_TypeCode.inl"
00205 #endif  /* __ACE_INLINE__ */
00206 
00207 #ifdef ACE_TEMPLATES_REQUIRE_SOURCE
00208 # include "tao/AnyTypeCode/Recursive_Type_TypeCode.cpp"
00209 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00210 
00211 #ifdef ACE_TEMPLATES_REQUIRE_PRAGMA
00212 # pragma implementation ("Recursive_Type_TypeCode.cpp")
00213 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00214 
00215 #include /**/ "ace/post.h"
00216 
00217 #endif  /* TAO_RECURSIVE_TYPE_TYPECODE_H */

Generated on Sun Jan 27 13:21:06 2008 for TAO_AnyTypeCode by doxygen 1.3.6